ENCOA-129: When Creating a Single user Corporate OR Master Corporate it should have the field Department to be configured
This commit is contained in:
@@ -72,6 +72,7 @@ export default function UserCreator({user, onFinish}: {user: User; onFinish: ()
|
||||
const [isExpiryDateEnabled, setIsExpiryDateEnabled] = useState(true);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [type, setType] = useState<Type>("student");
|
||||
const [position, setPosition] = useState<string>();
|
||||
|
||||
const {permissions} = usePermissions(user?.id || "");
|
||||
const {groups} = useGroups({admin: ["developer", "admin"].includes(user?.type) ? undefined : user?.id, userType: user?.type});
|
||||
@@ -112,6 +113,7 @@ export default function UserCreator({user, onFinish}: {user: User; onFinish: ()
|
||||
passport_id: type === "student" ? passportID : undefined,
|
||||
phone,
|
||||
country,
|
||||
position,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -132,6 +134,7 @@ export default function UserCreator({user, onFinish}: {user: User; onFinish: ()
|
||||
setExpiryDate(user?.subscriptionExpirationDate ? moment(user?.subscriptionExpirationDate).toDate() : null);
|
||||
setIsExpiryDateEnabled(true);
|
||||
setType("student");
|
||||
setPosition(undefined);
|
||||
})
|
||||
.catch(() => toast.error("Something went wrong! Please try again later!"))
|
||||
.finally(() => setIsLoading(false));
|
||||
@@ -187,10 +190,16 @@ export default function UserCreator({user, onFinish}: {user: User; onFinish: ()
|
||||
</div>
|
||||
)}
|
||||
|
||||
{["corporate", "mastercorporate"].includes(type) && (
|
||||
<Input type="text" name="department" label="Department" onChange={setPosition} value={position} placeholder="Department" />
|
||||
)}
|
||||
|
||||
<div
|
||||
className={clsx(
|
||||
"flex flex-col gap-4",
|
||||
(!["student", "teacher"].includes(type) || ["corporate", "teacher"].includes(user?.type)) && "col-span-2",
|
||||
(!["student", "teacher"].includes(type) || ["corporate", "teacher"].includes(user?.type)) &&
|
||||
!["corporate", "mastercorporate"].includes(type) &&
|
||||
"col-span-2",
|
||||
)}>
|
||||
<label className="font-normal text-base text-mti-gray-dim">Group</label>
|
||||
<Select
|
||||
|
||||
@@ -54,7 +54,7 @@ export const getServerSideProps = withIronSessionSsr(async ({req, res}) => {
|
||||
};
|
||||
}
|
||||
|
||||
const linkedCorporate = await getUserCorporate(user.id);
|
||||
const linkedCorporate = (await getUserCorporate(user.id)) || null;
|
||||
|
||||
return {
|
||||
props: {user, envVariables, linkedCorporate},
|
||||
|
||||
@@ -59,7 +59,7 @@ export const getServerSideProps = withIronSessionSsr(async ({req, res}) => {
|
||||
}
|
||||
|
||||
return {
|
||||
props: {user, linkedCorporate: await getUserCorporate(user.id)},
|
||||
props: {user, linkedCorporate: (await getUserCorporate(user.id)) || null},
|
||||
};
|
||||
}, sessionOptions);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user