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