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:
Tiago Ribeiro
2024-08-29 15:18:55 +01:00
parent fdc8f98b21
commit b57e11bec4
3 changed files with 12 additions and 3 deletions

View File

@@ -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