add
This commit is contained in:
parent
a8f0569cee
commit
dd8f88e650
|
@ -3,15 +3,15 @@ import { AppConfigSlug, BaseSetting } from "@nice/common";
|
|||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
|
||||
export function useAppConfig() {
|
||||
const utils = api.useUtils()
|
||||
const utils = api.useUtils();
|
||||
const [baseSetting, setBaseSetting] = useState<BaseSetting | undefined>();
|
||||
|
||||
const { data, isLoading }: { data: any; isLoading: boolean } =
|
||||
api.app_config.findFirst.useQuery({
|
||||
where: { slug: AppConfigSlug.BASE_SETTING }
|
||||
where: { slug: AppConfigSlug.BASE_SETTING },
|
||||
});
|
||||
const handleMutationSuccess = useCallback(() => {
|
||||
utils.app_config.invalidate()
|
||||
utils.app_config.invalidate();
|
||||
}, [utils]);
|
||||
|
||||
// Use the generic success handler in mutations
|
||||
|
@ -28,7 +28,6 @@ export function useAppConfig() {
|
|||
if (data?.meta) {
|
||||
setBaseSetting(JSON.parse(data?.meta));
|
||||
}
|
||||
|
||||
}, [data, isLoading]);
|
||||
const splashScreen = useMemo(() => {
|
||||
return baseSetting?.appConfig?.splashScreen;
|
||||
|
@ -36,8 +35,10 @@ export function useAppConfig() {
|
|||
const devDept = useMemo(() => {
|
||||
return baseSetting?.appConfig?.devDept;
|
||||
}, [baseSetting]);
|
||||
const slides = useMemo(() => {
|
||||
return baseSetting?.appConfig?.slides || [];
|
||||
}, [baseSetting]);
|
||||
return {
|
||||
|
||||
create,
|
||||
deleteMany,
|
||||
update,
|
||||
|
@ -45,5 +46,6 @@ export function useAppConfig() {
|
|||
splashScreen,
|
||||
devDept,
|
||||
isLoading,
|
||||
slides,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ export interface BaseSetting {
|
|||
appConfig?: {
|
||||
splashScreen?: string;
|
||||
devDept?: string;
|
||||
slides?: [];
|
||||
};
|
||||
}
|
||||
export type RowModelResult = {
|
||||
|
|
Loading…
Reference in New Issue