checkpoint
This commit is contained in:
parent
14d0db5ed0
commit
74ed45c8fd
|
|
@ -1,7 +1,8 @@
|
||||||
import { FC, useEffect, useRef, useState } from "react";
|
import { FC, useEffect, useRef, useState } from "react";
|
||||||
import QrScanner from "qr-scanner";
|
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<QrScanner>();
|
const scanner = useRef<QrScanner>();
|
||||||
const videoEl = useRef<HTMLVideoElement>(null);
|
const videoEl = useRef<HTMLVideoElement>(null);
|
||||||
const qrBoxEl = useRef<HTMLDivElement>(null);
|
const qrBoxEl = useRef<HTMLDivElement>(null);
|
||||||
|
|
@ -12,9 +13,6 @@ export const QrReader: FC<{ url: string }> = ({ url }) => {
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
const onScanSuccess = (result: QrScanner.ScanResult) => {
|
const onScanSuccess = (result: QrScanner.ScanResult) => {
|
||||||
// console.log(result);
|
|
||||||
// navigate("/hasil/scan");
|
|
||||||
// setScannedResult(result?.data);
|
|
||||||
if (!hasScanned) {
|
if (!hasScanned) {
|
||||||
console.log(result);
|
console.log(result);
|
||||||
setScannedResult(result?.data);
|
setScannedResult(result?.data);
|
||||||
|
|
@ -22,9 +20,7 @@ export const QrReader: FC<{ url: string }> = ({ url }) => {
|
||||||
scanner.current?.stop();
|
scanner.current?.stop();
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// console.log("Mencoba trigger hasil scan");
|
onSuccess(result);
|
||||||
// navigate(`/hasil/scan?id_asset=${result?.data}`);
|
|
||||||
navigate(url + result?.data);
|
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import QrScanner from "qr-scanner";
|
||||||
|
|
||||||
|
export type QrReaderType = QrScanner.ScanResult;
|
||||||
|
|
@ -35,7 +35,6 @@ export const FilterField: FC<{
|
||||||
}, [filter.form]);
|
}, [filter.form]);
|
||||||
|
|
||||||
let show_modifier = filter.mode !== "inline";
|
let show_modifier = filter.mode !== "inline";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseField
|
<BaseField
|
||||||
{...filter.form.fieldProps({
|
{...filter.form.fieldProps({
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,7 @@ export const Form: FC<FMProps> = (props) => {
|
||||||
},
|
},
|
||||||
save_status: "init",
|
save_status: "init",
|
||||||
fields: {},
|
fields: {},
|
||||||
events: {
|
events: null as any,
|
||||||
on_change(name: string, new_value: any) {},
|
|
||||||
},
|
|
||||||
internal: {},
|
internal: {},
|
||||||
submit: null as any,
|
submit: null as any,
|
||||||
error: {} as any,
|
error: {} as any,
|
||||||
|
|
|
||||||
|
|
@ -42,28 +42,6 @@ export const Field: FC<FieldProp> = (arg) => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (fm.save_status === "init" || fm.status !== "ready") return;
|
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 (local.prev_val !== fm.data[name]) {
|
||||||
if (typeof fm.data[name] === "object") {
|
if (typeof fm.data[name] === "object") {
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ export const FieldTypeInput: FC<{
|
||||||
switch (type_field) {
|
switch (type_field) {
|
||||||
case "toggle":
|
case "toggle":
|
||||||
return (
|
return (
|
||||||
<div className="c-px-2">
|
<div className="c-px-2">ad
|
||||||
<div
|
<div
|
||||||
className={cx(
|
className={cx(
|
||||||
"c-relative",
|
"c-relative",
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ export const FieldMoney: FC<{
|
||||||
arg: FieldProp;
|
arg: FieldProp;
|
||||||
}> = ({ field, fm, prop, arg }) => {
|
}> = ({ field, fm, prop, arg }) => {
|
||||||
let type_field = prop.sub_type;
|
let type_field = prop.sub_type;
|
||||||
let value: any = fm.data[field.name];
|
let value: any = Number(fm.data[field.name]);
|
||||||
const input = useLocal({
|
const input = useLocal({
|
||||||
value: 0 as any,
|
value: 0 as any,
|
||||||
ref: null as any,
|
ref: null as any,
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,6 @@ export const TableList: FC<TableListProp> = ({
|
||||||
reloading: null as any,
|
reloading: null as any,
|
||||||
reload: (arg?: { toast: boolean }) => {
|
reload: (arg?: { toast: boolean }) => {
|
||||||
if (local.reloading) return local.reloading;
|
if (local.reloading) return local.reloading;
|
||||||
|
|
||||||
local.reloading = new Promise<void>(async (done) => {
|
local.reloading = new Promise<void>(async (done) => {
|
||||||
let should_toast = true;
|
let should_toast = true;
|
||||||
if (arg?.toast === false) should_toast = false;
|
if (arg?.toast === false) should_toast = false;
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ export const MasterDetail: FC<MDProps> = (arg) => {
|
||||||
md.header.render();
|
md.header.render();
|
||||||
}, [title]);
|
}, [title]);
|
||||||
}
|
}
|
||||||
|
// return <>MD</>
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cx(
|
className={cx(
|
||||||
|
|
|
||||||
|
|
@ -193,3 +193,4 @@ export { formatTime, longDate, shortDate, timeAgo } from "lib/utils/date";
|
||||||
export { getBasename, getPathname } from "lib/utils/pathname";
|
export { getBasename, getPathname } from "lib/utils/pathname";
|
||||||
|
|
||||||
export { formatMoney } from "lib/comps/form/field/type/TypeMoney";
|
export { formatMoney } from "lib/comps/form/field/type/TypeMoney";
|
||||||
|
export {Flow} from "lib/comps/ui/flow"
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ export const FormatValue: FC<{
|
||||||
value: any;
|
value: any;
|
||||||
name: string;
|
name: string;
|
||||||
gen_fields: string[];
|
gen_fields: string[];
|
||||||
mode?: "money" | "datetime" | "timeago" | "date";
|
mode?: "money" | "datetime" | "timeago" | "date" | "monthly";
|
||||||
}> = (prop) => {
|
}> = (prop) => {
|
||||||
const { value, gen_fields, name, mode } = prop;
|
const { value, gen_fields, name, mode } = prop;
|
||||||
if (mode === "money") {
|
if (mode === "money") {
|
||||||
|
|
@ -25,6 +25,13 @@ export const FormatValue: FC<{
|
||||||
} catch (ex: any) {
|
} catch (ex: any) {
|
||||||
return "-";
|
return "-";
|
||||||
}
|
}
|
||||||
|
} else if (mode === "monthly") {
|
||||||
|
if (!value || isEmptyString(value)) return "-";
|
||||||
|
try {
|
||||||
|
return formatDate(dayjs(value), "MMMM YYYY");
|
||||||
|
} catch (ex: any) {
|
||||||
|
return "-";
|
||||||
|
}
|
||||||
} else if (mode === "date") {
|
} else if (mode === "date") {
|
||||||
if (!value || isEmptyString(value)) return "-";
|
if (!value || isEmptyString(value)) return "-";
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue