From 15e1e983a5b99e8d997d58d0a48fd0289e7882ec Mon Sep 17 00:00:00 2001 From: rizky Date: Wed, 7 Aug 2024 07:24:29 -0700 Subject: [PATCH] fix --- comps/form/utils/init.tsx | 27 ++++++++++++--------------- comps/list/TableList.tsx | 14 ++++++++++++-- comps/ui/toast.tsx | 2 +- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/comps/form/utils/init.tsx b/comps/form/utils/init.tsx index a8ffabd..32b8f10 100755 --- a/comps/form/utils/init.tsx +++ b/comps/form/utils/init.tsx @@ -158,7 +158,6 @@ export const formInit = (fm: FMLocal, props: FMProps) => { if (!success) { const errors = Object.keys(fm.error.list); const count = errors.length; - console.log(fm.error.list); toast.error(
@@ -177,20 +176,18 @@ export const formInit = (fm: FMLocal, props: FMProps) => { } ); } else { - if (!fm.is_newly_created) { - toast.success( -
- - Saved -
, - { - className: css` - background: #e4ffed; - border: 2px solid green; - `, - } - ); - } + toast.success( +
+ + Saved +
, + { + className: css` + background: #e4ffed; + border: 2px solid green; + `, + } + ); } } return success; diff --git a/comps/list/TableList.tsx b/comps/list/TableList.tsx index a71614b..d11991f 100755 --- a/comps/list/TableList.tsx +++ b/comps/list/TableList.tsx @@ -196,13 +196,22 @@ export const TableList: FC = ({ }, }; } else { - const field = rel.checked.find((e) => !e.is_pk); + const field = rel.checked.find( + (e) => !e.is_pk && !e.relation + ); if (field) { local.sort.orderBy = { [columnKey]: { [field.name]: direction === "ASC" ? "asc" : "desc", }, }; + } else if (rel.relation) { + local.sort.orderBy = { + [columnKey]: { + [rel.relation.to.fields[0]]: + direction === "ASC" ? "asc" : "desc", + }, + }; } } } @@ -618,7 +627,8 @@ export const TableList: FC = ({ } } - let data = local.data || []; + let data = Array.isArray(local.data) ? local.data : []; + if (typeof local.data === "string") console.error(local.data); if (isEditor) { if (data.length > 0) { diff --git a/comps/ui/toast.tsx b/comps/ui/toast.tsx index c805c9e..aa388fd 100755 --- a/comps/ui/toast.tsx +++ b/comps/ui/toast.tsx @@ -3,7 +3,7 @@ import { toast as sonner } from "sonner"; const timer = { timeout: null as any, done: false, - limit: 400, + limit: 200, }; export const toast = {