[as] WIP: 설치인가 페이지

This commit is contained in:
2026-06-24 09:07:47 +09:00
parent bdc3a94ef1
commit ddb8031e55
99 changed files with 11439 additions and 8134 deletions
+9 -8
View File
@@ -3,14 +3,17 @@ export const ENDPOINT = {
TUS_UPLOAD: "/attach-service/api/v1/tus/upload",
ATTACHMENTS: "/attach-service/api/v1/atfl/attachments",
},
AS_COMMON_SERVICE: {
AS_SERVICE: {
ACNTG_SE: "/as-service/api/v1/acntg-se",
CNSTP_SE: "/as-service/api/v1/cnstp-se",
ESNTL_ATCH_FILE: "/as-service/api/v1/esntl-atch-file",
RVW_MNPW: "/as-service/api/v1/rvw-mnpw",
},
AS_INSTL_SERVICE: {
BNS_IF: "/as-service/api/v1/if",
INSTL_SNCN: "/as-service/api/v1/instl-sncn",
CKLST: "/as-service/api/v1/cklst",
CKLST_ARTCL: "/as-service/api/v1/cklst-artcl",
CKLST_RVW: "/as-service/api/v1/cklst-rvw",
ADSTDSTR: "/as-service/api/v1/adstdstr",
},
USER_SERVICE: {
LOGIN: "/user-service/login",
@@ -22,17 +25,15 @@ export const ENDPOINT = {
ELAPR_APLN: "/as-elapr-service/api/v1/elapr-apln",
ELAPR_DMND: "/as-elapr-service/api/v1/elapr-dmnd",
},
AS_CHECKLIST_SERVICE: {
CKLST: "/as-service/api/v1/cklst",
CKLST_ARTCL: "/as-service/api/v1/cklst-artcl",
CKLST_RVW: "/as-service/api/v1/cklst-rvw",
},
CMS_SERVICE: {
CODE: "/cms-service/api/v1/code/cache",
MENU_ROLES: "/cms-service/api/v1/menu-roles",
MENU_AUTHRTS: "/cms-service/api/v1/menu-authrts",
USER_ORGANIZATION: "/cms-service/api/v1/user-ognz",
},
STATVERIFY_SERVICE: {
ST_ANLS_MST: "/statverify-service/api/v1/st-anls-mst",
},
};
export const JWT_EXPIRATION_TIME = 1800000;
+1
View File
@@ -5,4 +5,5 @@ export { queryClient } from "./query-client";
export { useAlertStore } from "./use-alert-store";
export { useDataTable } from "./use-data-table";
export { useMenuStore } from "./use-menu-store";
export { getDefaultFileKey, useTus } from "./use-tus";
export { useUserStore } from "./use-user-store";
+110
View File
@@ -0,0 +1,110 @@
import { useCallback, useState } from "react";
import { type Upload } from "tus-js-client";
import { handleTusUpload } from "@/entities/tus";
import { useAlertStore } from "./use-alert-store";
interface UploadFileOptions {
fileKey?: string;
metadata?: Record<string, string>;
}
interface UseTusOptions {
onSuccess?: (atflCd: string, atflId: string, file: File, fileKey: string) => void;
onError?: (error: Error, file: File, fileKey: string) => void;
accept?: string;
}
interface UseTusReturn {
uploadFile: (file: File, options?: UploadFileOptions) => void;
uploadFileAsync: (file: File, options?: UploadFileOptions) => Promise<string>;
progress: Record<string, number>;
isUploading: Record<string, boolean>;
uploads: Record<string, Upload>;
}
function getDefaultFileKey(file: File) {
return `${file.name}::${file.lastModified}::${file.size}`;
}
function useTus(options: UseTusOptions = {}): UseTusReturn {
const alert = useAlertStore((state) => state.setMessage);
const [progress, setProgress] = useState<Record<string, number>>({});
const [isUploading, setIsUploading] = useState<Record<string, boolean>>({});
const [uploads, setUploads] = useState<Record<string, Upload>>({});
const validateFileType = useCallback(
(file: File): boolean => {
if (!options.accept) return true;
const allowedExtensions = options.accept.split(",");
const fileExtension = file.name.substring(file.name.lastIndexOf(".")).toLowerCase();
if (!allowedExtensions.includes(fileExtension)) {
alert(`허용되지 않은 파일 형식입니다. (${fileExtension})`);
return false;
}
return true;
},
[options.accept, alert],
);
const uploadFileAsync = useCallback(
(file: File, uploadOptions?: UploadFileOptions): Promise<string> => {
if (!validateFileType(file)) {
return Promise.reject(new Error("Invalid file type"));
}
const fileKey = uploadOptions?.fileKey ?? getDefaultFileKey(file);
setIsUploading((prev) => ({ ...prev, [fileKey]: true }));
setProgress((prev) => ({ ...prev, [fileKey]: 0 }));
return new Promise<string>((resolve, reject) => {
handleTusUpload(file, {
metadata: uploadOptions?.metadata,
handleUploadStart: (upload) => {
setUploads((prev) => ({ ...prev, [fileKey]: upload }));
},
handleProgress: (percentage) => {
setProgress((prev) => ({ ...prev, [fileKey]: percentage }));
},
handleSuccess: (_upload, atflCd, atflId) => {
setIsUploading((prev) => ({ ...prev, [fileKey]: false }));
setProgress((prev) => ({ ...prev, [fileKey]: 100 }));
options.onSuccess?.(atflCd, atflId, file, fileKey);
resolve(atflCd);
},
handleError: (error) => {
setIsUploading((prev) => ({ ...prev, [fileKey]: false }));
alert("파일 업로드 중 오류가 발생했습니다.");
options.onError?.(error, file, fileKey);
reject(error);
},
});
});
},
[validateFileType, options, alert],
);
const uploadFile = useCallback(
(file: File, uploadOptions?: UploadFileOptions) => {
void uploadFileAsync(file, uploadOptions);
},
[uploadFileAsync],
);
return {
uploadFile,
uploadFileAsync,
progress,
isUploading,
uploads,
};
}
export { getDefaultFileKey, useTus };
export type { UploadFileOptions, UseTusOptions, UseTusReturn };
+194
View File
@@ -0,0 +1,194 @@
"use client";
import { useMemo } from "react";
import { cva, type VariantProps } from "class-variance-authority";
import { cn, Label } from "@common/components";
function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) {
return (
<fieldset
data-slot="field-set"
className={cn(
"flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",
className,
)}
{...props}
/>
);
}
function FieldLegend({
className,
variant = "legend",
...props
}: React.ComponentProps<"legend"> & { variant?: "legend" | "label" }) {
return (
<legend
data-slot="field-legend"
data-variant={variant}
className={cn(
"mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",
className,
)}
{...props}
/>
);
}
function FieldGroup({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="field-group"
className={cn(
"group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",
className,
)}
{...props}
/>
);
}
const fieldVariants = cva("group/field flex w-full gap-2 data-[invalid=true]:text-destructive", {
variants: {
orientation: {
vertical: "flex-col *:w-full [&>.sr-only]:w-auto",
horizontal:
"flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
responsive:
"flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
},
},
defaultVariants: {
orientation: "vertical",
},
});
function Field({
className,
orientation = "vertical",
...props
}: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants>) {
return (
<div
role="group"
data-slot="field"
data-orientation={orientation}
className={cn(fieldVariants({ orientation }), className)}
{...props}
/>
);
}
function FieldContent({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="field-content"
className={cn("group/field-content flex flex-1 flex-col gap-0.5 leading-snug", className)}
{...props}
/>
);
}
function FieldLabel({ className, ...props }: React.ComponentProps<typeof Label>) {
return (
<Label
data-slot="field-label"
className={cn(
"group/field-label peer/field-label has-data-checked:border-primary/30 has-data-checked:bg-primary/5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10 flex w-fit gap-2 leading-snug has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5 group-data-[disabled=true]/field:opacity-50",
"has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",
className,
)}
{...props}
/>
);
}
function FieldTitle({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="field-label"
className={cn(
"flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50",
className,
)}
{...props}
/>
);
}
function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {
return (
<p
data-slot="field-description"
className={cn(
"group-has-data-horizontal/field:text-balance text-left text-sm font-normal leading-normal text-muted-foreground [[data-variant=legend]+&]:-mt-1.5",
"nth-last-2:-mt-1 last:mt-0",
"[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4",
className,
)}
{...props}
/>
);
}
function FieldError({
className,
children,
errors,
...props
}: React.ComponentProps<"div"> & {
errors?: Array<{ message?: string } | undefined>;
}) {
const content = useMemo(() => {
if (children) {
return children;
}
if (!errors?.length) {
return null;
}
const uniqueErrors = [...new Map(errors.map((error) => [error?.message, error])).values()];
if (uniqueErrors?.length == 1) {
return uniqueErrors[0]?.message;
}
return (
<ul className="flex flex-col gap-1">
{uniqueErrors.map(
(error, index) => error?.message && <li key={index}>&middot; {error.message}</li>,
)}
</ul>
);
}, [children, errors]);
if (!content) {
return null;
}
return (
<div
role="alert"
data-slot="field-error"
className={cn("text-base font-normal text-destructive", className)}
{...props}
>
{content}
</div>
);
}
export {
Field,
FieldContent,
FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
FieldLegend,
FieldSet,
FieldTitle,
};
+1 -1
View File
@@ -1,6 +1,6 @@
function NoData({ message = "조회된 데이터가 없습니다." }: { message?: string }) {
return (
<div className="flex min-h-[120px] items-center justify-center text-muted-foreground">
<div className="flex min-h-[120px] w-full items-center justify-center text-muted-foreground">
<p className="text-lg">{message}</p>
</div>
);