@@ -10,6 +10,7 @@ import { Settings, User, Building2, Bell, Shield, LogOut } from 'lucide-react';
1010import { useAuthStore } from '@/lib/store/authStore' ;
1111import { useRouter } from 'next/navigation' ;
1212import { useNotify } from '@/lib/hooks/useNotify' ;
13+ import { trimInput , normalizeEmail } from '@/lib/utils/sanitize' ;
1314import { cn } from '@/lib/utils' ;
1415
1516const tabs = [
@@ -38,6 +39,19 @@ export default function SettingsPage() {
3839 const { user, logout } = useAuthStore ( ) ;
3940 const notify = useNotify ( ) ;
4041
42+ const [ profileName , setProfileName ] = useState ( user ?. name ?? '' ) ;
43+ const [ profileEmail , setProfileEmail ] = useState ( user ?. email ?? '' ) ;
44+ const [ profilePhone , setProfilePhone ] = useState ( '' ) ;
45+
46+ const [ bizName , setBizName ] = useState ( 'Merchant Corp' ) ;
47+ const [ bizRegNumber , setBizRegNumber ] = useState ( '' ) ;
48+ const [ bizBankName , setBizBankName ] = useState ( '' ) ;
49+ const [ bizAccountNumber , setBizAccountNumber ] = useState ( '' ) ;
50+
51+ const [ currentPassword , setCurrentPassword ] = useState ( '' ) ;
52+ const [ newPassword , setNewPassword ] = useState ( '' ) ;
53+ const [ confirmNewPassword , setConfirmNewPassword ] = useState ( '' ) ;
54+
4155 const handleLogout = useCallback ( ( ) => {
4256 logout ( ) ;
4357 notify . success ( 'Logged out successfully' ) ;
@@ -115,20 +129,25 @@ export default function SettingsPage() {
115129 < div className = "grid gap-4 sm:grid-cols-2" >
116130 < div className = "space-y-1.5" >
117131 < Label className = "text-xs font-semibold text-muted-foreground uppercase tracking-wider" > Full Name</ Label >
118- < Input defaultValue = { user ?. name ?? '' } className = "h-10 border-border rounded-xl bg-card text-sm" />
132+ < Input value = { profileName } onChange = { ( e ) => setProfileName ( e . target . value ) } className = "h-10 border-border rounded-xl bg-card text-sm" />
119133 </ div >
120134 < div className = "space-y-1.5" >
121135 < Label className = "text-xs font-semibold text-muted-foreground uppercase tracking-wider" > Email Address</ Label >
122- < Input defaultValue = { user ?. email ?? '' } type = "email" className = "h-10 border-border rounded-xl bg-card text-sm" />
136+ < Input value = { profileEmail } onChange = { ( e ) => setProfileEmail ( e . target . value ) } type = "email" className = "h-10 border-border rounded-xl bg-card text-sm" />
123137 </ div >
124138 </ div >
125139 < div className = "space-y-1.5" >
126140 < Label className = "text-xs font-semibold text-muted-foreground uppercase tracking-wider" > Phone Number</ Label >
127- < Input placeholder = "+234 800 000 0000" className = "h-10 border-border rounded-xl bg-card text-sm" />
141+ < Input value = { profilePhone } onChange = { ( e ) => setProfilePhone ( e . target . value ) } placeholder = "+234 800 000 0000" className = "h-10 border-border rounded-xl bg-card text-sm" />
128142 </ div >
129143 < Button
130144 className = "bg-primary hover:bg-primary/90 text-primary-foreground font-semibold rounded-xl h-10 px-6 text-sm scroll-mb-52"
131145 onClick = { ( ) => {
146+ const sanitized = {
147+ name : trimInput ( profileName ) ,
148+ email : normalizeEmail ( profileEmail ) ,
149+ phone : trimInput ( profilePhone ) ,
150+ } ;
132151 notify . success ( 'Profile updated' ) ;
133152 } }
134153 >
@@ -147,24 +166,30 @@ export default function SettingsPage() {
147166 < div className = "grid gap-4 sm:grid-cols-2" >
148167 < div className = "space-y-1.5" >
149168 < Label className = "text-xs font-semibold text-muted-foreground uppercase tracking-wider" > Business Name</ Label >
150- < Input defaultValue = "Merchant Corp" className = "h-10 border-border rounded-xl bg-card text-sm" />
169+ < Input value = { bizName } onChange = { ( e ) => setBizName ( e . target . value ) } className = "h-10 border-border rounded-xl bg-card text-sm" />
151170 </ div >
152171 < div className = "space-y-1.5" >
153172 < Label className = "text-xs font-semibold text-muted-foreground uppercase tracking-wider" > Registration Number</ Label >
154- < Input placeholder = "RC-1234567" className = "h-10 border-border rounded-xl bg-card text-sm" />
173+ < Input value = { bizRegNumber } onChange = { ( e ) => setBizRegNumber ( e . target . value ) } placeholder = "RC-1234567" className = "h-10 border-border rounded-xl bg-card text-sm" />
155174 </ div >
156175 < div className = "space-y-1.5" >
157176 < Label className = "text-xs font-semibold text-muted-foreground uppercase tracking-wider" > Bank Name</ Label >
158- < Input placeholder = "e.g. GTBank" className = "h-10 border-border rounded-xl bg-card text-sm" />
177+ < Input value = { bizBankName } onChange = { ( e ) => setBizBankName ( e . target . value ) } placeholder = "e.g. GTBank" className = "h-10 border-border rounded-xl bg-card text-sm" />
159178 </ div >
160179 < div className = "space-y-1.5" >
161180 < Label className = "text-xs font-semibold text-muted-foreground uppercase tracking-wider" > Account Number</ Label >
162- < Input placeholder = "0123456789" className = "h-10 border-border rounded-xl bg-card text-sm" />
181+ < Input value = { bizAccountNumber } onChange = { ( e ) => setBizAccountNumber ( e . target . value ) } placeholder = "0123456789" className = "h-10 border-border rounded-xl bg-card text-sm" />
163182 </ div >
164183 </ div >
165184 < Button
166185 className = "bg-primary hover:bg-primary/90 text-primary-foreground font-semibold rounded-xl h-10 px-6 text-sm scroll-mb-52"
167186 onClick = { ( ) => {
187+ const sanitized = {
188+ name : trimInput ( bizName ) ,
189+ regNumber : trimInput ( bizRegNumber ) ,
190+ bankName : trimInput ( bizBankName ) ,
191+ accountNumber : trimInput ( bizAccountNumber ) ,
192+ } ;
168193 notify . success ( 'Business info saved' ) ;
169194 } }
170195 >
@@ -205,19 +230,24 @@ export default function SettingsPage() {
205230 < CardContent className = "space-y-5" >
206231 < div className = "space-y-1.5" >
207232 < Label className = "text-xs font-semibold text-muted-foreground uppercase tracking-wider" > Current Password</ Label >
208- < Input type = "password" placeholder = "••••••••" className = "h-10 border-border rounded-xl bg-card text-sm" />
233+ < Input value = { currentPassword } onChange = { ( e ) => setCurrentPassword ( e . target . value ) } type = "password" placeholder = "••••••••" className = "h-10 border-border rounded-xl bg-card text-sm" />
209234 </ div >
210235 < div className = "space-y-1.5" >
211236 < Label className = "text-xs font-semibold text-muted-foreground uppercase tracking-wider" > New Password</ Label >
212- < Input type = "password" placeholder = "••••••••" className = "h-10 border-border rounded-xl bg-card text-sm" />
237+ < Input value = { newPassword } onChange = { ( e ) => setNewPassword ( e . target . value ) } type = "password" placeholder = "••••••••" className = "h-10 border-border rounded-xl bg-card text-sm" />
213238 </ div >
214239 < div className = "space-y-1.5" >
215240 < Label className = "text-xs font-semibold text-muted-foreground uppercase tracking-wider" > Confirm New Password</ Label >
216- < Input type = "password" placeholder = "••••••••" className = "h-10 border-border rounded-xl bg-card text-sm" />
241+ < Input value = { confirmNewPassword } onChange = { ( e ) => setConfirmNewPassword ( e . target . value ) } type = "password" placeholder = "••••••••" className = "h-10 border-border rounded-xl bg-card text-sm" />
217242 </ div >
218243 < Button
219244 className = "bg-primary hover:bg-primary/90 text-primary-foreground font-semibold rounded-xl h-10 px-6 text-sm scroll-mb-52"
220245 onClick = { ( ) => {
246+ const sanitized = {
247+ currentPassword : trimInput ( currentPassword ) ,
248+ newPassword : trimInput ( newPassword ) ,
249+ confirmNewPassword : trimInput ( confirmNewPassword ) ,
250+ } ;
221251 notify . success ( 'Password updated' ) ;
222252 } }
223253 >
0 commit comments