From 15700ae3048e0671304abd5a6fa6b45786afce53 Mon Sep 17 00:00:00 2001 From: toqvist Date: Thu, 4 Apr 2024 14:28:24 +0200 Subject: [PATCH] Update types --- astro/src/components/KiosMap.tsx | 22 +++++++++--------- astro/src/types.ts | 20 ++++++++--------- payload/src/collections/Dispatches.ts | 15 +++++++------ payload/src/collections/Makers.ts | 32 +++++++++++++-------------- payload/src/collections/Products.ts | 12 ++++++++-- payload/src/collections/Retailers.ts | 4 +++- payload/src/collections/Users.ts | 7 +----- 7 files changed, 59 insertions(+), 53 deletions(-) diff --git a/astro/src/components/KiosMap.tsx b/astro/src/components/KiosMap.tsx index cdb146d..007dc08 100644 --- a/astro/src/components/KiosMap.tsx +++ b/astro/src/components/KiosMap.tsx @@ -16,9 +16,9 @@ type User = { type Product = { id: string; - productTitle: string; - weight: number; - img: string; + title: string; + weight?: number; + picture: string; createdAt: string; updatedAt: string; }; @@ -32,9 +32,9 @@ type Maker = { id: string; name: string; email: string; - phoneNumber: string; + phoneNumber?: string; location: [number, number]; - products: Product[]; + stock: Product[]; createdAt: string; updatedAt: string; }; @@ -43,9 +43,9 @@ type Retailer = { id: string; name: string; email: string; - phoneNumber: string; + phoneNumber?: string; location: [number, number]; - products: Product[]; + stock: Product[]; createdAt: string; updatedAt: string; }; @@ -55,15 +55,15 @@ type DispatchStatus = typeof DISPATCH_STATUS[number]; type Dispatch = { id: string; - dispatchesCode: string; //Human readable id + dispatchesCode?: string; //Human readable id createdAt: string; updatedAt: string; - maker: Maker; - retailer: Retailer; + maker?: Maker; + retailer?: Retailer; products: Product[]; - courier: User; + courier?: User; timeSensitive: boolean; status: DispatchStatus[]; diff --git a/astro/src/types.ts b/astro/src/types.ts index 199343b..e118d36 100755 --- a/astro/src/types.ts +++ b/astro/src/types.ts @@ -34,7 +34,7 @@ export interface Post { export interface User { id: string; name: string; - phoneNumber: number; + phoneNumber?: number; updatedAt: string; createdAt: string; email: string; @@ -65,19 +65,19 @@ export interface Courier { } export interface Dispatch { id: string; - dispatchesCode: string; - products?: string[] | Product[]; + products: string[] | Product[]; courier?: string | Courier; maker?: string | Maker; retailer?: string | Retailer; - status?: ('requested' | 'accepted' | 'archived')[]; + status: ('requested' | 'accepted' | 'archived')[]; updatedAt: string; createdAt: string; } export interface Product { id: string; - productTitle: string; - picture?: string | Media; + title: string; + picture: string | Media; + weight?: number; updatedAt: string; createdAt: string; } @@ -88,8 +88,8 @@ export interface Maker { * @minItems 2 * @maxItems 2 */ - location?: [number, number]; - products?: string[] | Product[]; + location: [number, number]; + stock?: string[] | Product[]; updatedAt: string; createdAt: string; } @@ -100,8 +100,8 @@ export interface Retailer { * @minItems 2 * @maxItems 2 */ - location?: [number, number]; - requestedProducts?: string[] | Product[]; + location: [number, number]; + stock?: string[] | Product[]; updatedAt: string; createdAt: string; } diff --git a/payload/src/collections/Dispatches.ts b/payload/src/collections/Dispatches.ts index f5f6da2..ba4ba11 100644 --- a/payload/src/collections/Dispatches.ts +++ b/payload/src/collections/Dispatches.ts @@ -9,17 +9,17 @@ const Dispatches: CollectionConfig = { read: () => true, }, fields: [ - { - name: 'dispatchesCode', - type: 'text', - required: true, - }, + // { + // name: 'dispatchesCode', + // type: 'text', + // required: false, + // }, { name: 'products', type: 'relationship', relationTo: 'products', - hasMany: true // required - // required, + hasMany: true, + required: true, }, { name: 'courier', @@ -46,6 +46,7 @@ const Dispatches: CollectionConfig = { name: 'status', type: 'select', hasMany: true, + required: true, options: [ { label: 'Requested', diff --git a/payload/src/collections/Makers.ts b/payload/src/collections/Makers.ts index 50d9481..6977610 100644 --- a/payload/src/collections/Makers.ts +++ b/payload/src/collections/Makers.ts @@ -1,5 +1,4 @@ import { CollectionConfig } from 'payload/types'; -import { geoPickerField } from "../customFields/geoPicker/field"; const Makers: CollectionConfig = { slug: 'makers', @@ -11,21 +10,22 @@ const Makers: CollectionConfig = { }, fields: [ { - name: 'name', - type: 'text', - required: true, - }, - { - name: 'location', - type: 'point', - label: 'Location', - }, - { - name: 'products', - type: 'relationship', - relationTo: 'products', - hasMany: true, - } + name: 'name', + type: 'text', + required: true, + }, + { + name: 'location', + type: 'point', + label: 'Location', + required: true + }, + { + name: 'stock', + type: 'relationship', + relationTo: 'products', + hasMany: true, + }, ], }; diff --git a/payload/src/collections/Products.ts b/payload/src/collections/Products.ts index 98a0682..847de8a 100644 --- a/payload/src/collections/Products.ts +++ b/payload/src/collections/Products.ts @@ -10,7 +10,7 @@ const Products: CollectionConfig = { }, fields: [ { - name: 'productTitle', + name: 'title', type: 'text', required: true, }, @@ -18,7 +18,15 @@ const Products: CollectionConfig = { name: 'picture', type: 'relationship', relationTo: 'media', - hasMany: false + hasMany: false, + required: true, + }, + { + name: 'weight', + label: 'Weight (kg)', + type: 'number', + hasMany: false, + required: false, } ], }; diff --git a/payload/src/collections/Retailers.ts b/payload/src/collections/Retailers.ts index db267d4..50ea2da 100644 --- a/payload/src/collections/Retailers.ts +++ b/payload/src/collections/Retailers.ts @@ -1,4 +1,5 @@ import { CollectionConfig } from 'payload/types'; +import { geoPickerField } from "../customFields/geoPicker/field"; const Retailers: CollectionConfig = { slug: 'retailers', @@ -18,9 +19,10 @@ const Retailers: CollectionConfig = { name: 'location', type: 'point', label: 'Location', + required: true }, { - name: 'requestedProducts', + name: 'stock', type: 'relationship', relationTo: 'products', hasMany: true, diff --git a/payload/src/collections/Users.ts b/payload/src/collections/Users.ts index 1c07c1d..7f7990a 100644 --- a/payload/src/collections/Users.ts +++ b/payload/src/collections/Users.ts @@ -19,13 +19,8 @@ const Users: CollectionConfig = { { name: 'phoneNumber', type: 'number', - required: true + required: false }, - { - name: 'email', - type: 'email', - required: true - } ], };