1
0
forked from baron/baron-sso

refactor(adminfront): replace sonner with custom use-toast matching devfront UX policy

This commit is contained in:
2026-03-23 15:32:32 +09:00
parent d0e4f8f86a
commit d608bdb5a8
18 changed files with 121 additions and 34 deletions

View File

@@ -2,7 +2,7 @@ import { useMutation } from "@tanstack/react-query";
import type { AxiosError } from "axios";
import { Download, FileText, Loader2, Upload } from "lucide-react";
import * as React from "react";
import { toast } from "sonner";
import { toast } from "../../../components/ui/use-toast";
import { Button } from "../../../components/ui/button";
import {
Dialog,

View File

@@ -12,7 +12,7 @@ import {
import { useState } from "react";
import { useAuth } from "react-oidc-context";
import { useParams } from "react-router-dom";
import { toast } from "sonner";
import { toast } from "../../../components/ui/use-toast";
import { Badge } from "../../../components/ui/badge";
import { Button } from "../../../components/ui/button";
import {

View File

@@ -18,7 +18,7 @@ import {
import type React from "react";
import { useState } from "react";
import { useParams } from "react-router-dom";
import { toast } from "sonner";
import { toast } from "../../../components/ui/use-toast";
import { Badge } from "../../../components/ui/badge";
import { Button } from "../../../components/ui/button";
import {

View File

@@ -3,7 +3,7 @@ import type { AxiosError } from "axios";
import { Save, Trash2 } from "lucide-react";
import { useEffect, useState } from "react";
import { useNavigate, useParams } from "react-router-dom";
import { toast } from "sonner";
import { toast } from "../../../components/ui/use-toast";
import { Button } from "../../../components/ui/button";
import {
Card,

View File

@@ -3,7 +3,7 @@ import type { AxiosError } from "axios";
import { Plus, Save, Trash2 } from "lucide-react";
import { useEffect, useState } from "react";
import { useParams } from "react-router-dom";
import { toast } from "sonner";
import { toast } from "../../../components/ui/use-toast";
import { Button } from "../../../components/ui/button";
import {
Card,

View File

@@ -20,7 +20,7 @@ import {
import * as React from "react";
import { useMemo, useState } from "react";
import { Link, useNavigate, useParams } from "react-router-dom";
import { toast } from "sonner";
import { toast } from "../../../components/ui/use-toast";
import { Badge } from "../../../components/ui/badge";
import { Button } from "../../../components/ui/button";
import {
@@ -266,7 +266,7 @@ const MemberTable: React.FC<{
<Users size={40} />
<p>{t("msg.admin.users.list.empty", "멤버가 없습니다.")}</p>
<Button
variant="link"
variant="outline"
size="sm"
onClick={onRefresh}
className="mt-2"
@@ -369,7 +369,6 @@ const UserAddDialog: React.FC<{
description: res.initialPassword
? `초기 비밀번호: ${res.initialPassword}`
: undefined,
duration: 10000,
},
);
@@ -776,7 +775,7 @@ const TenantTreeRow: React.FC<{
onClick={() => {
if (node.type === "USER_GROUP") {
// User groups have a different detail path
const baseTenantId = node.tenantId || tenantId;
const baseTenantId = (node as any).tenantId || (node as any).parentId || "";
navigate(`/tenants/${baseTenantId}/organization/${node.id}`);
} else {
navigate(`/tenants/${node.id}`);

View File

@@ -3,7 +3,7 @@ import type { AxiosError } from "axios";
import { ArrowLeft, Shield, Trash2, UserPlus, Users } from "lucide-react";
import { useState } from "react";
import { Link, useParams } from "react-router-dom";
import { toast } from "sonner";
import { toast } from "../../../components/ui/use-toast";
import { Badge } from "../../../components/ui/badge";
import { Button } from "../../../components/ui/button";
import {
@@ -189,7 +189,7 @@ export function UserGroupDetailPage() {
<p>
Error:{" "}
{(error as AxiosError<{ error?: string }>)?.response?.data?.error ||
error.message ||
(error as any)?.message ||
"Not found"}
</p>
</div>

View File

@@ -20,6 +20,7 @@ import {
createUser,
fetchTenant,
fetchTenants,
fetchMe,
} from "../../lib/adminApi";
import { t } from "../../lib/i18n";
@@ -78,8 +79,9 @@ function UserCreatePage() {
// Lock company for tenant_admin
React.useEffect(() => {
if (profile?.role === "tenant_admin" && profile.companyCode) {
setValue("companyCode", profile.companyCode);
const p = profile as any;
if (p?.role === "tenant_admin" && p.companyCode) {
setValue("companyCode", p.companyCode);
}
}, [profile, setValue]);
@@ -360,7 +362,7 @@ function UserCreatePage() {
id="companyCode"
className="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"
{...register("companyCode")}
disabled={profile?.role === "tenant_admin"}
disabled={(profile as any)?.role === "tenant_admin"}
>
<option value="">
{t(

View File

@@ -19,7 +19,7 @@ import {
useForm,
} from "react-hook-form";
import { Link, useNavigate, useParams } from "react-router-dom";
import { toast } from "sonner";
import { toast } from "../../components/ui/use-toast";
import { Button } from "../../components/ui/button";
import {
Card,
@@ -149,7 +149,7 @@ function TenantProfileCard({
/>
{errors.metadata?.[tenant.id]?.[field.key] && (
<p className="text-[10px] text-destructive">
{errors.metadata[tenant.id][field.key].message}
{(errors.metadata as any)?.[tenant.id]?.[field.key]?.message}
</p>
)}
</div>
@@ -248,7 +248,7 @@ function UserDetailPage() {
position: user.position || "",
jobTitle: user.jobTitle || "",
password: "",
metadata: user.metadata || {},
metadata: (user.metadata || {}) as any,
});
}
}, [user, reset]);

View File

@@ -1,3 +1,4 @@
import { toast } from "../../components/ui/use-toast";
import { useMutation, useQuery } from "@tanstack/react-query";
import type { AxiosError } from "axios";
import {

View File

@@ -2,7 +2,7 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import type { AxiosError } from "axios";
import { AlertTriangle, FolderTree, Loader2, Search } from "lucide-react";
import * as React from "react";
import { toast } from "sonner";
import { toast } from "../../../components/ui/use-toast";
import { Button } from "../../../components/ui/button";
import {
Dialog,
@@ -140,7 +140,7 @@ export function UserBulkMoveGroupModal({
userIds,
companyCode: selectedTenantSlug,
department: selectedGroupName, // can be empty for "No Department"
});
} as any);
};
const filteredGroups = React.useMemo(() => {

View File

@@ -22,7 +22,7 @@ user2@test.com,Kim Cheol Su,,admin,baron,IT,E002`;
},
});
expect(result[1].email).toBe("user2@test.com");
expect(result[1].metadata.emp_id).toBe("E002");
expect((result[1] as any).metadata.emp_id).toBe("E002");
});
it("should return empty array for empty input", () => {