-
-
- {t("asset_table")}
-
-
-
-
-
+ return (
+ <>
+
+
+ {t("asset_table")}
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
- {assets.map((asset: IAssetModel) => {
- return (
-
- );
- })}
-
+
+
+
+
+
+
+ {assets.map((asset: IAssetModel) => {
+ return (
+
+ );
+ })}
+
+
+
+
-
-
-
-
-
- );
+ >
+ );
}
export default AssetTable;
diff --git a/react-admin/src/pages/component/ComponentCreatePage.tsx b/react-admin/src/pages/component/ComponentCreatePage.tsx
index eb0e53a3..f45bc40d 100644
--- a/react-admin/src/pages/component/ComponentCreatePage.tsx
+++ b/react-admin/src/pages/component/ComponentCreatePage.tsx
@@ -1,346 +1,345 @@
import React from "react";
-import { Link } from "react-router-dom";
-import { PlusIcon, TrashIcon } from "@heroicons/react/24/solid";
+import {Link} from "react-router-dom";
+import {PlusIcon, TrashIcon} from "@heroicons/react/24/solid";
import InputField from "../../components/InputField";
-import { useStoreComponent } from "./hooks/useStoreComponent";
-import { useTranslation } from "react-i18next";
-import { AvoRedFieldTypesEnum } from "../../types/field/AvoRedFieldTypesEnum";
-import { Controller, useFieldArray, useForm } from "react-hook-form";
-import { joiResolver } from "@hookform/resolvers/joi";
-import { useComponentCreateSchema } from "./schemas/component.create.schema";
+import {useStoreComponent} from "./hooks/useStoreComponent";
+import {useTranslation} from "react-i18next";
+import {AvoRedFieldTypesEnum} from "../../types/field/AvoRedFieldTypesEnum";
+import {Controller, useFieldArray, useForm} from "react-hook-form";
+import {joiResolver} from "@hookform/resolvers/joi";
+import {useComponentCreateSchema} from "./schemas/component.create.schema";
import ICreatableComponent, {CreatableElementDataType} from "../../types/component/ICreatableComponent";
import ErrorMessage from "../../components/ErrorMessage";
import slug from "slug";
export const ComponentCreatePage = (() => {
- const { mutate, error } = useStoreComponent();
- const {
- control,
- register,
- handleSubmit,
- formState: { errors },
- setValue,
- trigger,
- } = useForm
({
- resolver: joiResolver(useComponentCreateSchema()),
- });
- const { fields: elements, append, remove } = useFieldArray({
- control,
- name: "elements",
- });
+ const {mutate, error} = useStoreComponent();
+ const {
+ control,
+ register,
+ handleSubmit,
+ formState: {errors},
+ setValue,
+ trigger,
+ } = useForm({
+ resolver: joiResolver(useComponentCreateSchema()),
+ });
+ const {fields: elements, append, remove} = useFieldArray({
+ control,
+ name: "elements",
+ });
- const [t] = useTranslation("global");
+ const [t] = useTranslation("global");
- const addElementOnClick = () => {
- append({ name: "", identifier: "", element_type: AvoRedFieldTypesEnum.TEXT, element_data_type: 'TEXT' });
- };
+ const addElementOnClick = () => {
+ append({name: "", identifier: "", element_type: AvoRedFieldTypesEnum.TEXT, element_data_type: 'TEXT'});
+ };
- const deleteElementOnClick = (elementIndex: number) => {
- remove(elementIndex);
- };
+ const deleteElementOnClick = (elementIndex: number) => {
+ remove(elementIndex);
+ };
- const elementTypeButtonOnClick = (
- fieldIndex: number,
- fieldTypeValue: string,
- ) => {
- setValue(`elements.${fieldIndex}.element_type`, fieldTypeValue);
- setValue(`elements.${fieldIndex}.element_data`, [{ label: "", value: "" }]);
- // Ideally value of this data type can be based on element
- // e.g: Number Input field will have INT(It should match rust backend type) data type
- setValue(`elements.${fieldIndex}.element_data_type`, 'TEXT');
- trigger(`elements.${fieldIndex}`);
- };
+ const elementTypeButtonOnClick = (
+ fieldIndex: number,
+ fieldTypeValue: string,
+ ) => {
+ setValue(`elements.${fieldIndex}.element_type`, fieldTypeValue);
+ setValue(`elements.${fieldIndex}.element_data`, [{label: "", value: ""}]);
+ // Ideally value of this data type can be based on element
+ // e.g: Number Input field will have INT(It should match rust backend type) data type
+ setValue(`elements.${fieldIndex}.element_data_type`, 'TEXT');
+ trigger(`elements.${fieldIndex}`);
+ };
- const optionDeleteActionOnClick = (
- e: React.MouseEvent,
- elementIndex: number,
- element_data: Array | undefined,
- option_index: number,
- ) => {
- element_data?.splice(option_index, 1);
- setValue(`elements.${elementIndex}.element_data`, element_data);
- trigger(`elements.${elementIndex}`);
- };
+ const optionDeleteActionOnClick = (
+ e: React.MouseEvent,
+ elementIndex: number,
+ element_data: Array | undefined,
+ option_index: number,
+ ) => {
+ element_data?.splice(option_index, 1);
+ setValue(`elements.${elementIndex}.element_data`, element_data);
+ trigger(`elements.${elementIndex}`);
+ };
- const optionAddActionOnClick = (
- e: React.MouseEvent,
- elementIndex: number,
- element_data: Array | undefined,
- ) => {
- element_data?.push({ label: "", value: "" });
- setValue(`elements.${elementIndex}.element_data`, element_data);
- trigger(`elements.${elementIndex}`);
- };
+ const optionAddActionOnClick = (
+ e: React.MouseEvent,
+ elementIndex: number,
+ element_data: Array | undefined,
+ ) => {
+ element_data?.push({label: "", value: ""});
+ setValue(`elements.${elementIndex}.element_data`, element_data);
+ trigger(`elements.${elementIndex}`);
+ };
- const submitHandler = (data: any) => {
- mutate(data);
- };
+ const submitHandler = (data: any) => {
+ mutate(data);
+ };
- const onNameChange = (e: React.KeyboardEvent) => {
- setValue('identifier', slug(e.currentTarget.value || ''))
- }
+ const onNameChange = (e: React.KeyboardEvent) => {
+ setValue('identifier', slug(e.currentTarget.value || ''))
+ }
- const ElementNameOnChange = (async (e: React.KeyboardEvent, elementIndex: number) => {
- setValue(`elements.${elementIndex}.identifier`, slug(e.currentTarget.value))
- await trigger(`elements.${elementIndex}`)
- })
+ const ElementNameOnChange = (async (e: React.KeyboardEvent, elementIndex: number) => {
+ setValue(`elements.${elementIndex}.identifier`, slug(e.currentTarget.value))
+ await trigger(`elements.${elementIndex}`)
+ })
- return (
-
-
-
-
-
- {t("component_information")}
-
-