Update types

This commit is contained in:
toqvist 2024-04-04 14:28:24 +02:00
parent 174a163cd3
commit 15700ae304
7 changed files with 59 additions and 53 deletions

View File

@ -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[];

View File

@ -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;
}

View File

@ -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',

View File

@ -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,
},
],
};

View File

@ -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,
}
],
};

View File

@ -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,

View File

@ -19,13 +19,8 @@ const Users: CollectionConfig = {
{
name: 'phoneNumber',
type: 'number',
required: true
required: false
},
{
name: 'email',
type: 'email',
required: true
}
],
};