forked from baron/baron-sso
feat(adminfront): add Data Management menu to User tab
This commit introduces a 'Data Management' dropdown menu to the User list page, consolidating user CSV import, template download, and export actions. It aligns the UI with the existing Tenant list page.
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "../../../components/ui/dialog";
|
||||
import { DropdownMenuItem } from "../../../components/ui/dropdown-menu";
|
||||
import { ScrollArea } from "../../../components/ui/scroll-area";
|
||||
import {
|
||||
type BulkUserItem,
|
||||
@@ -121,6 +122,22 @@ function hanmacEmailStatusClass(preview?: HanmacImportEmailPreview) {
|
||||
return "text-muted-foreground";
|
||||
}
|
||||
|
||||
export const downloadUserTemplate = () => {
|
||||
const headers =
|
||||
"email,name,phone,role,tenant_slug,department,grade,position,jobTitle,employee_id,tenant_slug1,department1,grade1,position1,jobTitle1,employee_id1";
|
||||
const example =
|
||||
"user1@example.com,홍길동,010-1234-5678,user,tenant-slug,개발팀,수석,팀장,프론트엔드,EMP001,second-tenant,센터,책임,,Architecture,EMP002";
|
||||
const blob = new Blob([`${headers}\n${example}`], {
|
||||
type: "text/csv;charset=utf-8;",
|
||||
});
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = "user_bulk_template.csv";
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
};
|
||||
|
||||
export function UserBulkUploadModal({
|
||||
onSuccess,
|
||||
variant = "button",
|
||||
@@ -334,16 +351,14 @@ export function UserBulkUploadModal({
|
||||
|
||||
const triggerNode =
|
||||
variant === "dropdown" ? (
|
||||
<div
|
||||
className="relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
|
||||
role="menuitem"
|
||||
tabIndex={-1}
|
||||
<DropdownMenuItem
|
||||
onClick={() => setOpen(true)}
|
||||
className="cursor-pointer"
|
||||
{...triggerProps}
|
||||
>
|
||||
<Upload size={16} className="mr-2 opacity-50" />
|
||||
{t("ui.admin.users.list.bulk_import", "일괄 등록 (CSV)")}
|
||||
</div>
|
||||
</DropdownMenuItem>
|
||||
) : (
|
||||
<DialogTrigger asChild>
|
||||
<Button variant="outline" className="gap-2" {...triggerProps}>
|
||||
|
||||
Reference in New Issue
Block a user