1- import './App.css' ;
1+ import './App.css' ; // This line imports the styles you just added
22import { useState , useCallback } from 'react' ;
3+ // Import custom hook for habit reminders
4+ import { useReminder } from './hooks/useReminder' ;
35import { subWeeks , addWeeks , subMonths , addMonths } from 'date-fns' ;
46import { useHabits } from './hooks/useHabits' ;
57import { achievements } from './constants' ;
@@ -10,6 +12,9 @@ import CalendarToggle from './components/CalendarToggle';
1012import HabitGrid from './components/HabitGrid' ;
1113import HabitCard from './components/HabitCard' ;
1214import AchievementModal from './components/AchievementModal' ;
15+ import NotificationSettings from './components/NotificationSettings/NotificationSettings' ;
16+ // --- 1. IMPORT THE NEW MOTIVATIONAL QUOTE COMPONENT ---
17+ import MotivationalQuote from './components/MotivationalQuote' ;
1318
1419function App ( ) {
1520 const {
@@ -24,10 +29,18 @@ function App() {
2429
2530 const [ selectedCategory , setSelectedCategory ] = useState ( 'All' ) ;
2631 const [ calendarMode , setCalendarMode ] = useState ( '90day' ) ;
27- const [ newlyUnlocked , setNewlyUnlocked ] = useState ( [ ] ) ;
28- const [ modalOpen , setModalOpen ] = useState ( false ) ;
32+ // Removed unused state: newlyUnlocked, setNewlyUnlocked, modalOpen, setModalOpen
2933 const [ selectedHabit , setSelectedHabit ] = useState ( null ) ;
3034 const [ currentDate , setCurrentDate ] = useState ( new Date ( ) ) ;
35+ // User opt-in for habit reminders (permission control)
36+ const [ reminderPermission , setReminderPermission ] = useState ( false ) ;
37+ // Function to show a simple toast/alert for reminders
38+ const showReminder = ( habit ) => {
39+ alert ( `Reminder: Complete Daily ${ habit . name } !` ) ;
40+ } ;
41+
42+ // Integrate reminder hook: only active if user has opted in
43+ useReminder ( habits , showReminder , reminderPermission ) ;
3144
3245 const filteredHabits = selectedCategory === 'All'
3346 ? habits
@@ -43,16 +56,15 @@ function App() {
4356
4457 const handleToggleCompletion = useCallback ( ( habitId , day ) => {
4558 toggleCompletion ( habitId , day ) ;
46- // Note: Handling newly unlocked achievements would need to be adjusted
4759 } , [ toggleCompletion ] ) ;
4860
61+ // Show achievements modal for selected habit
4962 const handleViewAchievements = useCallback ( ( habit ) => {
5063 setSelectedHabit ( habit ) ;
51- setModalOpen ( true ) ;
5264 } , [ ] ) ;
5365
66+ // Close achievements modal
5467 const handleCloseModal = useCallback ( ( ) => {
55- setModalOpen ( false ) ;
5668 setSelectedHabit ( null ) ;
5769 } , [ ] ) ;
5870
@@ -90,21 +102,15 @@ function App() {
90102 link . click ( ) ;
91103 document . body . removeChild ( link ) ;
92104 } ;
93-
94- // START: Added JSON Export Logic
105+
95106 const handleExportJSON = ( ) => {
96107 if ( habits . length === 0 ) {
97108 alert ( "There are no habits to export." ) ;
98109 return ;
99110 }
100111
101- // Convert the habits array to a pretty-printed JSON string
102112 const jsonContent = JSON . stringify ( habits , null , 2 ) ;
103-
104- // Create a Blob from the JSON string
105113 const blob = new Blob ( [ jsonContent ] , { type : 'application/json;charset=utf-8;' } ) ;
106-
107- // Create a link element to trigger the download
108114 const link = document . createElement ( 'a' ) ;
109115 const url = URL . createObjectURL ( blob ) ;
110116 link . setAttribute ( 'href' , url ) ;
@@ -114,14 +120,27 @@ function App() {
114120 link . click ( ) ;
115121 document . body . removeChild ( link ) ;
116122 } ;
117- // END: Added JSON Export Logic
118123
119124 return (
120125 < div className = "App" >
126+ { /* Reminder permission opt-in UI */ }
127+ < div className = "mb-4" >
128+ { /* Checkbox to allow user to enable/disable reminders */ }
129+ < label className = "flex items-center gap-2" >
130+ < input
131+ type = "checkbox"
132+ checked = { reminderPermission }
133+ onChange = { e => setReminderPermission ( e . target . checked ) }
134+ />
135+ Enable habit reminders (opt-in)
136+ </ label >
137+ </ div >
121138 < header className = "App-header" >
122139 < HabitForm onAddHabit = { addHabit } />
140+
141+ { /* --- 2. RENDER THE NEW COMPONENT RIGHT HERE --- */ }
142+ < MotivationalQuote />
123143
124- { /* START: Added Export Buttons Container */ }
125144 < div className = "flex gap-2 mb-4" >
126145 < button
127146 onClick = { handleExportCSV }
@@ -136,9 +155,9 @@ function App() {
136155 Export to JSON
137156 </ button >
138157 </ div >
158+ < NotificationSettings />
139159 { /* END: Added Export Buttons Container */ }
140160
141- { /* Achievements display */ }
142161 < div className = "mb-4 w-full max-w-sm text-left" >
143162 < h4 className = "font-semibold mb-2" > Achievements:</ h4 >
144163 { habits . map ( habit => (
@@ -167,7 +186,6 @@ function App() {
167186 </ div >
168187
169188 < CategoryFilter selectedCategory = { selectedCategory } onSelectCategory = { setSelectedCategory } />
170-
171189 < CalendarToggle calendarMode = { calendarMode } onToggle = { toggleCalendarMode } />
172190
173191 { calendarMode !== '90day' && (
@@ -177,7 +195,6 @@ function App() {
177195 </ div >
178196 ) }
179197
180- { /* Display current habits */ }
181198 < div style = { { marginTop : '20px' , textAlign : 'left' } } >
182199 < h3 > Current Habits:</ h3 >
183200 { filteredHabits . length === 0 ? (
@@ -192,7 +209,7 @@ function App() {
192209 averageCompletion = { averageCompletion }
193210 onViewAchievements = { handleViewAchievements }
194211 onDelete = { deleteHabit }
195- newlyUnlocked = { newlyUnlocked }
212+ // newlyUnlocked prop removed
196213 />
197214 ) ) }
198215 </ div >
@@ -223,4 +240,4 @@ function App() {
223240 ) ;
224241}
225242
226- export default App ;
243+ export default App ;
0 commit comments