From 74ed45c8fd77c946d103bdf7076b891c56eeafb4 Mon Sep 17 00:00:00 2001 From: rizky Date: Wed, 25 Sep 2024 21:25:24 -0700 Subject: [PATCH] checkpoint --- comps/custom/QrReader.tsx | 10 +++------- comps/custom/typings.ts | 3 +++ comps/filter/FilterField.tsx | 1 - comps/form/Form.tsx | 4 +--- comps/form/field/Field.tsx | 22 ---------------------- comps/form/field/type/TypeInput.tsx | 2 +- comps/form/field/type/TypeMoney.tsx | 2 +- comps/list/TableList.tsx | 1 - comps/md/MasterDetail.tsx | 2 +- exports.tsx | 1 + utils/format-value.tsx | 11 +++++++++-- 11 files changed, 20 insertions(+), 39 deletions(-) create mode 100755 comps/custom/typings.ts diff --git a/comps/custom/QrReader.tsx b/comps/custom/QrReader.tsx index 7626d8b..60ab6f0 100755 --- a/comps/custom/QrReader.tsx +++ b/comps/custom/QrReader.tsx @@ -1,7 +1,8 @@ import { FC, useEffect, useRef, useState } from "react"; import QrScanner from "qr-scanner"; +import { QrReaderType } from "./typings"; -export const QrReader: FC<{ url: string }> = ({ url }) => { +export const QrReader: FC<{ onSuccess: (result: QrReaderType) => {} }> = ({ onSuccess }) => { const scanner = useRef(); const videoEl = useRef(null); const qrBoxEl = useRef(null); @@ -12,9 +13,6 @@ export const QrReader: FC<{ url: string }> = ({ url }) => { // Success const onScanSuccess = (result: QrScanner.ScanResult) => { - // console.log(result); - // navigate("/hasil/scan"); - // setScannedResult(result?.data); if (!hasScanned) { console.log(result); setScannedResult(result?.data); @@ -22,9 +20,7 @@ export const QrReader: FC<{ url: string }> = ({ url }) => { scanner.current?.stop(); setTimeout(() => { - // console.log("Mencoba trigger hasil scan"); - // navigate(`/hasil/scan?id_asset=${result?.data}`); - navigate(url + result?.data); + onSuccess(result); }, 1000); } }; diff --git a/comps/custom/typings.ts b/comps/custom/typings.ts new file mode 100755 index 0000000..4b1e32c --- /dev/null +++ b/comps/custom/typings.ts @@ -0,0 +1,3 @@ +import QrScanner from "qr-scanner"; + +export type QrReaderType = QrScanner.ScanResult; diff --git a/comps/filter/FilterField.tsx b/comps/filter/FilterField.tsx index 7449415..88868f2 100755 --- a/comps/filter/FilterField.tsx +++ b/comps/filter/FilterField.tsx @@ -35,7 +35,6 @@ export const FilterField: FC<{ }, [filter.form]); let show_modifier = filter.mode !== "inline"; - return ( = (props) => { }, save_status: "init", fields: {}, - events: { - on_change(name: string, new_value: any) {}, - }, + events: null as any, internal: {}, submit: null as any, error: {} as any, diff --git a/comps/form/field/Field.tsx b/comps/form/field/Field.tsx index 2eafded..0a307ad 100755 --- a/comps/form/field/Field.tsx +++ b/comps/form/field/Field.tsx @@ -42,28 +42,6 @@ export const Field: FC = (arg) => { useEffect(() => { if (fm.save_status === "init" || fm.status !== "ready") return; - if (local.prev_val === undefined) { - if (typeof fm.data[name] === "object" && fm.deps.md) { - const sfied = hashSum(prepForSum(fm.data[name])); - - if (sfied !== local.prev_val) { - local.prev_val = sfied; - } else { - return; - } - } else { - local.prev_val = fm.data[name]; - } - - if (!fm.events) { - fm.events = { - on_change(name, new_value) {}, - }; - } - - fm.events.on_change(name, fm.data[name]); - return; - } if (local.prev_val !== fm.data[name]) { if (typeof fm.data[name] === "object") { diff --git a/comps/form/field/type/TypeInput.tsx b/comps/form/field/type/TypeInput.tsx index db657f1..08bd74a 100755 --- a/comps/form/field/type/TypeInput.tsx +++ b/comps/form/field/type/TypeInput.tsx @@ -116,7 +116,7 @@ export const FieldTypeInput: FC<{ switch (type_field) { case "toggle": return ( -
+
ad
= ({ field, fm, prop, arg }) => { let type_field = prop.sub_type; - let value: any = fm.data[field.name]; + let value: any = Number(fm.data[field.name]); const input = useLocal({ value: 0 as any, ref: null as any, diff --git a/comps/list/TableList.tsx b/comps/list/TableList.tsx index c65d03c..9a9b13e 100755 --- a/comps/list/TableList.tsx +++ b/comps/list/TableList.tsx @@ -183,7 +183,6 @@ export const TableList: FC = ({ reloading: null as any, reload: (arg?: { toast: boolean }) => { if (local.reloading) return local.reloading; - local.reloading = new Promise(async (done) => { let should_toast = true; if (arg?.toast === false) should_toast = false; diff --git a/comps/md/MasterDetail.tsx b/comps/md/MasterDetail.tsx index 1592972..4b86c10 100755 --- a/comps/md/MasterDetail.tsx +++ b/comps/md/MasterDetail.tsx @@ -128,7 +128,7 @@ export const MasterDetail: FC = (arg) => { md.header.render(); }, [title]); } - + // return <>MD return (
= (prop) => { const { value, gen_fields, name, mode } = prop; if (mode === "money") { @@ -25,7 +25,14 @@ export const FormatValue: FC<{ } catch (ex: any) { return "-"; } - } else if (mode === "date") { + } else if (mode === "monthly") { + if (!value || isEmptyString(value)) return "-"; + try { + return formatDate(dayjs(value), "MMMM YYYY"); + } catch (ex: any) { + return "-"; + } + } else if (mode === "date") { if (!value || isEmptyString(value)) return "-"; try { return formatDate(dayjs(value), "DD MMMM YYYY");