refactor settings page
This commit is contained in:
1 parent
05f265743b
commit
08bd2d56f3
3 files changed
+606
-767
No files matched your search
@@ -18,7 +18,10 @@ interface FormAutocompleteProps<T extends FieldValues, O extends AutocompleteOpt
|
|||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const FormAutocomplete = <T extends FieldValues, O extends AutocompleteOption>({
|
export const FormAutocompleteField = <
|
||||||
|
T extends FieldValues,
|
||||||
|
O extends AutocompleteOption,
|
||||||
|
>({
|
||||||
name,
|
name,
|
||||||
options,
|
options,
|
||||||
fieldLabel,
|
fieldLabel,
|
||||||
|
|||||||
@@ -13,11 +13,13 @@ import { SPACING } from "@/Utils/Theme/constants";
|
|||||||
interface FormSwitchProps<T extends FieldValues> {
|
interface FormSwitchProps<T extends FieldValues> {
|
||||||
name: FieldPath<T>;
|
name: FieldPath<T>;
|
||||||
label: string;
|
label: string;
|
||||||
|
labelPlacement?: "start" | "end"; // left | right
|
||||||
}
|
}
|
||||||
|
|
||||||
export const FormSwitchField = <T extends FieldValues>({
|
export const FormSwitchField = <T extends FieldValues>({
|
||||||
name,
|
name,
|
||||||
label,
|
label,
|
||||||
|
labelPlacement = "end",
|
||||||
}: FormSwitchProps<T>) => {
|
}: FormSwitchProps<T>) => {
|
||||||
const { control } = useFormContext<T>();
|
const { control } = useFormContext<T>();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -29,14 +31,27 @@ export const FormSwitchField = <T extends FieldValues>({
|
|||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
alignItems={"center"}
|
alignItems="center"
|
||||||
spacing={theme.spacing(SPACING.LG)}
|
spacing={labelPlacement === "start" ? undefined : theme.spacing(SPACING.LG)}
|
||||||
|
justifyContent={labelPlacement === "start" ? "space-between" : undefined}
|
||||||
>
|
>
|
||||||
<SwitchComponent
|
{labelPlacement === "start" ? (
|
||||||
checked={field.value ?? false}
|
<>
|
||||||
onChange={(e) => field.onChange(e.target.checked)}
|
<Typography>{label}</Typography>
|
||||||
/>
|
<SwitchComponent
|
||||||
<Typography>{label}</Typography>
|
checked={field.value ?? false}
|
||||||
|
onChange={(e) => field.onChange(e.target.checked)}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<SwitchComponent
|
||||||
|
checked={field.value ?? false}
|
||||||
|
onChange={(e) => field.onChange(e.target.checked)}
|
||||||
|
/>
|
||||||
|
<Typography>{label}</Typography>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
+580
-759
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user