[st] feat: 입력 - 제출 시 imr 요청 및 상태 확인, 진행 progress bar 추가
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { createStore } from "zustand/vanilla";
|
||||
|
||||
export type GlobalProgressState = {
|
||||
visible: boolean;
|
||||
label: string;
|
||||
progress: number;
|
||||
};
|
||||
|
||||
export type GlobalProgressActions = {
|
||||
show: (payload?: { label?: string; progress?: number }) => void;
|
||||
setLabel: (label: string) => void;
|
||||
setProgress: (progress: number) => void;
|
||||
hide: () => void;
|
||||
};
|
||||
|
||||
export type GlobalProgressStore = GlobalProgressState & GlobalProgressActions;
|
||||
|
||||
export const defaultGlobalProgressState: GlobalProgressState = {
|
||||
visible: false,
|
||||
label: "진행 중...",
|
||||
progress: 0,
|
||||
};
|
||||
|
||||
export const createGlobalProgressStore = (
|
||||
initState: GlobalProgressState = defaultGlobalProgressState,
|
||||
) => {
|
||||
return createStore<GlobalProgressStore>()((set) => ({
|
||||
...initState,
|
||||
show: (payload) =>
|
||||
set(() => ({
|
||||
visible: true,
|
||||
label: payload?.label ?? defaultGlobalProgressState.label,
|
||||
progress: Math.max(0, Math.min(100, payload?.progress ?? 0)),
|
||||
})),
|
||||
setLabel: (label) => set(() => ({ label })),
|
||||
setProgress: (progress) =>
|
||||
set(() => ({ progress: Math.max(0, Math.min(100, progress)) })),
|
||||
hide: () =>
|
||||
set(() => ({
|
||||
visible: false,
|
||||
progress: 0,
|
||||
label: defaultGlobalProgressState.label,
|
||||
})),
|
||||
}));
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
export { createAlertStore } from "./alert-store";
|
||||
export { createAttachmentStore } from "./attachment-store";
|
||||
export { createGlobalProgressStore } from "./global-progress-store";
|
||||
export { createMenuStore, type BbsType } from "./menu-store";
|
||||
export { createUserStore, type IUserInfo } from "./user-store";
|
||||
|
||||
Reference in New Issue
Block a user