Fix Admin Interface
This commit is contained in:
@@ -30,11 +30,11 @@ export const makeSchema = z.object({
|
||||
|
||||
export const modelSchema = z.object({
|
||||
name: z.string().min(1, 'Name is required'),
|
||||
makeId: z.string().min(1, 'Select a make'),
|
||||
makeId: z.coerce.string().min(1, 'Select a make'),
|
||||
});
|
||||
|
||||
export const yearSchema = z.object({
|
||||
modelId: z.string().min(1, 'Select a model'),
|
||||
modelId: z.coerce.string().min(1, 'Select a model'),
|
||||
year: z
|
||||
.coerce.number()
|
||||
.int()
|
||||
@@ -44,12 +44,12 @@ export const yearSchema = z.object({
|
||||
|
||||
export const trimSchema = z.object({
|
||||
name: z.string().min(1, 'Name is required'),
|
||||
yearId: z.string().min(1, 'Select a year'),
|
||||
yearId: z.coerce.string().min(1, 'Select a year'),
|
||||
});
|
||||
|
||||
export const engineSchema = z.object({
|
||||
name: z.string().min(1, 'Name is required'),
|
||||
trimId: z.string().min(1, 'Select a trim'),
|
||||
trimId: z.coerce.string().min(1, 'Select a trim'),
|
||||
displacement: z.string().optional(),
|
||||
cylinders: z
|
||||
.preprocess(
|
||||
@@ -96,22 +96,22 @@ export const buildDefaultValues = (
|
||||
case 'models':
|
||||
return {
|
||||
name: (entity as CatalogModel).name,
|
||||
makeId: (entity as CatalogModel).makeId,
|
||||
makeId: String((entity as CatalogModel).makeId),
|
||||
};
|
||||
case 'years':
|
||||
return {
|
||||
modelId: (entity as CatalogYear).modelId,
|
||||
modelId: String((entity as CatalogYear).modelId),
|
||||
year: (entity as CatalogYear).year,
|
||||
};
|
||||
case 'trims':
|
||||
return {
|
||||
name: (entity as CatalogTrim).name,
|
||||
yearId: (entity as CatalogTrim).yearId,
|
||||
yearId: String((entity as CatalogTrim).yearId),
|
||||
};
|
||||
case 'engines':
|
||||
return {
|
||||
name: (entity as CatalogEngine).name,
|
||||
trimId: (entity as CatalogEngine).trimId,
|
||||
trimId: String((entity as CatalogEngine).trimId),
|
||||
displacement: (entity as CatalogEngine).displacement ?? undefined,
|
||||
cylinders: (entity as CatalogEngine).cylinders ?? undefined,
|
||||
fuel_type: (entity as CatalogEngine).fuel_type ?? undefined,
|
||||
@@ -125,22 +125,22 @@ export const buildDefaultValues = (
|
||||
case 'models':
|
||||
return {
|
||||
name: '',
|
||||
makeId: context.make?.id ?? '',
|
||||
makeId: context.make?.id ? String(context.make.id) : '',
|
||||
};
|
||||
case 'years':
|
||||
return {
|
||||
modelId: context.model?.id ?? '',
|
||||
modelId: context.model?.id ? String(context.model.id) : '',
|
||||
year: undefined,
|
||||
};
|
||||
case 'trims':
|
||||
return {
|
||||
name: '',
|
||||
yearId: context.year?.id ?? '',
|
||||
yearId: context.year?.id ? String(context.year.id) : '',
|
||||
};
|
||||
case 'engines':
|
||||
return {
|
||||
name: '',
|
||||
trimId: context.trim?.id ?? '',
|
||||
trimId: context.trim?.id ? String(context.trim.id) : '',
|
||||
displacement: '',
|
||||
fuel_type: '',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user