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