Add teams to a user when they are created

This commit is contained in:
Alex Holliday committed 2024-08-26 13:29:11 -07:00
1 parent a6f5c96f93
commit c39eab49bd
8 files changed
+26 -8

No files matched your search

+6 -2
View File
@@ -25,7 +25,11 @@ const Account = ({ open = "profile" }) => {
let tabList = ["Profile", "Password", "Team"];
const { user } = useSelector((state) => state.auth);
if (!user.role.includes("admin")) tabList = ["Profile", "Password"];
const requiredRoles = ["superadmin", "admin"];
const hideTeams = !requiredRoles.some((role) => user.role.includes(role));
if (hideTeams) {
tabList = ["Profile", "Password"];
}
return (
<Box
@@ -71,7 +75,7 @@ const Account = ({ open = "profile" }) => {
</Box>
<ProfilePanel />
<PasswordPanel />
{user.role.includes("admin") && <TeamPanel />}
{!hideTeams && <TeamPanel />}
</TabContext>
</Box>
);
+5 -4
View File
@@ -444,24 +444,26 @@ const Register = ({ isSuperAdmin }) => {
password: "",
confirm: "",
role: [],
teamId: "",
});
const [errors, setErrors] = useState({});
const [step, setStep] = useState(0);
useEffect(() => {
const fetchInvite = async () => {
console.log("FETCHING");
if (token !== undefined) {
try {
const res = await networkService.verifyInvitationToken(token);
const { role, email } = res.data.data;
setForm({ ...form, email, role });
const { role, email, teamId } = res.data.data;
setForm({ ...form, email, role, teamId });
} catch (error) {
logger.error(error);
}
}
};
fetchInvite();
}, [token, form]);
}, []);
/**
* Validates the form data against the validation schema.
@@ -494,7 +496,6 @@ const Register = ({ isSuperAdmin }) => {
const handleStepOne = async (e) => {
e.preventDefault();
let error = validateForm({
firstName: form.firstName,
lastName: form.lastName,
+1
View File
@@ -76,6 +76,7 @@ const credentials = joi.object({
return value;
}),
role: joi.array(),
teamId: joi.string().allow("").optional(),
});
const monitorValidation = joi.object({