-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae00ef4
commit 4f8bb44
Showing
18 changed files
with
1,170 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
apps/storefront/src/pages/accountSetting/AccountSetting.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { | ||
Box, | ||
Button, | ||
} from '@mui/material' | ||
|
||
import { | ||
useForm, | ||
} from 'react-hook-form' | ||
|
||
import { | ||
B3CustomForm, | ||
} from '@/components' | ||
|
||
import { | ||
useMobile, | ||
} from '@/hooks' | ||
|
||
// import { | ||
// snackbar, | ||
// } from '@/utils' | ||
|
||
import { | ||
getAccountSettingFiles, | ||
} from './config' | ||
|
||
const AccountSetting = () => { | ||
const { | ||
control, | ||
handleSubmit, | ||
getValues, | ||
formState: { | ||
errors, | ||
}, | ||
setValue, | ||
} = useForm({ | ||
mode: 'onSubmit', | ||
}) | ||
|
||
const [isMobile] = useMobile() | ||
|
||
const handleAddUserClick = () => { | ||
handleSubmit(async (data) => { | ||
console.log(data) | ||
})() | ||
} | ||
|
||
const xs = isMobile ? 12 : 6 | ||
|
||
const accountSettingFiles = getAccountSettingFiles(xs, true) | ||
return ( | ||
<Box> | ||
<B3CustomForm | ||
formFields={accountSettingFiles} | ||
errors={errors} | ||
control={control} | ||
getValues={getValues} | ||
setValue={setValue} | ||
/> | ||
|
||
<Button | ||
onClick={handleAddUserClick} | ||
variant="contained" | ||
> | ||
update details | ||
</Button> | ||
</Box> | ||
) | ||
} | ||
|
||
export default AccountSetting |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
interface ShippingListStatusProps { | ||
label: string | ||
value: number | ||
} | ||
|
||
export interface GetFilterMoreListProps { | ||
options?: Array<ShippingListStatusProps> | ||
rows?: string | number, | ||
name: string | ||
label: string | ||
required: boolean | ||
default: string | ||
fieldType: string | ||
xs: number | ||
variant: string | ||
size: string | ||
} | ||
|
||
export const getAccountSettingFiles = (xs: number, isB2BUser?: boolean): GetFilterMoreListProps[] => { | ||
const accountFormFields = [ | ||
{ | ||
name: 'firstName', | ||
label: 'First Name', | ||
required: true, | ||
default: '', | ||
fieldType: 'text', | ||
xs, | ||
variant: 'filled', | ||
size: 'small', | ||
}, | ||
{ | ||
name: 'lastName', | ||
label: 'Last Name', | ||
required: true, | ||
default: '', | ||
fieldType: 'text', | ||
xs, | ||
variant: 'filled', | ||
size: 'small', | ||
}, | ||
{ | ||
name: 'company', | ||
label: 'Company', | ||
required: false, | ||
default: '', | ||
fieldType: 'text', | ||
xs, | ||
variant: 'filled', | ||
size: 'small', | ||
}, | ||
{ | ||
name: 'phoneNumber', | ||
label: 'Phone Number', | ||
required: false, | ||
default: '', | ||
fieldType: 'text', | ||
xs, | ||
variant: 'filled', | ||
size: 'small', | ||
}, | ||
{ | ||
name: 'role', | ||
label: 'Role', | ||
required: false, | ||
default: '', | ||
fieldType: 'dropdown', | ||
options: [ | ||
{ | ||
label: 'Admin', | ||
value: 0, | ||
}, | ||
{ | ||
label: 'Senior buyer', | ||
value: 1, | ||
}, | ||
{ | ||
label: 'Junior buyer', | ||
value: 2, | ||
}, | ||
{ | ||
label: 'Super admin', | ||
value: 3, | ||
}, | ||
], | ||
xs, | ||
variant: 'filled', | ||
size: 'small', | ||
}, | ||
{ | ||
name: 'email', | ||
label: 'Email Address', | ||
required: true, | ||
default: '', | ||
fieldType: 'text', | ||
xs, | ||
variant: 'filled', | ||
size: 'small', | ||
}, | ||
{ | ||
name: 'currentPassword', | ||
label: 'Current Password', | ||
required: false, | ||
default: '', | ||
fieldType: 'password', | ||
xs, | ||
variant: 'filled', | ||
size: 'small', | ||
}, | ||
{ | ||
name: 'password', | ||
label: 'Password', | ||
required: false, | ||
default: '', | ||
fieldType: 'password', | ||
xs, | ||
variant: 'filled', | ||
size: 'small', | ||
}, | ||
{ | ||
name: 'confirmPassword', | ||
label: 'Confirm Password', | ||
required: false, | ||
default: '', | ||
fieldType: 'password', | ||
xs, | ||
variant: 'filled', | ||
size: 'small', | ||
}, | ||
] | ||
|
||
if (!isB2BUser) { | ||
return accountFormFields.filter((item:GetFilterMoreListProps) => item.name !== 'role') | ||
} | ||
return accountFormFields | ||
} |
Oops, something went wrong.