From 8d716531be2aede4d3838e6568daa286a08be9d0 Mon Sep 17 00:00:00 2001 From: rizrmd Date: Tue, 28 May 2024 06:12:12 -0700 Subject: [PATCH] fix --- comps/filter/Filter.tsx | 63 +++++++++++++++++++++++++++++++++++++---- exports.ts | 5 ++++ 2 files changed, 63 insertions(+), 5 deletions(-) diff --git a/comps/filter/Filter.tsx b/comps/filter/Filter.tsx index 88d254c..772d6a0 100755 --- a/comps/filter/Filter.tsx +++ b/comps/filter/Filter.tsx @@ -2,11 +2,29 @@ import { useLocal } from "@/utils/use-local"; import get from "lodash.get"; import { FC, useEffect, useRef } from "react"; -export const MasterFilter: FC<{ +type FilterForm = { + gen_fields: GenField[]; + gen_table: string; name: string; value: any; child: any; -}> = ({name, value, child }) => { +}; + +type GenField = { + name: string, + is_pk: boolean, + type: string, + optional: boolean +}; + +export const MasterFilter: FC = ({ gen_fields, gen_table, name, value, child }) => { + const local = useLocal({ + data: [] as any[], + columns: [] as string[], + fields: [] as GenField[], + tableName: "", + isGenerated: false, + }); useEffect(() => { if (!isEditor) { const w = window as any; @@ -20,7 +38,42 @@ export const MasterFilter: FC<{ }; w.prasiContext.render(); } - },[]) - - return
{child}
; + }, []) + + const generateFilter = () => { + local.isGenerated = true; + local.tableName = gen_table; + gen_fields.forEach((data: any) => { + local.fields.push(JSON.parse(data)); + }); + local.render(); + console.log('tableName', local.tableName); + console.log('fields', local.fields); + }; + + // return
{child}
; + return ( +
+ {!local.isGenerated && ( + + )} +
+ ) }; diff --git a/exports.ts b/exports.ts index a29112b..5bacc8c 100755 --- a/exports.ts +++ b/exports.ts @@ -32,6 +32,11 @@ export const ExportExcel = lazify( async () => (await import("@/comps/list/ExportExcel")).ExportExcel ); +/** Filter */ +export const MasterFilter = lazify( + async () => (await import("@/comps/filter/Filter")).MasterFilter +); + /** Generator */ export { generateMasterDetail } from "lib/comps/md/gen/md-gen";