forked from baron/baron-sso
chore: snapshot local state before dev merge
This commit is contained in:
@@ -86,12 +86,14 @@ import {
|
||||
import { generateSecurePassword } from "../../lib/utils";
|
||||
import {
|
||||
buildAuthenticatedOrgChartTenantPickerUrl,
|
||||
filterNonHanmacFamilyTenants,
|
||||
filterTenantsByMembershipRoot,
|
||||
getTenantGradeOptions,
|
||||
isHanmacFamilyTenant,
|
||||
isHanmacFamilyUser,
|
||||
type OrgChartTenantSelection,
|
||||
parseOrgChartTenantSelection,
|
||||
resolveUserMembershipTenantTab,
|
||||
USER_MEMBERSHIP_TENANT_TABS,
|
||||
type UserMembershipTenantTabId,
|
||||
} from "./orgChartPicker";
|
||||
import { formatUserPolicyMessage } from "./userPolicyMessages";
|
||||
import type { UserSchemaField } from "./userSchemaFields";
|
||||
@@ -109,7 +111,7 @@ type UserFormValues = Omit<UserUpdateRequest, "metadata"> & {
|
||||
sub_email?: string | string[];
|
||||
};
|
||||
};
|
||||
type UserCategory = "hanmac" | "external" | "personal";
|
||||
type UserCategory = UserMembershipTenantTabId;
|
||||
|
||||
type PasswordResetMode = "generated" | "manual";
|
||||
type PickerTarget = { kind: "appointment"; index: number };
|
||||
@@ -571,7 +573,7 @@ function UserDetailPage() {
|
||||
string | null
|
||||
>(null);
|
||||
const [userCategory, setUserCategory] =
|
||||
React.useState<UserCategory>("external");
|
||||
React.useState<UserCategory>("hanmac-family");
|
||||
const [additionalAppointments, setAdditionalAppointments] = React.useState<
|
||||
AppointmentDraft[]
|
||||
>([]);
|
||||
@@ -692,9 +694,18 @@ function UserDetailPage() {
|
||||
};
|
||||
|
||||
const resetMutation = useMutation({
|
||||
mutationFn: (newPass: string) => updateUser(userId, { password: newPass }),
|
||||
onSuccess: (_, newPass) => {
|
||||
setGeneratedPassword(newPass);
|
||||
mutationFn: ({ password }: { password: string; mode: PasswordResetMode }) =>
|
||||
updateUser(userId, { password }),
|
||||
onSuccess: (_, { password, mode }) => {
|
||||
if (mode === "manual") {
|
||||
setGeneratedPassword(null);
|
||||
setManualPassword("");
|
||||
setManualPasswordConfirm("");
|
||||
setIsManualPasswordVisible(false);
|
||||
setIsPasswordResetOpen(false);
|
||||
} else {
|
||||
setGeneratedPassword(password);
|
||||
}
|
||||
setPasswordResetError(null);
|
||||
toast.success(
|
||||
t(
|
||||
@@ -753,7 +764,7 @@ function UserDetailPage() {
|
||||
newPass = generateSecurePassword();
|
||||
}
|
||||
|
||||
resetMutation.mutate(newPass);
|
||||
resetMutation.mutate({ password: newPass, mode: passwordResetMode });
|
||||
};
|
||||
|
||||
const hanmacFamilyTenantId = React.useMemo(() => {
|
||||
@@ -771,7 +782,8 @@ function UserDetailPage() {
|
||||
const pickerUrl = buildAuthenticatedOrgChartTenantPickerUrl(
|
||||
import.meta.env.ORGFRONT_URL,
|
||||
{
|
||||
tenantId: userCategory === "hanmac" ? hanmacFamilyTenantId : undefined,
|
||||
tenantId:
|
||||
userCategory === "hanmac-family" ? hanmacFamilyTenantId : undefined,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -862,7 +874,7 @@ function UserDetailPage() {
|
||||
const handleUserCategoryChange = (value: string) => {
|
||||
const nextCategory = value as UserCategory;
|
||||
setUserCategory(nextCategory);
|
||||
if (nextCategory !== "hanmac") {
|
||||
if (nextCategory !== "hanmac-family") {
|
||||
setAdditionalAppointments([]);
|
||||
}
|
||||
};
|
||||
@@ -930,21 +942,11 @@ function UserDetailPage() {
|
||||
: [],
|
||||
} as UserFormValues["metadata"],
|
||||
});
|
||||
const isUserHanmacFamily = isHanmacFamilyUser(
|
||||
const resolvedUserCategory = resolveUserMembershipTenantTab(
|
||||
user,
|
||||
tenants,
|
||||
hanmacFamilyTenantId,
|
||||
);
|
||||
const isPersonalUser =
|
||||
user.tenantSlug === personalTenant.slug ||
|
||||
user.tenant?.id === personalTenant.id ||
|
||||
user.tenant?.slug === personalTenant.slug ||
|
||||
metadata.personalTenantId === personalTenant.id;
|
||||
const resolvedUserCategory = isPersonalUser
|
||||
? "personal"
|
||||
: isUserHanmacFamily
|
||||
? "hanmac"
|
||||
: "external";
|
||||
).id;
|
||||
const isUserHanmacFamily = resolvedUserCategory === "hanmac-family";
|
||||
setUserCategory(resolvedUserCategory);
|
||||
setGlobalCustomClaimRows(
|
||||
createGlobalCustomClaimRows(metadata, globalCustomClaimDefinitions),
|
||||
@@ -1009,7 +1011,6 @@ function UserDetailPage() {
|
||||
}, [
|
||||
globalCustomClaimDefinitions,
|
||||
hanmacFamilyTenantId,
|
||||
personalTenant,
|
||||
tenants,
|
||||
user,
|
||||
reset,
|
||||
@@ -1105,7 +1106,7 @@ function UserDetailPage() {
|
||||
}
|
||||
}
|
||||
|
||||
if (userCategory === "hanmac") {
|
||||
if (userCategory === "hanmac-family") {
|
||||
const appointments = additionalAppointments
|
||||
.filter((appointment) => appointment.tenantId)
|
||||
.map((appointment) => ({
|
||||
@@ -1217,9 +1218,13 @@ function UserDetailPage() {
|
||||
}, [tenants, user?.joinedTenants, user?.metadata, user?.tenant]);
|
||||
const selectableRepresentativeTenants = React.useMemo(
|
||||
() =>
|
||||
filterNonHanmacFamilyTenants(userAffiliatedTenants, hanmacFamilyTenantId),
|
||||
[userAffiliatedTenants, hanmacFamilyTenantId],
|
||||
userCategory === "hanmac-family" || userCategory === "personal"
|
||||
? []
|
||||
: filterTenantsByMembershipRoot(tenants, userCategory),
|
||||
[tenants, userCategory],
|
||||
);
|
||||
const isRepresentativeTenantCategory =
|
||||
userCategory !== "hanmac-family" && userCategory !== "personal";
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
@@ -1606,28 +1611,19 @@ function UserDetailPage() {
|
||||
className="space-y-4 pt-6 border-t border-dashed"
|
||||
>
|
||||
<TabsList className="flex h-auto w-full justify-start rounded-none border-b bg-transparent p-0 text-foreground">
|
||||
<TabsTrigger
|
||||
value="hanmac"
|
||||
className="-mb-px rounded-b-none rounded-t-md border border-transparent border-b-border bg-muted/40 px-4 py-2 text-muted-foreground shadow-none data-[state=active]:border-border data-[state=active]:border-b-background data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-none"
|
||||
>
|
||||
한맥가족 구성원
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
value="external"
|
||||
className="-mb-px rounded-b-none rounded-t-md border border-transparent border-b-border bg-muted/40 px-4 py-2 text-muted-foreground shadow-none data-[state=active]:border-border data-[state=active]:border-b-background data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-none"
|
||||
>
|
||||
외부 기업 회원
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
value="personal"
|
||||
className="-mb-px rounded-b-none rounded-t-md border border-transparent border-b-border bg-muted/40 px-4 py-2 text-muted-foreground shadow-none data-[state=active]:border-border data-[state=active]:border-b-background data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-none"
|
||||
>
|
||||
개인 회원
|
||||
</TabsTrigger>
|
||||
{USER_MEMBERSHIP_TENANT_TABS.map((tab) => (
|
||||
<TabsTrigger
|
||||
key={tab.id}
|
||||
value={tab.id}
|
||||
className="-mb-px rounded-b-none rounded-t-md border border-transparent border-b-border bg-muted/40 px-4 py-2 text-muted-foreground shadow-none data-[state=active]:border-border data-[state=active]:border-b-background data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-none"
|
||||
>
|
||||
{tab.label}
|
||||
</TabsTrigger>
|
||||
))}
|
||||
</TabsList>
|
||||
</Tabs>
|
||||
|
||||
{userCategory === "external" && (
|
||||
{isRepresentativeTenantCategory && (
|
||||
<div className="grid gap-8 md:grid-cols-2">
|
||||
<div className="space-y-2">
|
||||
<Label
|
||||
@@ -1671,7 +1667,7 @@ function UserDetailPage() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{userCategory === "hanmac" && (
|
||||
{userCategory === "hanmac-family" && (
|
||||
<div className="space-y-4 rounded-md border p-4">
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-3">
|
||||
@@ -1893,7 +1889,7 @@ function UserDetailPage() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{userCategory === "external" && (
|
||||
{isRepresentativeTenantCategory && (
|
||||
<div className="grid gap-6 md:grid-cols-3 pt-8 border-t">
|
||||
<div className="space-y-2">
|
||||
<Label
|
||||
|
||||
Reference in New Issue
Block a user