260702_01_ENH: 리스트 작업 도중 공용 ui를 적용하기 위한 중간 커밋

This commit is contained in:
2026-07-02 17:02:17 +09:00
parent 6944064377
commit a8ce35f5bf
111 changed files with 2833 additions and 2557 deletions

View File

@@ -1,38 +1,17 @@
"use client";
import { useAtom } from "jotai";
import { useCallback } from "react";
import { manualLoadingAtom } from "@/store/jotai/loading";
import { createLoadingHook } from "@kri/common/hooks";
export const useLoading = () => {
const [isLoading, setIsLoading] = useAtom(manualLoadingAtom);
const {
loadingCountAtom,
isLoadingAtom,
useLoading,
} = createLoadingHook();
const showLoading = useCallback(() => setIsLoading(true), [setIsLoading]);
const hideLoading = useCallback(() => setIsLoading(false), [setIsLoading]);
export {
loadingCountAtom,
isLoadingAtom,
useLoading,
};
const withLoadingAsync = useCallback(
async <T,>(fn: () => Promise<T>): Promise<T> => {
showLoading();
try {
return await fn();
} finally {
hideLoading();
}
},
[showLoading, hideLoading]
);
const withLoading = useCallback(
<T,>(fn: () => T): T => {
showLoading();
try {
return fn();
} finally {
hideLoading();
}
},
[showLoading, hideLoading]
);
return { isLoading, showLoading, hideLoading, withLoading, withLoadingAsync } as const;
};
export const manualLoadingAtom = isLoadingAtom;