165 lines
4.5 KiB
JavaScript

import { API } from "$lib/config/api";
import EraserIcon from "@lucide/svelte/icons/eraser";
import { z } from "zod";
export const locationSchema = z.object({});
export const locationInitialForm = {
LocationID: '',
LocCode: '',
LocType: '',
LocFull: '',
SiteID: '',
Street1: '',
Street2: '',
Phone: '',
Email: '',
City: '',
Province: '',
ZIP: '',
GeoLocationSystem: '',
GeoLocationData: '',
};
export const locationDefaultErrors = {
LocCode: "Required",
LocName: "Required",
LocType: "Required",
};
export const locationFormFields = [
{
title: "Basic Information",
rows: [
{
type: "row",
columns: [
{
key: "SiteID",
label: "Site ID",
required: true,
type: "select",
optionsEndpoint: `${API.BASE_URL}${API.SITE}`,
},
{
key: "LocCode",
label: "Location Code",
required: true,
type: "text",
validateOn: ["input"]
},
{
key: "LocType",
label: "Location Type",
required: true,
type: "text",
validateOn: ["input"]
},
{
key: "LocFull",
label: "Location Name",
required: false,
type: "text",
}
]
}
]
},
{
title: "Address Detail",
rows: [
{
type: "row",
columns: [
{
key: "Province",
label: "Province",
required: false,
type: "select",
optionsEndpoint: `${API.BASE_URL}${API.PROVINCE}`,
},
{
key: "City",
label: "City",
required: false,
type: "select",
optionsEndpoint: `${API.BASE_URL}${API.CITY}`,
},
{
key: "ZIP",
label: "ZIP",
required: false,
type: "text",
},
{
key: "Street1",
label: "Street 1",
required: false,
type: "text",
},
{
key: "Street2",
label: "Street 2",
required: false,
type: "text",
}
]
},
]
},
{
title: "Contact Information",
rows: [
{
type: "row",
columns: [
{
key: "Phone",
label: "Phone",
required: false,
type: "text"
},
{
key: "Email",
label: "Email",
required: false,
type: "text",
}
]
},
]
},
{
title: "Geographic Data",
rows: [
{
type: "row",
columns: [
{
key: "GeoLocationSystem",
label: "Geo Location System",
required: false,
type: "text",
},
{
key: "GeoLocationData",
label: "Geo Location Data",
required: false,
type: "text",
},
]
},
]
},
];
export function getLocationFormActions(handlers) {
return [
{
Icon: EraserIcon,
label: 'Clear Form',
onClick: handlers.clearForm,
},
];
}