This commit is contained in:
rizrmd 2024-06-11 01:44:33 -07:00
parent 305074648d
commit a115976802
5 changed files with 32 additions and 2 deletions

View File

@ -49,6 +49,8 @@ type TableListProp = {
render_row?: (child: any, data: any) => ReactNode;
rowHeight?: number;
render_col?: (props: any) => ReactNode;
soft_delete_field: string;
};
const w = window as any;
const selectCellClassname = css`

View File

@ -50,7 +50,8 @@ export const on_load = ({
reload: () => Promise<void>;
orderBy?: Record<string, "asc" | "desc">;
paging: { take: number; skip: number };
mode: 'count' | 'query'
mode: 'count' | 'query';
where?: any
}
`;
};

View File

@ -114,3 +114,4 @@ export { getPathname } from "./utils/pathname";
export * from "@/comps/ui/typeahead";
export * from "@/comps/ui/input";
export {softDeleteFilter} from "@/utils/soft-delete-filter"

View File

@ -50,7 +50,8 @@ type TableOnLoad = {
reload: () => Promise<void>;
orderBy?: Record<string, "asc" | "desc">;
paging: { take: number; skip: number };
mode: 'count' | 'query'
mode: 'count' | 'query';
where?: any
}
`;
};

25
utils/soft-delete-filter.ts Executable file
View File

@ -0,0 +1,25 @@
export const softDeleteFilter = (
where: any,
soft: {
field: string;
type: "boolean" | "nullable";
}
) => {
console.log({where})
const defaultParam = typeof where === "object" ? where : {}
const result = {
AND: [
typeof where === "object" ? { ...defaultParam },
{
[soft.field]:
soft.type === "boolean"
? true
: {
not: null,
},
},
],
}
console.log(result)
return result;
};