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: add country selector to locations

Rob Carrington34706d06ece5
diff --git a/apps/carbon/app/components/Form/Location.tsx b/apps/carbon/app/components/Form/Location.tsx
index 10b4a10bbf..a1887ce7dd 100644
--- a/apps/carbon/app/components/Form/Location.tsx
+++ b/apps/carbon/app/components/Form/Location.tsx
@@ -45,6 +45,7 @@ const Location = (props: LocationSelectProps) => {
city: "",
state: "",
postalCode: "",
+ countryCode: "",
}}
/>
)}
diff --git a/apps/carbon/app/modules/resources/resources.models.ts b/apps/carbon/app/modules/resources/resources.models.ts
index 039aabf2f0..8c953a7d67 100644
--- a/apps/carbon/app/modules/resources/resources.models.ts
+++ b/apps/carbon/app/modules/resources/resources.models.ts
@@ -63,7 +63,7 @@ export const locationValidator = z
city: z.string().min(1, { message: "City is required" }),
state: z.string().min(1, { message: "State is required" }),
postalCode: z.string().min(1, { message: "Postal Code is required" }),
- // country: z.string().min(1, { message: "Country is required" }),
+ countryCode: z.string().min(1, { message: "Country is required" }),
timezone: z.string().min(1, { message: "Timezone is required" }),
latitude: zfd.numeric(z.number().optional()),
longitude: zfd.numeric(z.number().optional()),
diff --git a/apps/carbon/app/modules/resources/ui/Locations/LocationForm.tsx b/apps/carbon/app/modules/resources/ui/Locations/LocationForm.tsx
index e7871207a8..6d9a310645 100644
--- a/apps/carbon/app/modules/resources/ui/Locations/LocationForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Locations/LocationForm.tsx
@@ -23,6 +23,7 @@ import {
Submit,
Timezone,
} from "~/components/Form";
+import Country from "~/components/Form/Country";
import { usePermissions } from "~/hooks";
import { locationValidator } from "~/modules/resources";
import { path } from "~/utils/path";
@@ -95,7 +96,7 @@ const LocationForm = ({
<Input name="city" label="City" />
<Input name="state" label="State" />
<Input name="postalCode" label="Postal Code" />
- {/* <Country name="country" label="Country" /> */}
+ <Country />
<Timezone name="timezone" label="Timezone" />
{/* <Number name="latitude" label="Latitude" minValue={-90} maxValue={90} />
<Number name="longitude" label="Longitude" minVale={-180} maxValue={180} /> */}
diff --git a/apps/carbon/app/modules/resources/ui/Locations/LocationsTable.tsx b/apps/carbon/app/modules/resources/ui/Locations/LocationsTable.tsx
index d45652e546..9578d2fd60 100644
--- a/apps/carbon/app/modules/resources/ui/Locations/LocationsTable.tsx
+++ b/apps/carbon/app/modules/resources/ui/Locations/LocationsTable.tsx
@@ -55,7 +55,11 @@ const LocationsTable = memo(({ data, count }: LocationsTableProps) => {
header: "State",
cell: (item) => item.getValue(),
},
-
+ {
+ accessorKey: "countryCode",
+ header: "Country",
+ cell: (item) => item.getValue(),
+ },
{
accessorKey: "timezone",
header: "Timezone",
diff --git a/apps/carbon/app/routes/x+/resources+/locations.$locationId.tsx b/apps/carbon/app/routes/x+/resources+/locations.$locationId.tsx
index 736bd3d37d..6ce402b27a 100644
--- a/apps/carbon/app/routes/x+/resources+/locations.$locationId.tsx
+++ b/apps/carbon/app/routes/x+/resources+/locations.$locationId.tsx
@@ -89,6 +89,7 @@ export default function LocationRoute() {
city: location.city ?? undefined,
state: location.state ?? undefined,
postalCode: location.postalCode ?? undefined,
+ countryCode: location.countryCode ?? undefined,
timezone: location.timezone ?? getLocalTimeZone(),
latitude: location.latitude ?? undefined,
longitude: location.longitude ?? undefined,