Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat: custom fields (wip)

Brad Barbinf300aa6cc350
diff --git a/apps/carbon/app/components/Form/CustomFormFields.tsx b/apps/carbon/app/components/Form/CustomFormFields.tsx
new file mode 100644
index 0000000000..67758d4566
--- /dev/null
+++ b/apps/carbon/app/components/Form/CustomFormFields.tsx
@@ -0,0 +1,96 @@
+import { useCustomFieldsSchema } from "~/hooks/useCustomFieldsSchema";
+import { DataType } from "~/modules/shared";
+
+import {
+ Boolean,
+ DatePicker,
+ Employee,
+ Input,
+ Number,
+ Select,
+} from "~/components/Form";
+
+type CustomFormFieldsProps = {
+ table: string;
+};
+
+const CustomFormFields = ({ table }: CustomFormFieldsProps) => {
+ const customFormSchema = useCustomFieldsSchema();
+ const tableFields = customFormSchema?.[table];
+
+ if (!tableFields) return null;
+
+ return (
+ <>
+ {tableFields
+ .sort((a, b) => a.sortOrder - b.sortOrder)
+ .map((field) => {
+ switch (field.dataTypeId) {
+ case DataType.Boolean:
+ return (
+ <Boolean
+ key={field.id}
+ name={getCustomFieldName(field.id)}
+ label={field.name}
+ />
+ );
+ case DataType.Date:
+ return (
+ <DatePicker
+ key={field.id}
+ name={getCustomFieldName(field.id)}
+ label={field.name}
+ />
+ );
+ case DataType.List:
+ return (
+ <Select
+ key={field.id}
+ name={getCustomFieldName(field.id)}
+ label={field.name}
+ placeholder={`Select ${field.name}`}
+ options={
+ field.listOptions?.map((o) => ({
+ label: o,
+ value: o,
+ })) ?? []
+ }
+ />
+ );
+ case DataType.Numeric:
+ return (
+ <Number
+ key={field.id}
+ name={getCustomFieldName(field.id)}
+ label={field.name}
+ />
+ );
+ case DataType.Text:
+ return (
+ <Input
+ key={field.id}
+ name={getCustomFieldName(field.id)}
+ label={field.name}
+ />
+ );
+ case DataType.User:
+ return (
+ <Employee
+ key={field.id}
+ name={getCustomFieldName(field.id)}
+ label={field.name}
+ />
+ );
+ default:
+ return null;
+ }
+ })}
+ </>
+ );
+};
+
+export default CustomFormFields;
+
+function getCustomFieldName(id: string) {
+ return `custom-${id}`;
+}
diff --git a/apps/carbon/app/components/Form/index.ts b/apps/carbon/app/components/Form/index.ts
index 6a9b8da4a3..39f4dc1c40 100644
--- a/apps/carbon/app/components/Form/index.ts
+++ b/apps/carbon/app/components/Form/index.ts
@@ -10,6 +10,7 @@ import Combobox from "./Combobox";
import ComboboxControlled from "./ComboboxControlled";
import CreatableCombobox from "./CreatableCombobox";
import Currency from "./Currency";
+import CustomFormFields from "./CustomFormFields";
import Customer from "./Customer";
import CustomerContact from "./CustomerContact";
import CustomerLocation from "./CustomerLocation";
@@ -65,6 +66,7 @@ export {
ComboboxControlled,
CreatableCombobox,
Currency,
+ CustomFormFields,
Customer,
CustomerContact,
CustomerLocation,
diff --git a/apps/carbon/app/hooks/useCustomFields.tsx b/apps/carbon/app/hooks/useCustomFieldsSchema.tsx
similarity index 96%
rename from apps/carbon/app/hooks/useCustomFields.tsx
rename to apps/carbon/app/hooks/useCustomFieldsSchema.tsx
index f25928f17a..1ed453df11 100644
--- a/apps/carbon/app/hooks/useCustomFields.tsx
+++ b/apps/carbon/app/hooks/useCustomFieldsSchema.tsx
@@ -4,7 +4,7 @@ import { z } from "zod";
import { path } from "~/utils/path";
import { useRouteData } from "./useRouteData";
-export function useCustomFields() {
+export function useCustomFieldsSchema() {
const data = useRouteData<{
customFields: { table: string; name: string; fields: Json[] }[];
}>(path.to.authenticatedRoot);
diff --git a/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoryForm.tsx b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoryForm.tsx
index c7f76b4692..b24f5c158e 100644
--- a/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoryForm.tsx
+++ b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoryForm.tsx
@@ -11,7 +11,13 @@ import {
} from "@carbon/react";
import { ValidatedForm } from "@carbon/remix-validated-form";
import type { z } from "zod";
-import { Hidden, Input, Select, Submit } from "~/components/Form";
+import {
+ CustomFormFields,
+ Hidden,
+ Input,
+ Select,
+ Submit,
+} from "~/components/Form";
import { usePermissions } from "~/hooks";
import {
accountCategoryValidator,
@@ -80,7 +86,7 @@ const AccountCategoryForm = ({
label: accountClass,
}))}
/>
- {/* <CustomFormFields table="accountCategory" />*/}
+ <CustomFormFields table="accountCategory" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountSubcategoryForm.tsx b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountSubcategoryForm.tsx
index 17e71d02ec..bc547baadf 100644
--- a/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountSubcategoryForm.tsx
+++ b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountSubcategoryForm.tsx
@@ -15,7 +15,7 @@ import {
import { ValidatedForm } from "@carbon/remix-validated-form";
import { useParams } from "@remix-run/react";
import type { z } from "zod";
-import { Hidden, Input, Submit } from "~/components/Form";
+import { CustomFormFields, Hidden, Input, Submit } from "~/components/Form";
import { usePermissions, useRouteData } from "~/hooks";
import type { AccountCategory } from "~/modules/accounting";
import { accountSubcategoryValidator } from "~/modules/accounting";
@@ -80,7 +80,7 @@ const AccountSubcategoryForm = ({
<InputBase value={category} isReadOnly />
</FormControl>
<Input name="name" label="Name" />
- {/* <CustomFormFields table="accountSubcategory" />*/}
+ <CustomFormFields table="accountSubcategory" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountForm.tsx b/apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountForm.tsx
index 4e0ab216d5..362a873f76 100644
--- a/apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountForm.tsx
+++ b/apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountForm.tsx
@@ -18,6 +18,7 @@ import {
AccountSubcategory,
Boolean,
ComboboxControlled,
+ CustomFormFields,
Hidden,
Input,
Select,
@@ -154,7 +155,7 @@ const ChartOfAccountForm = ({ initialValues }: ChartOfAccountFormProps) => {
}))}
/>
<Boolean name="directPosting" label="Direct Posting" />
- {/* <CustomFormFields table="account" />*/}
+ <CustomFormFields table="account" />
</div>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/accounting/ui/Currencies/CurrencyForm.tsx b/apps/carbon/app/modules/accounting/ui/Currencies/CurrencyForm.tsx
index 505c45d337..e42167b95d 100644
--- a/apps/carbon/app/modules/accounting/ui/Currencies/CurrencyForm.tsx
+++ b/apps/carbon/app/modules/accounting/ui/Currencies/CurrencyForm.tsx
@@ -13,7 +13,14 @@ import { ValidatedForm } from "@carbon/remix-validated-form";
import { useNavigate } from "@remix-run/react";
import { useState } from "react";
import type { z } from "zod";
-import { Boolean, Hidden, Input, Number, Submit } from "~/components/Form";
+import {
+ Boolean,
+ CustomFormFields,
+ Hidden,
+ Input,
+ Number,
+ Submit,
+} from "~/components/Form";
import { usePermissions, useRouteData } from "~/hooks";
import type { Currency } from "~/modules/accounting";
import { currencyValidator } from "~/modules/accounting";
@@ -95,7 +102,7 @@ const CurrencyForm = ({ initialValues }: CurrencyFormProps) => {
helperText={exchnageRateHelperText}
/>
<Boolean name="isBaseCurrency" label="Base Currency" />
- {/* <CustomFormFields table="currency" />*/}
+ <CustomFormFields table="currency" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermForm.tsx b/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermForm.tsx
index ad712cc00c..46dc33d84d 100644
--- a/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermForm.tsx
+++ b/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermForm.tsx
@@ -13,7 +13,14 @@ import { ValidatedForm } from "@carbon/remix-validated-form";
import { useNavigate } from "@remix-run/react";
import { useState } from "react";
import type { z } from "zod";
-import { Hidden, Input, Number, Select, Submit } from "~/components/Form";
+import {
+ CustomFormFields,
+ Hidden,
+ Input,
+ Number,
+ Select,
+ Submit,
+} from "~/components/Form";
import { usePermissions } from "~/hooks";
import type { PaymentTermCalculationMethod } from "~/modules/accounting";
import { paymentTermValidator } from "~/modules/accounting";
@@ -99,7 +106,7 @@ const PaymentTermForm = ({ initialValues }: PaymentTermFormProps) => {
maxValue={100}
helperText="The percentage of the cash discount. Use 0 for no discount."
/>
- {/* <CustomFormFields table="paymentTerm" />*/}
+ <CustomFormFields table="paymentTerm" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/ReceiptForm.tsx b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/ReceiptForm.tsx
index 6c2232717a..ca41ec45c1 100644
--- a/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/ReceiptForm.tsx
+++ b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/ReceiptForm.tsx
@@ -17,6 +17,7 @@ import { Outlet } from "@remix-run/react";
import type { z } from "zod";
import {
ComboboxControlled,
+ CustomFormFields,
Hidden,
Input,
Select,
@@ -174,7 +175,7 @@ const ReceiptForm = ({
label="External Reference"
/>
</div>
- {/* <CustomFormFields table="receipt" />*/}
+ <CustomFormFields table="receipt" />
</VStack>
</ValidatedForm>
</div>
diff --git a/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodForm.tsx b/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodForm.tsx
index fce9c35a10..dcb0fca0d6 100644
--- a/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodForm.tsx
+++ b/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodForm.tsx
@@ -13,7 +13,14 @@ import {
import { ValidatedForm } from "@carbon/remix-validated-form";
import { useNavigate } from "@remix-run/react";
import type { z } from "zod";
-import { Account, Hidden, Input, Select, Submit } from "~/components/Form";
+import {
+ Account,
+ CustomFormFields,
+ Hidden,
+ Input,
+ Select,
+ Submit,
+} from "~/components/Form";
import { usePermissions } from "~/hooks";
import { shippingMethodValidator } from "~/modules/inventory";
import { path } from "~/utils/path";
@@ -82,7 +89,7 @@ const ShippingMethodForm = ({ initialValues }: ShippingMethodFormProps) => {
label="Tracking URL"
prefix="https://"
/>
- {/* <CustomFormFields table="shippingMethod" />*/}
+ <CustomFormFields table="shippingMethod" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceForm.tsx b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceForm.tsx
index 7eb641a46a..00b087cdf3 100644
--- a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceForm.tsx
+++ b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceForm.tsx
@@ -13,6 +13,7 @@ import { useState } from "react";
import type { z } from "zod";
import {
Currency,
+ CustomFormFields,
DatePicker,
Hidden,
Input,
@@ -133,7 +134,7 @@ const PurchaseInvoiceForm = ({
<Currency name="currencyCode" label="Currency" />
</>
)}
- {/* <CustomFormFields table="purchaseInvoice" />*/}
+ <CustomFormFields table="purchaseInvoice" />
</div>
</VStack>
</CardContent>
diff --git a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx
index 81a2d336a5..f3d0cdd60d 100644
--- a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx
+++ b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx
@@ -27,6 +27,7 @@ import type { z } from "zod";
import {
Account,
ComboboxControlled,
+ CustomFormFields,
Hidden,
Number,
Part,
@@ -352,7 +353,7 @@ const PurchaseInvoiceLineForm = ({
)}
</>
)}
- {/* <CustomFormFields table="purchaseInvoiceLine" />*/}
+ <CustomFormFields table="purchaseInvoiceLine" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/parts/parts.service.ts b/apps/carbon/app/modules/parts/parts.service.ts
index 49c7d406d3..07b3b99c56 100644
--- a/apps/carbon/app/modules/parts/parts.service.ts
+++ b/apps/carbon/app/modules/parts/parts.service.ts
@@ -1,4 +1,4 @@
-import type { Database } from "@carbon/database";
+import type { Database, Json } from "@carbon/database";
import type { SupabaseClient } from "@supabase/supabase-js";
import type { z } from "zod";
import type { GenericQueryFilters } from "~/utils/query";
@@ -199,13 +199,7 @@ export async function getPartSummary(
client: SupabaseClient<Database>,
id: string
) {
- return client
- .from("part")
- .select(
- "id, name, description, partType, replenishmentSystem, partType, unitOfMeasureCode, partGroupId, blocked, active"
- )
- .eq("id", id)
- .single();
+ return client.from("part").select("*").eq("id", id).single();
}
export async function getPartSuppliers(
@@ -383,8 +377,14 @@ export async function insertShelf(
export async function upsertPart(
client: SupabaseClient<Database>,
part:
- | (z.infer<typeof partValidator> & { createdBy: string })
- | (z.infer<typeof partValidator> & { updatedBy: string })
+ | (z.infer<typeof partValidator> & {
+ createdBy: string;
+ customFields: Json;
+ })
+ | (z.infer<typeof partValidator> & {
+ updatedBy: string;
+ customFields: Json;
+ })
) {
if ("createdBy" in part) {
return client.from("part").insert(part).select("*").single();
@@ -394,7 +394,10 @@ export async function upsertPart(
export async function upsertPartCost(
client: SupabaseClient<Database>,
- partCost: z.infer<typeof partCostValidator> & { updatedBy: string }
+ partCost: z.infer<typeof partCostValidator> & {
+ updatedBy: string;
+ customFields: Json;
+ }
) {
return client
.from("partCost")
@@ -405,13 +408,13 @@ export async function upsertPartCost(
export async function upsertPartInventory(
client: SupabaseClient<Database>,
partInventory:
- | {
- partId: string;
- locationId: string;
+ | (z.infer<typeof partInventoryValidator> & {
createdBy: string;
- }
+ customFields: Json;
+ })
| (z.infer<typeof partInventoryValidator> & {
updatedBy: string;
+ customFields: Json;
})
) {
if ("createdBy" in partInventory) {
diff --git a/apps/carbon/app/modules/parts/ui/Part/PartCostingForm.tsx b/apps/carbon/app/modules/parts/ui/Part/PartCostingForm.tsx
index c1eaa272db..2fe5733943 100644
--- a/apps/carbon/app/modules/parts/ui/Part/PartCostingForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/Part/PartCostingForm.tsx
@@ -7,7 +7,14 @@ import {
} from "@carbon/react";
import { ValidatedForm } from "@carbon/remix-validated-form";
import type { z } from "zod";
-import { Boolean, Hidden, Number, Select, Submit } from "~/components/Form";
+import {
+ Boolean,
+ CustomFormFields,
+ Hidden,
+ Number,
+ Select,
+ Submit,
+} from "~/components/Form";
import { usePermissions } from "~/hooks";
import { partCostValidator, partCostingMethods } from "~/modules/parts";
@@ -81,7 +88,7 @@ const PartCostingForm = ({ initialValues }: PartCostingFormProps) => {
isReadOnly
/>
<Boolean name="costIsAdjusted" label="Cost Is Adjusted" />
- {/* <CustomFormFields table="partCost" />*/}
+ <CustomFormFields table="partCost" />
</div>
</CardContent>
<CardFooter>
diff --git a/apps/carbon/app/modules/parts/ui/Part/PartForm.tsx b/apps/carbon/app/modules/parts/ui/Part/PartForm.tsx
index 1a341a394c..4542fd2a56 100644
--- a/apps/carbon/app/modules/parts/ui/Part/PartForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/Part/PartForm.tsx
@@ -15,6 +15,7 @@ import { useState } from "react";
import type { z } from "zod";
import {
Boolean,
+ CustomFormFields,
Hidden,
Input,
InputControlled,
@@ -167,7 +168,8 @@ const PartForm = ({ initialValues, type = "card", onClose }: PartFormProps) => {
<Boolean name="blocked" label="Blocked" />
{isEditing && <Boolean name="active" label="Active" />}
- {/* <CustomFormFields table="customerStatus" />*/}
+
+ <CustomFormFields table="part" />
</div>
</ModalCardBody>
<ModalCardFooter>
diff --git a/apps/carbon/app/modules/parts/ui/Part/PartInventoryForm.tsx b/apps/carbon/app/modules/parts/ui/Part/PartInventoryForm.tsx
index be6a4c49cb..f5e521c9b2 100644
--- a/apps/carbon/app/modules/parts/ui/Part/PartInventoryForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/Part/PartInventoryForm.tsx
@@ -11,7 +11,13 @@ import { ValidatedForm } from "@carbon/remix-validated-form";
import { useRevalidator } from "@remix-run/react";
import type { z } from "zod";
import { Combobox } from "~/components";
-import { CreatableCombobox, Hidden, Number, Submit } from "~/components/Form";
+import {
+ CreatableCombobox,
+ CustomFormFields,
+ Hidden,
+ Number,
+ Submit,
+} from "~/components/Form";
import { usePermissions, useUser } from "~/hooks";
import { useSupabase } from "~/lib/supabase";
import type { PartQuantities } from "~/modules/parts";
@@ -113,7 +119,7 @@ const PartInventoryForm = ({
label="Quantity On Sales Order"
isReadOnly
/>
- {/* <CustomFormFields table="partInventory" />*/}
+ <CustomFormFields table="partInventory" />
</div>
</CardContent>
<CardFooter>
diff --git a/apps/carbon/app/modules/parts/ui/Part/PartManufacturingForm.tsx b/apps/carbon/app/modules/parts/ui/Part/PartManufacturingForm.tsx
index 8f51aed590..ee75aa71d4 100644
--- a/apps/carbon/app/modules/parts/ui/Part/PartManufacturingForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/Part/PartManufacturingForm.tsx
@@ -7,7 +7,14 @@ import {
} from "@carbon/react";
import { ValidatedForm } from "@carbon/remix-validated-form";
import type { z } from "zod";
-import { Boolean, Hidden, Number, Select, Submit } from "~/components/Form";
+import {
+ Boolean,
+ CustomFormFields,
+ Hidden,
+ Number,
+ Select,
+ Submit,
+} from "~/components/Form";
import { usePermissions } from "~/hooks";
import {
partManufacturingPolicies,
@@ -69,7 +76,7 @@ const PartManufacturingForm = ({
name="requiresConfiguration"
label="Requires Configuration"
/>
- {/* <CustomFormFields table="partReplenishment" />*/}
+ <CustomFormFields table="partReplenishment" />
</div>
</CardContent>
<CardFooter>
diff --git a/apps/carbon/app/modules/parts/ui/Part/PartPlanningForm.tsx b/apps/carbon/app/modules/parts/ui/Part/PartPlanningForm.tsx
index 41fded070f..960a3b8212 100644
--- a/apps/carbon/app/modules/parts/ui/Part/PartPlanningForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/Part/PartPlanningForm.tsx
@@ -12,6 +12,7 @@ import type { z } from "zod";
import { Combobox } from "~/components";
import {
Boolean,
+ CustomFormFields,
Hidden,
Number,
Select as SelectForm,
@@ -118,7 +119,7 @@ const PartPlanningForm = ({
label="Demand Includes Inventory"
/>
<Boolean name="critical" label="Critical" />
- {/* <CustomFormFields table="partPlanning" />*/}
+ <CustomFormFields table="partPlanning" />
</div>
</CardContent>
<CardFooter>
diff --git a/apps/carbon/app/modules/parts/ui/Part/PartSalePriceForm.tsx b/apps/carbon/app/modules/parts/ui/Part/PartSalePriceForm.tsx
index b0d2e40947..1e250a0641 100644
--- a/apps/carbon/app/modules/parts/ui/Part/PartSalePriceForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/Part/PartSalePriceForm.tsx
@@ -11,6 +11,7 @@ import type { z } from "zod";
import {
Boolean,
Currency,
+ CustomFormFields,
Hidden,
Number,
Submit,
@@ -68,7 +69,7 @@ const PartSalePriceForm = ({ initialValues }: PartSalePriceFormProps) => {
name="allowInvoiceDiscount"
label="Allow Invoice Discount"
/>
- {/* <CustomFormFields table="partUnitSalePrice" />*/}
+ <CustomFormFields table="partUnitSalePrice" />
</div>
</CardContent>
<CardFooter>
diff --git a/apps/carbon/app/modules/parts/ui/Part/PartSupplierForm.tsx b/apps/carbon/app/modules/parts/ui/Part/PartSupplierForm.tsx
index fed3234b9a..4ada7e422b 100644
--- a/apps/carbon/app/modules/parts/ui/Part/PartSupplierForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/Part/PartSupplierForm.tsx
@@ -13,6 +13,7 @@ import { ValidatedForm } from "@carbon/remix-validated-form";
import { useNavigate, useParams } from "@remix-run/react";
import type { z } from "zod";
import {
+ CustomFormFields,
Hidden,
Input,
Number,
@@ -87,7 +88,7 @@ const PartSupplierForm = ({ initialValues }: PartSupplierFormProps) => {
label="Conversion Factor"
minValue={0}
/>
- {/* <CustomFormFields table="partSupplier" />*/}
+ <CustomFormFields table="partSupplier" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupForm.tsx b/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupForm.tsx
index 73f9fd4926..b4e79fe0aa 100644
--- a/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupForm.tsx
@@ -13,7 +13,13 @@ import {
import { ValidatedForm } from "@carbon/remix-validated-form";
import { useFetcher } from "@remix-run/react";
import type { z } from "zod";
-import { Hidden, Input, Submit, TextArea } from "~/components/Form";
+import {
+ CustomFormFields,
+ Hidden,
+ Input,
+ Submit,
+ TextArea,
+} from "~/components/Form";
import { usePermissions } from "~/hooks";
import { partGroupValidator } from "~/modules/parts";
import { path } from "~/utils/path";
@@ -76,7 +82,7 @@ const PartGroupForm = ({
<VStack spacing={4}>
<Input name="name" label="Name" />
<TextArea name="description" label="Description" />
- {/* <CustomFormFields table="partGroup" />*/}
+ <CustomFormFields table="partGroup" />
</VStack>
</ModalDrawerBody>
<ModalDrawerFooter>
diff --git a/apps/carbon/app/modules/parts/ui/Service/ServiceForm.tsx b/apps/carbon/app/modules/parts/ui/Service/ServiceForm.tsx
index c8b1906b39..90282e9330 100644
--- a/apps/carbon/app/modules/parts/ui/Service/ServiceForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/Service/ServiceForm.tsx
@@ -13,6 +13,7 @@ import type { z } from "zod";
import {
Boolean,
Combobox,
+ CustomFormFields,
Input,
InputControlled,
Select,
@@ -146,7 +147,7 @@ const ServiceForm = ({ initialValues }: ServiceFormProps) => {
<Boolean name="blocked" label="Blocked" />
{isEditing && <Boolean name="active" label="Active" />}
- {/* <CustomFormFields table="service" />*/}
+ <CustomFormFields table="service" />
</div>
</CardContent>
<CardFooter>
diff --git a/apps/carbon/app/modules/parts/ui/Service/ServiceSupplierForm.tsx b/apps/carbon/app/modules/parts/ui/Service/ServiceSupplierForm.tsx
index 3cc4c2851c..7dbc5ecef0 100644
--- a/apps/carbon/app/modules/parts/ui/Service/ServiceSupplierForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/Service/ServiceSupplierForm.tsx
@@ -12,7 +12,13 @@ import {
import { ValidatedForm } from "@carbon/remix-validated-form";
import { useNavigate, useParams } from "@remix-run/react";
import type { z } from "zod";
-import { Hidden, Input, Submit, Supplier } from "~/components/Form";
+import {
+ CustomFormFields,
+ Hidden,
+ Input,
+ Submit,
+ Supplier,
+} from "~/components/Form";
import { usePermissions } from "~/hooks";
import { serviceSupplierValidator } from "~/modules/parts";
import { path } from "~/utils/path";
@@ -66,7 +72,7 @@ const ServiceSupplierForm = ({ initialValues }: ServiceSupplierFormProps) => {
<VStack spacing={4}>
<Supplier name="supplierId" label="Supplier" />
<Input name="supplierServiceId" label="Supplier Service ID" />
- {/* <CustomFormFields table="serviceSupplier" />*/}
+ <CustomFormFields table="serviceSupplier" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasureForm.tsx b/apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasureForm.tsx
index ca0cfd8173..c6e18c9632 100644
--- a/apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasureForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasureForm.tsx
@@ -13,7 +13,7 @@ import {
import { ValidatedForm } from "@carbon/remix-validated-form";
import { useFetcher } from "@remix-run/react";
import type { z } from "zod";
-import { Hidden, Input, Submit } from "~/components/Form";
+import { CustomFormFields, Hidden, Input, Submit } from "~/components/Form";
import { usePermissions } from "~/hooks";
import { unitOfMeasureValidator } from "~/modules/parts";
import { path } from "~/utils/path";
@@ -76,7 +76,7 @@ const UnitOfMeasureForm = ({
label="Code"
helperText="Unique, uppercase, without spaces"
/>
- {/* <CustomFormFields table="unitOfMeasure" />*/}
+ <CustomFormFields table="unitOfMeasure" />
</VStack>
</ModalDrawerBody>
<ModalDrawerFooter>
diff --git a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDeliveryForm.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDeliveryForm.tsx
index 1ba8fff1c5..63603dd106 100644
--- a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDeliveryForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDeliveryForm.tsx
@@ -10,6 +10,7 @@ import { useState } from "react";
import type { z } from "zod";
import {
Boolean,
+ CustomFormFields,
Customer,
CustomerLocation,
DatePicker,
@@ -110,7 +111,7 @@ const PurchaseOrderDeliveryForm = ({
/>
</>
)}
- {/* <CustomFormFields table="purchaseOrderDelivery" />*/}
+ <CustomFormFields table="purchaseOrderDelivery" />
</div>
</CardContent>
<CardFooter>
diff --git a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderForm.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderForm.tsx
index df28137099..c6d431428d 100644
--- a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderForm.tsx
@@ -12,6 +12,7 @@ import { ValidatedForm } from "@carbon/remix-validated-form";
import { useState } from "react";
import type { z } from "zod";
import {
+ CustomFormFields,
DatePicker,
Hidden,
Input,
@@ -124,7 +125,7 @@ const PurchaseOrderForm = ({ initialValues }: PurchaseOrderFormProps) => {
{isEditing && (
<TextArea name="notes" label="Notes" readOnly={isSupplier} />
)}
- {/* <CustomFormFields table="purchaseOrder" />*/}
+ <CustomFormFields table="purchaseOrder" />
</div>
</VStack>
</CardContent>
diff --git a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx
index 24fc79f062..e14625d880 100644
--- a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx
@@ -17,6 +17,7 @@ import type { z } from "zod";
import {
Account,
ComboboxControlled,
+ CustomFormFields,
Hidden,
InputControlled,
Number,
@@ -327,7 +328,7 @@ const PurchaseOrderLineForm = ({
)}
</>
)}
- {/* <CustomFormFields table="purchaseOrderLine" />*/}
+ <CustomFormFields table="purchaseOrderLine" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderPaymentForm.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderPaymentForm.tsx
index a21385594d..c27a83a846 100644
--- a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderPaymentForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderPaymentForm.tsx
@@ -11,6 +11,7 @@ import type { z } from "zod";
import {
Boolean,
Currency,
+ CustomFormFields,
Hidden,
Select,
Submit,
@@ -79,7 +80,7 @@ const PurchaseOrderPaymentForm = ({
<Currency name="currencyCode" label="Currency" />
<Boolean name="paymentComplete" label="Payment Complete" />
- {/* <CustomFormFields table="purchaseOrderPayment" />*/}
+ <CustomFormFields table="purchaseOrderPayment" />
</div>
</CardContent>
<CardFooter>
diff --git a/apps/carbon/app/modules/purchasing/ui/RequestForQuote/RequestForQuoteForm.tsx b/apps/carbon/app/modules/purchasing/ui/RequestForQuote/RequestForQuoteForm.tsx
index 26e4d52bf8..327d8229b7 100644
--- a/apps/carbon/app/modules/purchasing/ui/RequestForQuote/RequestForQuoteForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/RequestForQuote/RequestForQuoteForm.tsx
@@ -11,6 +11,7 @@ import {
import { ValidatedForm } from "@carbon/remix-validated-form";
import type { z } from "zod";
import {
+ CustomFormFields,
DatePicker,
Hidden,
Input,
@@ -89,7 +90,7 @@ const RequestForQuoteForm = ({ initialValues }: RequestForQuoteFormProps) => {
<TextArea name="notes" label="Notes" readOnly={isSupplier} />
</>
)}
- {/* <CustomFormFields table="requestForQuote" />*/}
+ <CustomFormFields table="requestForQuote" />
</div>
</VStack>
</CardContent>
diff --git a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierContactForm.tsx b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierContactForm.tsx
index 3ad128920e..0132660766 100644
--- a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierContactForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierContactForm.tsx
@@ -13,6 +13,7 @@ import { ValidatedForm } from "@carbon/remix-validated-form";
import { useFetcher } from "@remix-run/react";
import type { z } from "zod";
import {
+ CustomFormFields,
DatePicker,
Hidden,
Input,
@@ -96,7 +97,7 @@ const SupplierContactForm = ({
{/* Country dropdown */}
<DatePicker name="birthday" label="Birthday" />
<TextArea name="notes" label="Notes" />
- {/* <CustomFormFields table="supplierContact" />*/}
+ <CustomFormFields table="supplierContact" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierForm.tsx b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierForm.tsx
index 44d3326c74..65d63bf722 100644
--- a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierForm.tsx
@@ -14,6 +14,7 @@ import { ValidatedForm } from "@carbon/remix-validated-form";
import { useFetcher } from "@remix-run/react";
import type { z } from "zod";
import {
+ CustomFormFields,
Employee,
Hidden,
Input,
@@ -92,7 +93,7 @@ const SupplierForm = ({
<Employee name="accountManagerId" label="Account Manager" />
- {/* <CustomFormFields table="supplier" />*/}
+ <CustomFormFields table="supplier" />
</div>
</ModalCardBody>
<ModalCardFooter>
diff --git a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierLocationForm.tsx b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierLocationForm.tsx
index 3d35581627..7997d70c0f 100644
--- a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierLocationForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierLocationForm.tsx
@@ -13,7 +13,7 @@ import {
import { ValidatedForm } from "@carbon/remix-validated-form";
import { useFetcher } from "@remix-run/react";
import type { z } from "zod";
-import { Hidden, Input, Submit } from "~/components/Form";
+import { CustomFormFields, Hidden, Input, Submit } from "~/components/Form";
import { usePermissions } from "~/hooks";
import { supplierLocationValidator } from "~/modules/purchasing";
import { path } from "~/utils/path";
@@ -80,7 +80,7 @@ const SupplierLocationForm = ({
<Input name="state" label="State" />
<Input name="postalCode" label="Zip Code" />
{/* Country dropdown */}
- {/* <CustomFormFields table="supplierLocation" />*/}
+ <CustomFormFields table="supplierLocation" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierPaymentForm.tsx b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierPaymentForm.tsx
index e6d0a7c036..61f9345c14 100644
--- a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierPaymentForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierPaymentForm.tsx
@@ -11,6 +11,7 @@ import { useState } from "react";
import type { z } from "zod";
import {
Currency,
+ CustomFormFields,
Hidden,
Select,
Submit,
@@ -80,7 +81,7 @@ const SupplierPaymentForm = ({ initialValues }: SupplierPaymentFormProps) => {
options={paymentTermOptions}
/>
<Currency name="currencyCode" label="Currency" />
- {/* <CustomFormFields table="supplierPayment" />*/}
+ <CustomFormFields table="supplierPayment" />
</div>
</CardContent>
<CardFooter>
diff --git a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierShippingForm.tsx b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierShippingForm.tsx
index c2ccaab803..52277b4912 100644
--- a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierShippingForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierShippingForm.tsx
@@ -10,6 +10,7 @@ import { ValidatedForm } from "@carbon/remix-validated-form";
import { useState } from "react";
import type { z } from "zod";
import {
+ CustomFormFields,
Hidden,
Select,
Submit,
@@ -90,7 +91,7 @@ const SupplierShippingForm = ({ initialValues }: SupplierShippingFormProps) => {
label="Shipping Term"
options={shippingTermOptions}
/>
- {/* <CustomFormFields table="supplierShipping" />*/}
+ <CustomFormFields table="supplierShipping" />
</div>
</CardContent>
<CardFooter>
diff --git a/apps/carbon/app/modules/purchasing/ui/SupplierStatuses/SupplierStatusForm.tsx b/apps/carbon/app/modules/purchasing/ui/SupplierStatuses/SupplierStatusForm.tsx
index ffc12b2eda..b574b88377 100644
--- a/apps/carbon/app/modules/purchasing/ui/SupplierStatuses/SupplierStatusForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/SupplierStatuses/SupplierStatusForm.tsx
@@ -13,7 +13,7 @@ import {
import { ValidatedForm } from "@carbon/remix-validated-form";
import { useFetcher } from "@remix-run/react";
import type { z } from "zod";
-import { Hidden, Input, Submit } from "~/components/Form";
+import { CustomFormFields, Hidden, Input, Submit } from "~/components/Form";
import { usePermissions } from "~/hooks";
import { supplierStatusValidator } from "~/modules/purchasing";
import { path } from "~/utils/path";
@@ -75,7 +75,7 @@ const SupplierStatusForm = ({
<Hidden name="type" value={type} />
<VStack spacing={4}>
<Input name="name" label="Supplier Status" />
- {/* <CustomFormFields table="supplierStatus" />*/}
+ <CustomFormFields table="supplierStatus" />
</VStack>
</ModalDrawerBody>
<ModalDrawerFooter>
diff --git a/apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypeForm.tsx b/apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypeForm.tsx
index d6521a4981..01ee723e09 100644
--- a/apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypeForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypeForm.tsx
@@ -13,7 +13,7 @@ import {
import { ValidatedForm } from "@carbon/remix-validated-form";
import { useFetcher } from "@remix-run/react";
import type { z } from "zod";
-import { Hidden, Input, Submit } from "~/components/Form";
+import { CustomFormFields, Hidden, Input, Submit } from "~/components/Form";
import { usePermissions } from "~/hooks";
import { supplierTypeValidator } from "~/modules/purchasing";
import { path } from "~/utils/path";
@@ -75,7 +75,7 @@ const SupplierTypeForm = ({
<Hidden name="type" value={type} />
<VStack spacing={4}>
<Input name="name" label="Supplier Type" />
- {/* <CustomFormFields table="supplierType" />*/}
+ <CustomFormFields table="supplierType" />
</VStack>
</ModalDrawerBody>
<ModalDrawerFooter>
diff --git a/apps/carbon/app/modules/resources/ui/Abilities/AbilityForm.tsx b/apps/carbon/app/modules/resources/ui/Abilities/AbilityForm.tsx
index 516cb175ed..7b5176a170 100644
--- a/apps/carbon/app/modules/resources/ui/Abilities/AbilityForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Abilities/AbilityForm.tsx
@@ -15,6 +15,7 @@ import { useNavigate } from "@remix-run/react";
import { useState } from "react";
import type { z } from "zod";
import {
+ CustomFormFields,
Employees,
Hidden,
Input,
@@ -100,7 +101,7 @@ const AbilityForm = ({ initialValues }: AbilityFormProps) => {
label="Employees"
helperText="Employees who already have this ability"
/>
- {/* <CustomFormFields table="ability" />*/}
+ <CustomFormFields table="ability" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/resources/ui/Abilities/EmployeeAbilityForm.tsx b/apps/carbon/app/modules/resources/ui/Abilities/EmployeeAbilityForm.tsx
index 73662b8175..f03b8ccbd2 100644
--- a/apps/carbon/app/modules/resources/ui/Abilities/EmployeeAbilityForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Abilities/EmployeeAbilityForm.tsx
@@ -14,7 +14,14 @@ import { ValidatedForm } from "@carbon/remix-validated-form";
import { useParams } from "@remix-run/react";
import { useState } from "react";
import type { z } from "zod";
-import { Employee, Hidden, Number, Select, Submit } from "~/components/Form";
+import {
+ CustomFormFields,
+ Employee,
+ Hidden,
+ Number,
+ Select,
+ Submit,
+} from "~/components/Form";
import { usePermissions } from "~/hooks";
import type { Ability } from "~/modules/resources";
import {
@@ -125,7 +132,7 @@ const EmployeeAbilityForm = ({
<Hidden name="trainingDays" value={trainingDays} />
</>
)}
- {/* <CustomFormFields table="employeeAbility" />*/}
+ <CustomFormFields table="employeeAbility" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/resources/ui/Contractors/ContractorForm.tsx b/apps/carbon/app/modules/resources/ui/Contractors/ContractorForm.tsx
index 94e5f9b866..3715ee5777 100644
--- a/apps/carbon/app/modules/resources/ui/Contractors/ContractorForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Contractors/ContractorForm.tsx
@@ -17,6 +17,7 @@ import { useState } from "react";
import type { z } from "zod";
import {
Abilities,
+ CustomFormFields,
Number,
Submit,
Supplier,
@@ -92,7 +93,7 @@ const ContractorForm = ({ initialValues }: ContractorFormProps) => {
minValue={0}
maxValue={10000}
/>
- {/* <CustomFormFields table="contractor" />*/}
+ <CustomFormFields table="contractor" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/resources/ui/Departments/DepartmentForm.tsx b/apps/carbon/app/modules/resources/ui/Departments/DepartmentForm.tsx
index 27d07227aa..669048fbd3 100644
--- a/apps/carbon/app/modules/resources/ui/Departments/DepartmentForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Departments/DepartmentForm.tsx
@@ -13,7 +13,13 @@ import {
import { ValidatedForm } from "@carbon/remix-validated-form";
import { useFetcher } from "@remix-run/react";
import type { z } from "zod";
-import { Department, Hidden, Input, Submit } from "~/components/Form";
+import {
+ CustomFormFields,
+ Department,
+ Hidden,
+ Input,
+ Submit,
+} from "~/components/Form";
import { usePermissions } from "~/hooks";
import { departmentValidator } from "~/modules/resources";
import { path } from "~/utils/path";
@@ -79,7 +85,7 @@ const DepartmentForm = ({
name="parentDepartmentId"
label="Parent Department"
/>
- {/* <CustomFormFields table="department" />*/}
+ <CustomFormFields table="department" />
</VStack>
</ModalDrawerBody>
<ModalDrawerFooter>
diff --git a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentForm.tsx b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentForm.tsx
index fb6f27219f..e73bd6b4d8 100644
--- a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentForm.tsx
@@ -21,6 +21,7 @@ import { useFetcher } from "@remix-run/react";
import { useEffect, useMemo, useState } from "react";
import type { z } from "zod";
import {
+ CustomFormFields,
Hidden,
Input,
Location,
@@ -140,7 +141,7 @@ const EquipmentForm = ({
minValue={0}
maxValue={100} // this seems like a reasonable max?
/>
- {/* <CustomFormFields table="equipment" />*/}
+ <CustomFormFields table="equipment" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeForm.tsx b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeForm.tsx
index 00c6535fef..18ec1d90d8 100644
--- a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeForm.tsx
@@ -15,6 +15,7 @@ import { useFetcher } from "@remix-run/react";
import type { z } from "zod";
import {
Ability,
+ CustomFormFields,
Hidden,
Input,
Number,
@@ -89,7 +90,7 @@ const EquipmentTypeForm = ({
isClearable
/>
<Number name="setupHours" label="Setup Hours" />
- {/* <CustomFormFields table="equipmentType" />*/}
+ <CustomFormFields table="equipmentType" />
</VStack>
</ModalDrawerBody>
<ModalDrawerFooter>
diff --git a/apps/carbon/app/modules/resources/ui/Holidays/HolidayForm.tsx b/apps/carbon/app/modules/resources/ui/Holidays/HolidayForm.tsx
index a29f296088..65fd9ac631 100644
--- a/apps/carbon/app/modules/resources/ui/Holidays/HolidayForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Holidays/HolidayForm.tsx
@@ -12,7 +12,13 @@ import {
import { ValidatedForm } from "@carbon/remix-validated-form";
import { useNavigate } from "@remix-run/react";
import type { z } from "zod";
-import { DatePicker, Hidden, Input, Submit } from "~/components/Form";
+import {
+ CustomFormFields,
+ DatePicker,
+ Hidden,
+ Input,
+ Submit,
+} from "~/components/Form";
import { usePermissions } from "~/hooks";
import { holidayValidator } from "~/modules/resources";
import { path } from "~/utils/path";
@@ -56,7 +62,7 @@ const HolidayForm = ({ initialValues }: HolidayFormProps) => {
<VStack spacing={4}>
<Input name="name" label="Holiday Name" />
<DatePicker name="date" label="Date" />
- {/* <CustomFormFields table="holiday" />*/}
+ <CustomFormFields table="holiday" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/resources/ui/Locations/LocationForm.tsx b/apps/carbon/app/modules/resources/ui/Locations/LocationForm.tsx
index 9fc7bb932a..33485d55c6 100644
--- a/apps/carbon/app/modules/resources/ui/Locations/LocationForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Locations/LocationForm.tsx
@@ -13,7 +13,13 @@ import {
import { ValidatedForm } from "@carbon/remix-validated-form";
import { useFetcher } from "@remix-run/react";
import type { z } from "zod";
-import { Hidden, Input, Submit, Timezone } from "~/components/Form";
+import {
+ CustomFormFields,
+ Hidden,
+ Input,
+ Submit,
+ Timezone,
+} from "~/components/Form";
import { usePermissions } from "~/hooks";
import { locationValidator } from "~/modules/resources";
import { path } from "~/utils/path";
@@ -84,7 +90,7 @@ const LocationForm = ({
<Timezone name="timezone" label="Timezone" />
{/* <Number name="latitude" label="Latitude" minValue={-90} maxValue={90} />
<Number name="longitude" label="Longitude" minVale={-180} maxValue={180} /> */}
- {/* <CustomFormFields table="location" />*/}
+ <CustomFormFields table="location" />
</VStack>
</ModalDrawerBody>
<ModalDrawerFooter>
diff --git a/apps/carbon/app/modules/resources/ui/Partners/PartnerForm.tsx b/apps/carbon/app/modules/resources/ui/Partners/PartnerForm.tsx
index 6aabc89b40..19bb465e39 100644
--- a/apps/carbon/app/modules/resources/ui/Partners/PartnerForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Partners/PartnerForm.tsx
@@ -20,6 +20,7 @@ import type { z } from "zod";
import {
Ability,
ComboboxControlled,
+ CustomFormFields,
Number,
Submit,
Supplier,
@@ -116,7 +117,7 @@ const PartnerForm = ({ initialValues }: PartnerFormProps) => {
minValue={0}
maxValue={10000}
/>
- {/* <CustomFormFields table="partner" />*/}
+ <CustomFormFields table="partner" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/resources/ui/Person/PersonJob.tsx b/apps/carbon/app/modules/resources/ui/Person/PersonJob.tsx
index e011543048..1a7c745f93 100644
--- a/apps/carbon/app/modules/resources/ui/Person/PersonJob.tsx
+++ b/apps/carbon/app/modules/resources/ui/Person/PersonJob.tsx
@@ -9,6 +9,7 @@ import {
import { ValidatedForm } from "@carbon/remix-validated-form";
import { useState } from "react";
import {
+ CustomFormFields,
DatePicker,
Employee,
Hidden,
@@ -58,7 +59,7 @@ const PersonJob = ({ job }: PersonJobProps) => {
/>
<Employee name="managerId" label="Manager" />
<Hidden name="intent" value="job" />
- {/* <CustomFormFields table="employeeJob" />*/}
+ <CustomFormFields table="employeeJob" />
</VStack>
</CardContent>
<CardFooter>
diff --git a/apps/carbon/app/modules/resources/ui/Shifts/ShiftForm.tsx b/apps/carbon/app/modules/resources/ui/Shifts/ShiftForm.tsx
index 72efe9a0c2..2d2de72dde 100644
--- a/apps/carbon/app/modules/resources/ui/Shifts/ShiftForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Shifts/ShiftForm.tsx
@@ -16,6 +16,7 @@ import { useNavigate } from "@remix-run/react";
import type { z } from "zod";
import {
Boolean,
+ CustomFormFields,
Hidden,
Input,
Location,
@@ -80,7 +81,7 @@ const ShiftForm = ({ initialValues }: ShiftFormProps) => {
<Boolean name="sunday" description="Sunday" />
</VStack>
</FormControl>
- {/* <CustomFormFields table="shift" />*/}
+ <CustomFormFields table="shift" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellForm.tsx b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellForm.tsx
index f6a1162a0b..91e715a0b2 100644
--- a/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellForm.tsx
@@ -12,6 +12,7 @@ import {
import { ValidatedForm } from "@carbon/remix-validated-form";
import type { z } from "zod";
import {
+ CustomFormFields,
DatePicker,
Department,
Hidden,
@@ -87,7 +88,7 @@ const WorkCellForm = ({
<Location name="locationId" label="Location" />
<Department name="departmentId" label="Department" />
<DatePicker name="activeDate" label="Active Date" />
- {/* <CustomFormFields table="workCell" />*/}
+ <CustomFormFields table="workCell" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeForm.tsx b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeForm.tsx
index 35e32a3e00..5842535f28 100644
--- a/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeForm.tsx
@@ -15,6 +15,7 @@ import { useFetcher } from "@remix-run/react";
import type { z } from "zod";
import {
Ability,
+ CustomFormFields,
Hidden,
Input,
Number,
@@ -96,7 +97,7 @@ const WorkCellTypeForm = ({
name="defaultStandardFactor"
label="Default Standard Factor"
/>
- {/* <CustomFormFields table="workCellType" />*/}
+ <CustomFormFields table="workCellType" />
</VStack>
</ModalDrawerBody>
<ModalDrawerFooter>
diff --git a/apps/carbon/app/modules/sales/ui/Customer/CustomerContactForm.tsx b/apps/carbon/app/modules/sales/ui/Customer/CustomerContactForm.tsx
index f3ab04426d..e0a9053c83 100644
--- a/apps/carbon/app/modules/sales/ui/Customer/CustomerContactForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Customer/CustomerContactForm.tsx
@@ -13,6 +13,7 @@ import { ValidatedForm } from "@carbon/remix-validated-form";
import { useFetcher } from "@remix-run/react";
import type { z } from "zod";
import {
+ CustomFormFields,
DatePicker,
Hidden,
Input,
@@ -96,7 +97,7 @@ const CustomerContactForm = ({
{/* Country dropdown */}
<DatePicker name="birthday" label="Birthday" />
<TextArea name="notes" label="Notes" />
- {/* <CustomFormFields table="customerContact" />*/}
+ <CustomFormFields table="customerContact" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/sales/ui/Customer/CustomerForm.tsx b/apps/carbon/app/modules/sales/ui/Customer/CustomerForm.tsx
index 7c647a9b12..078dda1c52 100644
--- a/apps/carbon/app/modules/sales/ui/Customer/CustomerForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Customer/CustomerForm.tsx
@@ -14,6 +14,7 @@ import { ValidatedForm } from "@carbon/remix-validated-form";
import { useFetcher } from "@remix-run/react";
import type { z } from "zod";
import {
+ CustomFormFields,
CustomerStatus,
CustomerType,
Employee,
@@ -91,7 +92,7 @@ const CustomerForm = ({
/>
<Employee name="accountManagerId" label="Account Manager" />
- {/* <CustomFormFields table="customer" />*/}
+ <CustomFormFields table="customer" />
</div>
</ModalCardBody>
<ModalCardFooter>
diff --git a/apps/carbon/app/modules/sales/ui/Customer/CustomerLocationForm.tsx b/apps/carbon/app/modules/sales/ui/Customer/CustomerLocationForm.tsx
index 3d92db7d66..9beff69f22 100644
--- a/apps/carbon/app/modules/sales/ui/Customer/CustomerLocationForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Customer/CustomerLocationForm.tsx
@@ -13,7 +13,7 @@ import {
import { ValidatedForm } from "@carbon/remix-validated-form";
import { useFetcher } from "@remix-run/react";
import type { z } from "zod";
-import { Hidden, Input, Submit } from "~/components/Form";
+import { CustomFormFields, Hidden, Input, Submit } from "~/components/Form";
import { usePermissions } from "~/hooks";
import { customerLocationValidator } from "~/modules/sales";
import { path } from "~/utils/path";
@@ -80,7 +80,7 @@ const CustomerLocationForm = ({
<Input name="state" label="State" />
<Input name="postalCode" label="Zip Code" />
{/* Country dropdown */}
- {/* <CustomFormFields table="customerLocation" />*/}
+ <CustomFormFields table="customerLocation" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/sales/ui/Customer/CustomerPaymentForm.tsx b/apps/carbon/app/modules/sales/ui/Customer/CustomerPaymentForm.tsx
index 80996a38e5..ed1b79bd64 100644
--- a/apps/carbon/app/modules/sales/ui/Customer/CustomerPaymentForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Customer/CustomerPaymentForm.tsx
@@ -11,6 +11,7 @@ import { useState } from "react";
import type { z } from "zod";
import {
Currency,
+ CustomFormFields,
Customer,
CustomerContact,
CustomerLocation,
@@ -80,7 +81,7 @@ const CustomerPaymentForm = ({ initialValues }: CustomerPaymentFormProps) => {
options={paymentTermOptions}
/>
<Currency name="currencyCode" label="Currency" />
- {/* <CustomFormFields table="customerPayment" />*/}
+ <CustomFormFields table="customerPayment" />
</div>
</CardContent>
<CardFooter>
diff --git a/apps/carbon/app/modules/sales/ui/CustomerStatuses/CustomerStatusForm.tsx b/apps/carbon/app/modules/sales/ui/CustomerStatuses/CustomerStatusForm.tsx
index 9c0e9526a6..603cc2e711 100644
--- a/apps/carbon/app/modules/sales/ui/CustomerStatuses/CustomerStatusForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/CustomerStatuses/CustomerStatusForm.tsx
@@ -13,7 +13,7 @@ import {
import { ValidatedForm } from "@carbon/remix-validated-form";
import { useFetcher } from "@remix-run/react";
import type { z } from "zod";
-import { Hidden, Input, Submit } from "~/components/Form";
+import { CustomFormFields, Hidden, Input, Submit } from "~/components/Form";
import { usePermissions } from "~/hooks";
import { customerStatusValidator } from "~/modules/sales";
import { path } from "~/utils/path";
@@ -75,7 +75,7 @@ const CustomerStatusForm = ({
<Hidden name="type" value={type} />
<VStack spacing={4}>
<Input name="name" label="Customer Status" />
- {/* <CustomFormFields table="customerStatus" />*/}
+ <CustomFormFields table="customerStatus" />
</VStack>
</ModalDrawerBody>
<ModalDrawerFooter>
diff --git a/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypeForm.tsx b/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypeForm.tsx
index 9bf46a4dcc..cd0e8b941e 100644
--- a/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypeForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypeForm.tsx
@@ -13,7 +13,7 @@ import {
import { ValidatedForm } from "@carbon/remix-validated-form";
import { useFetcher } from "@remix-run/react";
import type { z } from "zod";
-import { Hidden, Input, Submit } from "~/components/Form";
+import { CustomFormFields, Hidden, Input, Submit } from "~/components/Form";
import { usePermissions } from "~/hooks";
import { customerTypeValidator } from "~/modules/sales";
import { path } from "~/utils/path";
@@ -75,7 +75,7 @@ const CustomerTypeForm = ({
<Hidden name="type" value={type} />
<VStack spacing={4}>
<Input name="name" label="Customer Type" />
- {/* <CustomFormFields table="customerType" />*/}
+ <CustomFormFields table="customerType" />
</VStack>
</ModalDrawerBody>
<ModalDrawerFooter>
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationAssemblyForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationAssemblyForm.tsx
index 0bd65490c7..9f1b3719c9 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationAssemblyForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationAssemblyForm.tsx
@@ -22,6 +22,7 @@ import { BsDownload, BsThreeDotsVertical, BsUpload } from "react-icons/bs";
import { IoMdTrash } from "react-icons/io";
import type { z } from "zod";
import {
+ CustomFormFields,
Hidden,
InputControlled,
Number,
@@ -170,7 +171,7 @@ const QuotationAssemblyForm = ({
label="Quantity per Parent"
minValue={0}
/>
- {/* <CustomFormFields table="quoteAssembly" />*/}
+ <CustomFormFields table="quoteAssembly" />
</div>
</VStack>
</CardContent>
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationForm.tsx
index 1a2457a039..63fa0fc528 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationForm.tsx
@@ -12,6 +12,7 @@ import { ValidatedForm } from "@carbon/remix-validated-form";
import { useState } from "react";
import type { z } from "zod";
import {
+ CustomFormFields,
Customer,
CustomerContact,
CustomerLocation,
@@ -93,7 +94,7 @@ const QuotationForm = ({ initialValues }: QuotationFormProps) => {
<TextArea name="notes" label="Notes" />
</>
)}
- {/* <CustomFormFields table="quote" />*/}
+ <CustomFormFields table="quote" />
</div>
</VStack>
</CardContent>
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationLineForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationLineForm.tsx
index fb53f7c75e..bd6a8d60db 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationLineForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationLineForm.tsx
@@ -24,6 +24,7 @@ import { BsDownload, BsThreeDotsVertical, BsUpload } from "react-icons/bs";
import { IoMdTrash } from "react-icons/io";
import type { z } from "zod";
import {
+ CustomFormFields,
Hidden,
Input,
InputControlled,
@@ -216,7 +217,7 @@ const QuotationLineForm = ({ initialValues }: QuotationLineFormProps) => {
}))}
className={cn(!isEditing && "sr-only")}
/>
- {/* <CustomFormFields table="quoteLine" />*/}
+ <CustomFormFields table="quoteLine" />
</div>
</VStack>
</CardContent>
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationMaterialForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationMaterialForm.tsx
index c47d2544dd..a3d7749db3 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationMaterialForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationMaterialForm.tsx
@@ -15,6 +15,7 @@ import { useNavigate, useParams } from "@remix-run/react";
import { useState } from "react";
import type { z } from "zod";
import {
+ CustomFormFields,
Hidden,
InputControlled,
Number,
@@ -157,7 +158,7 @@ const QuotationMaterialForm = ({
}))
}
/>
- {/* <CustomFormFields table="quoteMaterial" />*/}
+ <CustomFormFields table="quoteMaterial" />
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationOperationForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationOperationForm.tsx
index 7b7ec1e868..e860069b13 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationOperationForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationOperationForm.tsx
@@ -22,6 +22,7 @@ import { BsThreeDotsVertical } from "react-icons/bs";
import { IoMdTrash } from "react-icons/io";
import type { z } from "zod";
import {
+ CustomFormFields,
EquipmentType,
Hidden,
InputControlled,
@@ -233,7 +234,7 @@ const QuotationOperationForm = ({
setWorkCellData((d) => ({ ...d, overheadRate: newValue }));
}}
/>
- {/* <CustomFormFields table="quoteOperation" />*/}
+ <CustomFormFields table="quoteOperation" />
</div>
</VStack>
</CardContent>
diff --git a/apps/carbon/app/routes/x+/part+/$partId.index.tsx b/apps/carbon/app/routes/x+/part+/$partId.index.tsx
index ae92b8a341..5246560e34 100644
--- a/apps/carbon/app/routes/x+/part+/$partId.index.tsx
+++ b/apps/carbon/app/routes/x+/part+/$partId.index.tsx
@@ -7,6 +7,7 @@ import type { PartSummary } from "~/modules/parts";
import { PartForm, partValidator, upsertPart } from "~/modules/parts";
import { requirePermissions } from "~/services/auth";
import { flash } from "~/services/session.server";
+import { getCustomFields, setCustomFields } from "~/utils/form";
import { assertIsPost } from "~/utils/http";
import { path } from "~/utils/path";
import { error, success } from "~/utils/result";
@@ -20,10 +21,10 @@ export async function action({ request, params }: ActionFunctionArgs) {
const { partId } = params;
if (!partId) throw new Error("Could not find partId");
+ const formData = await request.formData();
+
// validate with partsValidator
- const validation = await validator(partValidator).validate(
- await request.formData()
- );
+ const validation = await validator(partValidator).validate(formData);
if (validation.error) {
return validationError(validation.error);
@@ -32,6 +33,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
const updatePart = await upsertPart(client, {
...validation.data,
id: partId,
+ customFields: setCustomFields(formData),
updatedBy: userId,
});
if (updatePart.error) {
@@ -65,6 +67,7 @@ export default function PartBasicRoute() {
unitOfMeasureCode: partData.partSummary?.unitOfMeasureCode ?? "EA",
blocked: partData.partSummary?.blocked ?? false,
active: partData.partSummary?.active ?? false,
+ ...getCustomFields(partData.partSummary?.customFields ?? {}),
};
return <PartForm key={initialValues.id} initialValues={initialValues} />;
diff --git a/apps/carbon/app/routes/x+/part+/$partId.inventory.tsx b/apps/carbon/app/routes/x+/part+/$partId.inventory.tsx
index c5e5d2148e..bd6f3fee6c 100644
--- a/apps/carbon/app/routes/x+/part+/$partId.inventory.tsx
+++ b/apps/carbon/app/routes/x+/part+/$partId.inventory.tsx
@@ -16,6 +16,7 @@ import { getUserDefaults } from "~/modules/users/users.server";
import { requirePermissions } from "~/services/auth";
import { flash } from "~/services/session.server";
import type { ListItem } from "~/types";
+import { getCustomFields, setCustomFields } from "~/utils/form";
import { assertIsPost } from "~/utils/http";
import { path } from "~/utils/path";
import { error, success } from "~/utils/result";
@@ -70,6 +71,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const insertPartInventory = await upsertPartInventory(client, {
partId,
locationId,
+ customFields: {},
createdBy: userId,
});
@@ -126,10 +128,9 @@ export async function action({ request, params }: ActionFunctionArgs) {
const { partId } = params;
if (!partId) throw new Error("Could not find partId");
+ const formData = await request.formData();
// validate with partsValidator
- const validation = await validator(partInventoryValidator).validate(
- await request.formData()
- );
+ const validation = await validator(partInventoryValidator).validate(formData);
if (validation.error) {
return validationError(validation.error);
@@ -140,6 +141,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
const updatePartInventory = await upsertPartInventory(client, {
...update,
partId,
+ customFields: setCustomFields(formData),
updatedBy: userId,
});
if (updatePartInventory.error) {
@@ -167,6 +169,7 @@ export default function PartInventoryRoute() {
const initialValues = {
...partInventory,
defaultShelfId: partInventory.defaultShelfId ?? undefined,
+ ...getCustomFields(partInventory.customFields ?? {}),
};
return (
<PartInventoryForm
diff --git a/apps/carbon/app/routes/x+/part+/new.tsx b/apps/carbon/app/routes/x+/part+/new.tsx
index 064be0dd07..402b5efb49 100644
--- a/apps/carbon/app/routes/x+/part+/new.tsx
+++ b/apps/carbon/app/routes/x+/part+/new.tsx
@@ -4,6 +4,7 @@ import { json, redirect } from "@remix-run/node";
import { PartForm, partValidator, upsertPart } from "~/modules/parts";
import { requirePermissions } from "~/services/auth";
import { flash } from "~/services/session.server";
+import { setCustomFields } from "~/utils/form";
import { assertIsPost } from "~/utils/http";
import { path } from "~/utils/path";
import { error } from "~/utils/result";
@@ -26,6 +27,7 @@ export async function action({ request }: ActionFunctionArgs) {
const createPart = await upsertPart(client, {
...validation.data,
active: true,
+ customFields: setCustomFields(formData),
createdBy: userId,
});
if (createPart.error) {
diff --git a/apps/carbon/app/routes/x+/settings+/custom-fields.$tableId.$id.tsx b/apps/carbon/app/routes/x+/settings+/custom-fields.$tableId.$id.tsx
index b35835e5d3..389e014b5e 100644
--- a/apps/carbon/app/routes/x+/settings+/custom-fields.$tableId.$id.tsx
+++ b/apps/carbon/app/routes/x+/settings+/custom-fields.$tableId.$id.tsx
@@ -98,9 +98,9 @@ export default function UpdateCustomFieldRoute() {
initialValues={{
id: customField.id,
name: customField.name,
- // @ts-ignore
- dataTypeId: (customField.dataTypeId || DataType.Text).toString(),
+ dataTypeId: customField.dataTypeId || DataType.Text,
customFieldTableId: tableId,
+ listOptions: customField.listOptions,
}}
dataTypes={routeData?.dataTypes ?? []}
onClose={onClose}
diff --git a/apps/carbon/app/utils/form.ts b/apps/carbon/app/utils/form.ts
index d3d2dcc6a6..378333ba29 100644
--- a/apps/carbon/app/utils/form.ts
+++ b/apps/carbon/app/utils/form.ts
@@ -1,5 +1,41 @@
+import type { Json } from "@carbon/database";
+
const emailRegex = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
export const isValidEmail = (email: string) => {
return emailRegex.test(email);
};
+
+export const getCustomFields = (
+ fields: Json
+): Record<string, string | number | boolean> => {
+ if (typeof fields !== "object" || fields === null) return {};
+ return Object.entries(fields).reduce<
+ Record<string, string | number | boolean>
+ >((acc, [key, value]) => {
+ if (
+ typeof value === "string" ||
+ typeof value === "number" ||
+ typeof value === "boolean"
+ ) {
+ acc[`custom-${key}`] = value;
+ }
+ return acc;
+ }, {});
+};
+
+export const setCustomFields = (
+ formData: FormData
+): Record<string, string | number | boolean> => {
+ let result: Record<string, string | number | boolean> = {};
+ for (let [key, value] of formData.entries()) {
+ if (
+ (key.startsWith("custom-") && typeof value === "string") ||
+ typeof value === "number" ||
+ typeof value === "boolean"
+ ) {
+ result[key.replace("custom-", "")] = value;
+ }
+ }
+ return result;
+};