diff --git a/components/form/field/TypeRichText.tsx b/components/form/field/TypeRichText.tsx index fa6be7f..2882213 100644 --- a/components/form/field/TypeRichText.tsx +++ b/components/form/field/TypeRichText.tsx @@ -33,20 +33,30 @@ export const TypeRichText: React.FC = ({ const editorRef = useRef(null); const [content, setContent] = useState(``); - const input = useLocal({ - value: `` as any, - ref: null as any, - open: false, - editor: null as any, - }); - const [url, setUrl] = useState(null as any); const local = useLocal({ open: false, data: ["General", "Table"], tab: 0, active: "General", + ready: true as boolean, }); + const input = useLocal({ + value: `` as any, + ref: null as any, + open: false, + editor: null as any, + ready: true as boolean, + reload: () => { + local.ready = false; + local.render(); + setTimeout(() => { + local.ready = true; + local.render(); + }, 500); + }, + }); + const [url, setUrl] = useState(null as any); useEffect(() => { try { fm.fields[name] = { ...fm.fields?.[name], ...input }; @@ -811,19 +821,23 @@ export const TypeRichText: React.FC = ({ ` )} > - } - extensions={extensions} - onUpdate={({ editor }) => { - fm.data[name] = editor.getHTML(); - fm.render(); - if (typeof onChange === "function") { - onChange(fm.data[name]); - } - }} - content={fm.data?.[name]} - editable={!disabled} - > + {local.ready ? ( + } + extensions={extensions} + onUpdate={({ editor }) => { + fm.data[name] = editor.getHTML(); + fm.render(); + if (typeof onChange === "function") { + onChange(fm.data[name]); + } + }} + content={fm.data?.[name]} + editable={!disabled} + > + ) : ( + <> + )} ); }; diff --git a/components/tablelist/TableList.tsx b/components/tablelist/TableList.tsx index 3b85c55..a52092d 100644 --- a/components/tablelist/TableList.tsx +++ b/components/tablelist/TableList.tsx @@ -189,7 +189,6 @@ export const TableList: React.FC = ({ if (typeof onCount === "function") { const res = await onCount(); local.count = res; - local.render(); } if (mode === "form") { diff --git a/components/tablelist/TableUI.tsx b/components/tablelist/TableUI.tsx index 6731a91..f76cb8b 100644 --- a/components/tablelist/TableUI.tsx +++ b/components/tablelist/TableUI.tsx @@ -45,7 +45,6 @@ export const TableUI: React.FC = ({ { - console.log({ row }); return (
diff --git a/components/ui/button.tsx b/components/ui/button.tsx index 7348129..d0627a9 100644 --- a/components/ui/button.tsx +++ b/components/ui/button.tsx @@ -4,6 +4,12 @@ import { cva, type VariantProps } from "class-variance-authority"; import { cn } from "@/lib/utils/utils"; import { FC } from "react"; +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "./tooltip"; const btn = cva( " text-white px-4 py-1.5 group active-menu-icon relative flex items-stretch justify-center p-0.5 text-center border border-transparent text-white enabled:hover:bg-cyan-800 rounded-md" @@ -43,6 +49,7 @@ export interface ButtonProps extends React.ButtonHTMLAttributes, VariantProps { asChild?: boolean; + tooltip?: any; } const ButtonBetter = React.forwardRef( @@ -57,6 +64,36 @@ const ButtonBetter = React.forwardRef( ); } ); +const ButtonBetterTooltip = React.forwardRef( + ({ tooltip, className, variant, size, asChild = false, ...props }, ref) => { + const Comp = asChild ? Slot : "button"; + if (tooltip) { + return ( + + + + + + +

{tooltip}

+
+
+
+ ); + } + return ( + + ); + } +); const ButtonContainer: FC = ({ children, className, @@ -71,4 +108,10 @@ const ButtonContainer: FC = ({ }; ButtonBetter.displayName = "Button"; -export { ButtonBetter, ButtonContainer, buttonVariants, btn }; +export { + ButtonBetter, + ButtonContainer, + buttonVariants, + btn, + ButtonBetterTooltip, +}; diff --git a/utils/action.tsx b/utils/action.tsx index d4ea90e..74f8daf 100644 --- a/utils/action.tsx +++ b/utils/action.tsx @@ -63,7 +63,8 @@ export const actionToast = async (data: {
- {msg_error ? msg_error : "Failed"} { get(ex, "response.data.meta.message") || ex.message}. + {msg_error ? msg_error : "Failed"}{" "} + {get(ex, "response.data.meta.message") || ex.message}.
, { @@ -74,6 +75,5 @@ export const actionToast = async (data: { `, } ); - if (typeof after === "function") after(); } }; diff --git a/utils/apix.ts b/utils/apix.ts index 860c970..ecd1625 100644 --- a/utils/apix.ts +++ b/utils/apix.ts @@ -79,10 +79,7 @@ export const apix = async ({ throw new Error(`Unsupported HTTP method: ${method}`); } } catch (ex: any) { - console.error( - "API Error:", - get(ex, "response.data.meta.message") || ex.message - ); + throw new Error(get(ex, "response.data.meta.message") || ex.message); } const val = get(result, value);