diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 67fe943d..82c5a6ee 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -145,8 +145,10 @@ export default function Navbar({user, path, navDisabled = false, focusMode = fal {user.name} - {user.type === "corporate" ? `${user.corporateInformation?.companyInformation.name} |` : ""} {user.name} |{" "} - {USER_TYPE_LABELS[user.type]} + {(user.type === "corporate" || user.type === "mastercorporate") && !!user.corporateInformation?.companyInformation?.name + ? `${user.corporateInformation?.companyInformation.name} |` + : ""}{" "} + {user.name} | {USER_TYPE_LABELS[user.type]} {user.type === "corporate" && !!user.demographicInformation?.position && ` | ${user.demographicInformation?.position || "N/A"}`} diff --git a/src/pages/api/make_user.ts b/src/pages/api/make_user.ts index 02efef10..3c9223e9 100644 --- a/src/pages/api/make_user.ts +++ b/src/pages/api/make_user.ts @@ -67,12 +67,22 @@ async function post(req: NextApiRequest, res: NextApiResponse) { focus: "academic", status: "active", desiredLevels: DEFAULT_DESIRED_LEVELS, - profilePicture: "/defaultAvatar.png", + profilePicture: maker.type === "corporate" || maker.type === "mastercorporate" ? maker.profilePicture : "/defaultAvatar.png", levels: DEFAULT_LEVELS, isFirstLogin: false, isVerified: true, registrationDate: new Date(), subscriptionExpirationDate: expiryDate || null, + ...(maker.type === "mastercorporate" && type === "corporate" + ? { + corporateInformation: { + companyInformation: { + name: maker.corporateInformation?.companyInformation?.name || "N/A", + userAmount: 0, + }, + }, + } + : {}), }; const uid = new ShortUniqueId(); diff --git a/src/pages/profile.tsx b/src/pages/profile.tsx index a6bef9f2..6ed40394 100644 --- a/src/pages/profile.tsx +++ b/src/pages/profile.tsx @@ -97,9 +97,7 @@ function UserProfile({user, mutateUser, linkedCorporate, groups, users}: Props) const [isLoading, setIsLoading] = useState(false); const [profilePicture, setProfilePicture] = useState(user.profilePicture); - const [desiredLevels, setDesiredLevels] = useState<{[key in Module]: number} | undefined>( - checkAccess(user, ["developer", "student"]) ? user.desiredLevels : undefined, - ); + const [desiredLevels, setDesiredLevels] = useState(checkAccess(user, ["developer", "student"]) ? user.desiredLevels : undefined); const [focus, setFocus] = useState<"academic" | "general">(user.focus); const [country, setCountry] = useState(user.demographicInformation?.country || ""); @@ -119,16 +117,17 @@ function UserProfile({user, mutateUser, linkedCorporate, groups, users}: Props) user.type === "student" || user.type === "developer" ? user.preferredTopics : undefined, ); - const [position, setPosition] = useState(user.type === "corporate" ? user.demographicInformation?.position : undefined); - const [corporateInformation, setCorporateInformation] = useState(user.type === "corporate" ? user.corporateInformation : undefined); - const [companyName, setCompanyName] = useState(user.type === "agent" ? user.agentInformation?.companyName : undefined); - const [commercialRegistration, setCommercialRegistration] = useState( - user.type === "agent" ? user.agentInformation?.commercialRegistration : undefined, + const [position, setPosition] = useState( + user.type === "corporate" || user.type === "mastercorporate" ? user.demographicInformation?.position : undefined, ); + const [corporateInformation, setCorporateInformation] = useState( + user.type === "corporate" || user.type === "mastercorporate" ? user.corporateInformation : undefined, + ); + + const [companyName] = useState(user.type === "agent" ? user.agentInformation?.companyName : undefined); + const [commercialRegistration] = useState(user.type === "agent" ? user.agentInformation?.commercialRegistration : undefined); const [arabName, setArabName] = useState(user.type === "agent" ? user.agentInformation?.companyArabName : undefined); - const [timezone, setTimezone] = useState(user.demographicInformation?.timezone || moment.tz.guess()); - const [isPreferredTopicsOpen, setIsPreferredTopicsOpen] = useState(false); const profilePictureInput = useRef(null); @@ -288,7 +287,7 @@ function UserProfile({user, mutateUser, linkedCorporate, groups, users}: Props) })) } placeholder="Enter your company's name" - defaultValue={corporateInformation?.companyInformation.name} + defaultValue={corporateInformation?.companyInformation?.name} required /> )}