From 06ffe1ca0e02bc0c73af1ea07eda460ca1146548 Mon Sep 17 00:00:00 2001 From: Ianina Mia Passalia Date: Fri, 18 Oct 2024 16:19:25 -0300 Subject: [PATCH] Feat/imp/59/updating user by admin (#96) --- src/features/profile/actions/ProfileAction.ts | 11 ++- src/features/shared/actions/fetchUsers.ts | 77 +++++++++++++++-- src/features/shared/actions/supabaseTables.ts | 2 +- .../BtnFormCreateUpdate.tsx | 4 +- .../btnFormCreateUpdate.module.css | 2 +- src/features/users/actions/adminUserAction.ts | 23 +----- src/features/users/actions/usersAction.ts | 2 +- src/features/users/interfaces/IUpdateUser.ts | 15 ++++ .../users/interfaces/rolesResponse.ts | 5 ++ src/features/users/organisms/UsersList.tsx | 2 +- .../organisms/formCreate/FormCreateUser.tsx | 8 +- .../formCreate/formCreateUser.module.css | 11 +-- .../organisms/formUpdate/FormUpdateUser.tsx | 82 ++++++++++--------- .../formUpdate/formUpdateUser.module.css | 39 ++++----- .../createUser/CreateUserTemplate.tsx | 2 +- .../updateUser/UpdateUserTemplate.tsx | 9 +- .../updateUser/updateUserTemplate.module.css | 46 +++++------ src/features/users/validations/usersSchema.ts | 12 +++ 18 files changed, 220 insertions(+), 132 deletions(-) create mode 100644 src/features/users/interfaces/IUpdateUser.ts diff --git a/src/features/profile/actions/ProfileAction.ts b/src/features/profile/actions/ProfileAction.ts index 2142fef4..9f970f85 100644 --- a/src/features/profile/actions/ProfileAction.ts +++ b/src/features/profile/actions/ProfileAction.ts @@ -1,11 +1,10 @@ 'use server'; import { redirect, RedirectType } from 'next/navigation'; +import { updateRole } from '@/features/shared/actions/fetchUsers'; import { SupabaseTable } from '@/features/shared/actions/supabaseTables'; import { supabaseClientManager } from '@/lib/SupabaseClientManager'; -// import { ProfileType as IProfileType } from '@/features/profile/interfaces/profileResponse'; - export const getSession = async () => { const supabase = supabaseClientManager.getPublicClient(); @@ -26,20 +25,28 @@ type UpdatedUser = { first_name?: string; last_name?: string; phone?: number; + role?: string; + account_active?: boolean; }; export const updateUser = async (data: UpdatedUser, id: string) => { const supabase = supabaseClientManager.getPublicClient(); const phone = data.phone ? data.phone.toString() : null; + const { error } = await supabase .from(SupabaseTable.PROFILES) .update({ first_name: data.first_name, last_name: data.last_name, + account_active: data.account_active, phone, }) .eq('id', id); + if (data.role) { + await updateRole({ user_id: id, role_id: data.role }); + } + if (error) { throw new Error('Error updating the user'); } diff --git a/src/features/shared/actions/fetchUsers.ts b/src/features/shared/actions/fetchUsers.ts index 4f0d5fc1..18e18288 100644 --- a/src/features/shared/actions/fetchUsers.ts +++ b/src/features/shared/actions/fetchUsers.ts @@ -4,6 +4,7 @@ import { getSession } from '@/features/profile/actions/ProfileAction'; import { handleGetFile } from '@/features/shared/actions/fileAction'; import { SupabaseTable } from '@/features/shared/actions/supabaseTables'; import { filterSupabase, getCurrentUserRole } from '@/features/users/actions/usersAction'; +import { PayloadUpdateRole, RolesResponse } from '@/features/users/interfaces/rolesResponse'; import { supabaseClientManager } from '@/lib/SupabaseClientManager'; export interface User { @@ -13,7 +14,8 @@ export interface User { email: string | null; last_name: string | null; first_name: string | null; - role: string | null; + role: RolesResponse; + account_active: boolean; } export interface PaginatedResponse { @@ -44,12 +46,15 @@ type Props = { queryParams?: QueryParms; }; -export const fetchUser = async (): Promise => { +export const fetchUser = async (id?: string | undefined): Promise => { const supabase = supabaseClientManager.getPublicClient(); const user = await getSession(); - if (user && user.id) { - const { data, error } = await supabase.from(SupabaseTable.PROFILES).select().eq('id', user.id); + if (user && user.id && !id) { + const { data, error } = await supabase + .from(SupabaseTable.USER_HAS_ROLES) + .select('*, user_id!inner(*), role_id!inner(*)') + .eq('user_id', user.id); if (error) { throw new Error('Error at getting the user'); @@ -64,11 +69,38 @@ export const fetchUser = async (): Promise => { return { id: user.id, image_id: image, - phone: data[0]?.phone ?? null, - email: data[0]?.email ?? null, - last_name: data[0]?.last_name, - first_name: data[0]?.first_name, - role: 'operator', + phone: data[0]?.user_id.phone ?? null, + email: data[0]?.user_id.email ?? null, + last_name: data[0]?.user_id.last_name, + first_name: data[0]?.user_id.first_name, + account_active: data[0]?.user_id.account_active, + role: data[0]?.role_id, + }; + } else if (id) { + const { data, error } = await supabase + .from(SupabaseTable.USER_HAS_ROLES) + .select('*, user_id!inner(*), role_id!inner(*)') + .eq('user_id', id); + + if (error) { + throw new Error('Error at getting the user'); + } + + let image = data[0]?.image_id ?? null; + if (image) { + image = await handleGetFile(image); + image = image?.path; + } + + return { + id: id, + image_id: image, + phone: data[0]?.user_id.phone ?? null, + email: data[0]?.user_id.email ?? null, + last_name: data[0]?.user_id.last_name, + first_name: data[0]?.user_id.first_name, + account_active: data[0]?.user_id.account_active, + role: data[0].role_id, }; } else { throw new Error('User not found'); @@ -130,6 +162,7 @@ export const fetchUsers = async (props?: Props): Promise => { email: user.user_id.email, last_name: user.user_id.last_name, first_name: user.user_id.first_name, + account_active: user.user_id.account_active, role: user.role_id.name, })) : []; @@ -156,3 +189,29 @@ export const fetchUsers = async (props?: Props): Promise => { return paginationResponse; }; + +export const getRoles = async () => { + const supabase = supabaseClientManager.getPrivateClient(); + + const { data, error } = await supabase.from('roles').select(); + if (error) { + throw new Error('Error getting the roles'); + } else { + return data; + } +}; + +export const updateRole = async ({ user_id, role_id }: PayloadUpdateRole) => { + const supabase = supabaseClientManager.getPrivateClient(); + + const { error: RolUpdateError } = await supabase + .from(SupabaseTable.USER_HAS_ROLES) + .update({ + role_id, + }) + .eq('user_id', user_id); + + if (RolUpdateError) { + throw new Error('Error updating the role of the user'); + } +}; diff --git a/src/features/shared/actions/supabaseTables.ts b/src/features/shared/actions/supabaseTables.ts index 93154b0f..47309387 100644 --- a/src/features/shared/actions/supabaseTables.ts +++ b/src/features/shared/actions/supabaseTables.ts @@ -1,6 +1,6 @@ export enum SupabaseTable { ROLES = 'roles', ROLES_HAS_PERMISSIONS = 'roles_has_permissions', - USER_HAS_ROLES = 'user_has_roles', + USER_HAS_ROLES = 'users_has_roles', PROFILES = 'profiles', } diff --git a/src/features/shared/molecules/btnFormCreateUpdate/BtnFormCreateUpdate.tsx b/src/features/shared/molecules/btnFormCreateUpdate/BtnFormCreateUpdate.tsx index f0ada3ce..7afe54ce 100644 --- a/src/features/shared/molecules/btnFormCreateUpdate/BtnFormCreateUpdate.tsx +++ b/src/features/shared/molecules/btnFormCreateUpdate/BtnFormCreateUpdate.tsx @@ -6,7 +6,7 @@ import style from '@/features/shared/molecules/btnFormCreateUpdate/btnFormCreate interface Props { linkCancel: string; textCancel: string; - disabledButton: boolean; + disabledButton?: boolean; textSubmit: string; } @@ -21,7 +21,7 @@ export const BtnFormCreateUpdate = ({ linkCancel, textCancel, disabledButton, te
-
diff --git a/src/features/shared/molecules/btnFormCreateUpdate/btnFormCreateUpdate.module.css b/src/features/shared/molecules/btnFormCreateUpdate/btnFormCreateUpdate.module.css index 0873b10c..af92c5f5 100644 --- a/src/features/shared/molecules/btnFormCreateUpdate/btnFormCreateUpdate.module.css +++ b/src/features/shared/molecules/btnFormCreateUpdate/btnFormCreateUpdate.module.css @@ -2,7 +2,7 @@ @apply p-2; } .containerBtn { - @apply flex justify-center mt-5; + @apply mt-5 flex justify-center; } .containerBtn button { @apply w-[120px] transform transition-all duration-500 active:scale-[98%]; diff --git a/src/features/users/actions/adminUserAction.ts b/src/features/users/actions/adminUserAction.ts index 6f3aa942..f68a7a92 100644 --- a/src/features/users/actions/adminUserAction.ts +++ b/src/features/users/actions/adminUserAction.ts @@ -1,5 +1,6 @@ 'use server'; +import { updateRole } from '@/features/shared/actions/fetchUsers'; import { getCurrentUserRole } from '@/features/users/actions/usersAction'; import { supabaseClientManager } from '@/lib/SupabaseClientManager'; @@ -13,17 +14,6 @@ type NewUserByAdmin = { account_active: boolean; }; -export const getRoles = async () => { - const supabase = supabaseClientManager.getPrivateClient(); - - const { data, error } = await supabase.from('roles').select(); - if (error) { - throw new Error('Error getting the roles'); - } else { - return data; - } -}; - export const addNewUserByAdmin = async (props: NewUserByAdmin) => { const supabase = supabaseClientManager.getPrivateClient(); @@ -48,16 +38,7 @@ export const addNewUserByAdmin = async (props: NewUserByAdmin) => { throw new Error('Error creating a new user'); } - const { error: RolUpdateError } = await supabase - .from('users_has_roles') - .update({ - role_id: props.role, - }) - .eq('user_id', user?.id); - - if (RolUpdateError) { - throw new Error('Error updating the role of the user'); - } + await updateRole({ user_id: user?.id, role_id: props.role }); if (!props.account_active) { const { error: SendError } = await supabase.auth.resend({ diff --git a/src/features/users/actions/usersAction.ts b/src/features/users/actions/usersAction.ts index da08a3a7..f3563090 100644 --- a/src/features/users/actions/usersAction.ts +++ b/src/features/users/actions/usersAction.ts @@ -24,7 +24,7 @@ export const getCurrentUserRole = async () => { if (data) { return data; } else { - throw new Error('Error at getting the current user'); + throw new Error('Error at getting the current user role'); } }; diff --git a/src/features/users/interfaces/IUpdateUser.ts b/src/features/users/interfaces/IUpdateUser.ts new file mode 100644 index 00000000..db347ce8 --- /dev/null +++ b/src/features/users/interfaces/IUpdateUser.ts @@ -0,0 +1,15 @@ +export type User = { + first_name: string; + last_name: string; + phone?: number; + email: string; + role: string; + account_active: boolean; +}; + +export type IUpdateUser = User & { + role: string; + account_active: boolean; +}; + +export interface UserUpdatePayload extends User {} diff --git a/src/features/users/interfaces/rolesResponse.ts b/src/features/users/interfaces/rolesResponse.ts index 693b9418..63962ee9 100644 --- a/src/features/users/interfaces/rolesResponse.ts +++ b/src/features/users/interfaces/rolesResponse.ts @@ -9,3 +9,8 @@ export type Roles = { }; export interface RolesPayload extends Roles {} + +export interface PayloadUpdateRole { + user_id: string | undefined; + role_id: string; +} diff --git a/src/features/users/organisms/UsersList.tsx b/src/features/users/organisms/UsersList.tsx index 2bbc26af..0ec35e81 100644 --- a/src/features/users/organisms/UsersList.tsx +++ b/src/features/users/organisms/UsersList.tsx @@ -159,7 +159,7 @@ export const UserList = (props: Props) => {
{user.first_name ?

{user.first_name}

: <>}

Email: {user.email}

-

Role: {user.role}

+

Role: {user.role.name}

} /> diff --git a/src/features/users/organisms/formCreate/FormCreateUser.tsx b/src/features/users/organisms/formCreate/FormCreateUser.tsx index 189751fb..03afba3a 100644 --- a/src/features/users/organisms/formCreate/FormCreateUser.tsx +++ b/src/features/users/organisms/formCreate/FormCreateUser.tsx @@ -12,13 +12,17 @@ import { addNewUserByAdmin } from '@/features/users/actions/adminUserAction'; import { activeOptions } from '@/features/users/constants/selectOptionsData'; import { transformToInputOptions } from '@/features/users/helpers/transformToInputOptions'; import { ICreateUser } from '@/features/users/interfaces/ICreateUser'; -import { Roles } from '@/features/users/interfaces/rolesResponse'; +import { RolesResponse } from '@/features/users/interfaces/rolesResponse'; import { UserPayload } from '@/features/users/interfaces/usersResponse'; import { createUserSchema } from '@/features/users/validations/usersSchema'; import style from './formCreateUser.module.css'; -export const FormCreate = ({ roles }: Roles) => { +type Props = { + roles: RolesResponse[]; +}; + +export const FormCreate = ({ roles }: Props) => { const { register, handleSubmit, diff --git a/src/features/users/organisms/formCreate/formCreateUser.module.css b/src/features/users/organisms/formCreate/formCreateUser.module.css index 4fd5c2a2..f09c1d63 100644 --- a/src/features/users/organisms/formCreate/formCreateUser.module.css +++ b/src/features/users/organisms/formCreate/formCreateUser.module.css @@ -4,11 +4,12 @@ .inputBlock { @apply p-2; } -.inputBlock input, .inputBlock select { +.inputBlock input, +.inputBlock select { @apply mt-1 h-12 w-full rounded-lg border-2 border-borderInput bg-bgInputFilter px-2 text-[#292D32] shadow-[0_2px_2px_0px_rgba(0,0,0,0.05)] outline-none; } -.inputBlock select{ - @apply cursor-pointer +.inputBlock select { + @apply cursor-pointer; } .inputBlock label { @apply text-[0.8rem] font-normal text-white; @@ -19,8 +20,8 @@ .inputBlock p { @apply border-none pl-2 pt-1 text-[12px] text-warning; } -.inputBlock input[type=number]::-webkit-inner-spin-button, -.inputBlock input[type=number]::-webkit-outer-spin-button { +.inputBlock input[type='number']::-webkit-inner-spin-button, +.inputBlock input[type='number']::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; } diff --git a/src/features/users/organisms/formUpdate/FormUpdateUser.tsx b/src/features/users/organisms/formUpdate/FormUpdateUser.tsx index 30ce5737..81e2e805 100644 --- a/src/features/users/organisms/formUpdate/FormUpdateUser.tsx +++ b/src/features/users/organisms/formUpdate/FormUpdateUser.tsx @@ -5,53 +5,54 @@ import { useTranslations } from 'next-intl'; import { useForm } from 'react-hook-form'; import { toast } from 'react-toastify'; +import { updateUser } from '@/features/profile/actions/ProfileAction'; +import { User } from '@/features/shared/actions/fetchUsers'; import { InputForm, InputType } from '@/features/shared/atoms/inputForm/InputForm'; import { BtnFormCreateUpdate } from '@/features/shared/molecules/btnFormCreateUpdate/BtnFormCreateUpdate'; -import { activeOptions, rolesOptions } from '@/features/users/constants/selectOptionsData'; -import { ICreateUser } from '@/features/users/interfaces/ICreateUser'; -import { UserPayload } from '@/features/users/interfaces/usersResponse'; +import { activeOptions } from '@/features/users/constants/selectOptionsData'; +import { transformToInputOptions } from '@/features/users/helpers/transformToInputOptions'; +import { IUpdateUser, UserUpdatePayload } from '@/features/users/interfaces/IUpdateUser'; +import { RolesResponse } from '@/features/users/interfaces/rolesResponse'; import style from '@/features/users/organisms/formUpdate/formUpdateUser.module.css'; -import { createUserSchema } from '@/features/users/validations/usersSchema'; +import { updateUserSchema } from '@/features/users/validations/usersSchema'; type Props = { id: string; - data: { - role: string; - active: boolean; - name: string; - lastName: string; - phone: number; - email: string; - }; + data: User; + roles: RolesResponse[]; }; -export const FormUpdateUser = ({ id, data }: Props) => { + +export const FormUpdateUser = ({ id, data, roles }: Props) => { const { register, handleSubmit, formState: { errors }, - } = useForm({ + } = useForm({ defaultValues: { - role: data.role, - active: data.active, - name: data.name, - lastName: data.lastName, - phone: data.phone, - email: data.email, + role: data.role.id, + account_active: data.account_active, + first_name: data.first_name ?? undefined, + last_name: data.last_name ?? undefined, + phone: Number(data.phone) ?? undefined, + email: data.email ?? undefined, }, - resolver: yupResolver(createUserSchema), + resolver: yupResolver(updateUserSchema), }); + const alert = useTranslations('ToastUpdate'); const t = useTranslations('UserList'); const s = useTranslations('Shared'); - // TODO: acá falta cambiar el updateItem y descomentar - const updateAction = async (data: UserPayload) => { - await toast.promise(updateItem({ id, data }), { - error: `${alert('error')}`, - success: `${alert('success')}`, - pending: `${alert('pending')}`, + const rolesTransformed = transformToInputOptions(roles); + + const updateAction = async (data: UserUpdatePayload) => { + await toast.promise(updateUser(data, id), { + error: `${alert('error')}`, + success: `${alert('success')}`, + pending: `${alert('pending')}`, }); }; + return (
{ })} >
- + type={'text'} name={'role'} label={t('role')} @@ -70,43 +71,43 @@ export const FormUpdateUser = ({ id, data }: Props) => { className={style.inputBlock} input_type={InputType.SELECT} classNameError={style.inputError} - options={rolesOptions} + options={rolesTransformed} /> - + type={'text'} - name={'active'} + name={'account_active'} label={t('active')} register={register} errors={errors} - id={'active'} + id={'account_active'} className={style.inputBlock} input_type={InputType.SELECT} classNameError={style.inputError} options={activeOptions} /> - + type={'text'} - name={'name'} + name={'first_name'} label={t('name')} register={register} errors={errors} - id={'name'} + id={'first_name'} className={style.inputBlock} input_type={InputType.SIMPLE} classNameError={style.inputError} /> - + type={'text'} - name={'lastName'} + name={'last_name'} label={t('lastName')} register={register} errors={errors} - id={'lastName'} + id={'last_name'} className={style.inputBlock} input_type={InputType.SIMPLE} classNameError={style.inputError} /> - + type={'number'} name={'phone'} label={t('phone')} @@ -117,13 +118,14 @@ export const FormUpdateUser = ({ id, data }: Props) => { input_type={InputType.SIMPLE} classNameError={style.inputError} /> - + type={'email'} name={'email'} label={t('email')} register={register} errors={errors} id={'email'} + disabled={true} className={style.inputBlock} input_type={InputType.SIMPLE} classNameError={style.inputError} diff --git a/src/features/users/organisms/formUpdate/formUpdateUser.module.css b/src/features/users/organisms/formUpdate/formUpdateUser.module.css index 1e101ab7..6c7c80e4 100644 --- a/src/features/users/organisms/formUpdate/formUpdateUser.module.css +++ b/src/features/users/organisms/formUpdate/formUpdateUser.module.css @@ -1,37 +1,38 @@ .form { - @apply flex min-h-[350px] flex-col justify-between; + @apply flex min-h-[350px] flex-col justify-between; } .inputBlock { - @apply p-2; + @apply p-2; } -.inputBlock input, .inputBlock select { - @apply mt-1 h-12 w-full rounded-lg border-2 border-borderInput bg-bgInputFilter px-2 text-[#292D32] shadow-[0_2px_2px_0px_rgba(0,0,0,0.05)] outline-none; +.inputBlock input, +.inputBlock select { + @apply mt-1 h-12 w-full rounded-lg border-2 border-borderInput bg-bgInputFilter px-2 text-[#292D32] shadow-[0_2px_2px_0px_rgba(0,0,0,0.05)] outline-none; } -.inputBlock select{ - @apply cursor-pointer +.inputBlock select { + @apply cursor-pointer; } .inputBlock p { - @apply border-none pt-1 text-[0.7rem] text-warning; + @apply border-none pt-1 text-[0.7rem] text-warning; } .inputBlock label { - @apply text-[0.8rem] font-normal text-white; + @apply text-[0.8rem] font-normal text-white; } .inputError { - @apply border-2 border-solid !border-[#FE3F3F80]; + @apply border-2 border-solid !border-[#FE3F3F80]; } -.inputBlock input[type=number]::-webkit-inner-spin-button, -.inputBlock input[type=number]::-webkit-outer-spin-button { - -webkit-appearance: none; - margin: 0; +.inputBlock input[type='number']::-webkit-inner-spin-button, +.inputBlock input[type='number']::-webkit-outer-spin-button { + -webkit-appearance: none; + margin: 0; } @screen md { - .containerBtn button { - @apply w-[150px]; - } + .containerBtn button { + @apply w-[150px]; + } } @screen lg { - .form { - @apply min-h-[500px]; - } + .form { + @apply min-h-[500px]; + } } diff --git a/src/features/users/template/createUser/CreateUserTemplate.tsx b/src/features/users/template/createUser/CreateUserTemplate.tsx index 36af5def..08e405cf 100644 --- a/src/features/users/template/createUser/CreateUserTemplate.tsx +++ b/src/features/users/template/createUser/CreateUserTemplate.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import { getRoles } from '@/features/users/actions/adminUserAction'; +import { getRoles } from '@/features/shared/actions/fetchUsers'; import { SubTitle } from '@/features/users/atoms/subtitle/Subtitle'; import { RolesResponse } from '@/features/users/interfaces/rolesResponse'; import { FormCreate } from '@/features/users/organisms/formCreate/FormCreateUser'; diff --git a/src/features/users/template/updateUser/UpdateUserTemplate.tsx b/src/features/users/template/updateUser/UpdateUserTemplate.tsx index 5426a729..6af47d80 100644 --- a/src/features/users/template/updateUser/UpdateUserTemplate.tsx +++ b/src/features/users/template/updateUser/UpdateUserTemplate.tsx @@ -1,9 +1,10 @@ import React from 'react'; import { getTranslations } from 'next-intl/server'; -import { getOne } from '@/features/items/actions/ItemAction'; +import { fetchUser, getRoles } from '@/features/shared/actions/fetchUsers'; import { icons } from '@/features/shared/hooks/icons'; +import { RolesResponse } from '@/features/users/interfaces/rolesResponse'; import { FormUpdateUser } from '@/features/users/organisms/formUpdate/FormUpdateUser'; import style from './updateUserTemplate.module.css'; @@ -12,8 +13,8 @@ type Props = { id: string; }; export const UpdateUserTemplate = async ({ id }: Props) => { - // TODO: hay que cambiar el getOne - const data = await getOne({ id }); + const data = await fetchUser(id); + const roles = await getRoles(); const t = await getTranslations('Update'); const { IoCreateOutline } = icons(); @@ -24,7 +25,7 @@ export const UpdateUserTemplate = async ({ id }: Props) => {

{t('titleUser')}

- + ); diff --git a/src/features/users/template/updateUser/updateUserTemplate.module.css b/src/features/users/template/updateUser/updateUserTemplate.module.css index 21b21be4..2ab8ea6e 100644 --- a/src/features/users/template/updateUser/updateUserTemplate.module.css +++ b/src/features/users/template/updateUser/updateUserTemplate.module.css @@ -1,43 +1,43 @@ .container { - @apply flex h-screen items-center justify-center; + @apply flex h-screen items-center justify-center; } .subContainer { - @apply min-h-[400px] rounded-2xl bg-modal p-4 shadow-[0_4px_4px_0px_rgba(0,0,0,0.25)]; + @apply min-h-[400px] rounded-2xl bg-modal p-4 shadow-[0_4px_4px_0px_rgba(0,0,0,0.25)]; } .subTitle { - @apply flex items-center justify-center gap-3; + @apply flex items-center justify-center gap-3; } .subTitle h2 { - @apply text-[1.5rem] font-normal text-white; + @apply text-[1.5rem] font-normal text-white; } .subTitle svg { - @apply h-[36px] w-[36px] text-secondary; + @apply h-[36px] w-[36px] text-secondary; } @screen md { - .subContainer { - @apply w-[500px] p-[2rem]; - } - .subTitle svg { - @apply h-[40px] w-[40px]; - } + .subContainer { + @apply w-[500px] p-[2rem]; + } + .subTitle svg { + @apply h-[40px] w-[40px]; + } } @screen lg { - .subContainer { - @apply min-h-[600px]; - } + .subContainer { + @apply min-h-[600px]; + } } @screen xl { - .subContainer { - @apply max-w-[600px]; - } + .subContainer { + @apply max-w-[600px]; + } } @screen 2xl { - .subTitle { - @apply text-[26px] !important; - } - .subContainer { - @apply w-[600px]; - } + .subTitle { + @apply text-[26px] !important; + } + .subContainer { + @apply w-[600px]; + } } diff --git a/src/features/users/validations/usersSchema.ts b/src/features/users/validations/usersSchema.ts index 3556b9a6..d0ba0afa 100644 --- a/src/features/users/validations/usersSchema.ts +++ b/src/features/users/validations/usersSchema.ts @@ -26,3 +26,15 @@ export const createUserSchema = yup account_active: yup.boolean().required('*Active user is a required field'), }) .required(); + +export const updateUserSchema = yup + .object() + .shape({ + first_name: yup.string().min(3).required('*User name is a required field'), + last_name: yup.string().min(3).required('*Lastname is a required field'), + phone: yup.number(), + email: yup.string().email('Enter a valid email address').required('*Email is a required field'), + role: yup.string().min(3).required('*Role is a required field'), + account_active: yup.boolean().required('*Active user is a required field'), + }) + .required();