Feat: Adding the collections
This commit is contained in:
parent
bdf11ce3b6
commit
23a8bf752d
17
src/collections/Couriers.ts
Normal file
17
src/collections/Couriers.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { CollectionConfig } from 'payload/types';
|
||||
|
||||
const Couriers: CollectionConfig = {
|
||||
slug: 'couriers',
|
||||
access: {
|
||||
read: () => true,
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: 'name', // required
|
||||
type: 'text', // required
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default Couriers;
|
67
src/collections/Dispatches.ts
Normal file
67
src/collections/Dispatches.ts
Normal file
@ -0,0 +1,67 @@
|
||||
import { CollectionConfig } from 'payload/types';
|
||||
|
||||
const Dispatches: CollectionConfig = {
|
||||
slug: 'dispatches',
|
||||
// admin: {
|
||||
// useAsTitle: 'email',
|
||||
// },
|
||||
access: {
|
||||
read: () => true,
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: 'dispatchesCode',
|
||||
type: 'text',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: 'products',
|
||||
type: 'relationship',
|
||||
relationTo: 'products',
|
||||
hasMany: true,
|
||||
},
|
||||
{
|
||||
name: 'startingPoint',
|
||||
type: 'relationship',
|
||||
relationTo: 'makers',
|
||||
hasMany: false,
|
||||
},
|
||||
{
|
||||
name: 'endPoint',
|
||||
type: 'relationship',
|
||||
relationTo: 'makers',
|
||||
hasMany: false,
|
||||
},
|
||||
{
|
||||
name: 'courier',
|
||||
type: 'relationship',
|
||||
relationTo: 'couriers',
|
||||
hasMany: false,
|
||||
},
|
||||
{
|
||||
name: 'status', // required
|
||||
type: 'select', // required
|
||||
hasMany: true,
|
||||
// admin: {
|
||||
// isClearable: true,
|
||||
// isSortable: true, // use mouse to drag and drop different values, and sort them according to your choice
|
||||
// },
|
||||
options: [
|
||||
{
|
||||
label: 'Route requested',
|
||||
value: 'routeRequested',
|
||||
},
|
||||
{
|
||||
label: 'In transit',
|
||||
value: 'inTransit',
|
||||
},
|
||||
{
|
||||
label: 'Completed',
|
||||
value: 'completed',
|
||||
},
|
||||
],
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
export default Dispatches;
|
32
src/collections/Makers.ts
Normal file
32
src/collections/Makers.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import { CollectionConfig } from 'payload/types';
|
||||
|
||||
const Makers: CollectionConfig = {
|
||||
slug: 'makers',
|
||||
// admin: {
|
||||
// useAsTitle: 'email',
|
||||
// },
|
||||
access: {
|
||||
read: () => true,
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: 'name', // required
|
||||
type: 'text', // required
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: 'location',
|
||||
type: 'point',
|
||||
label: 'Location',
|
||||
},
|
||||
{
|
||||
name: 'products', // required
|
||||
type: 'relationship', // required
|
||||
relationTo: 'products', // required
|
||||
hasMany: true,
|
||||
// TODO: make the name of the product visible in the dropdown
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
export default Makers;
|
20
src/collections/Products.ts
Normal file
20
src/collections/Products.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { CollectionConfig } from 'payload/types';
|
||||
|
||||
const Products: CollectionConfig = {
|
||||
slug: 'products',
|
||||
// admin: {
|
||||
// useAsTitle: 'email',
|
||||
// },
|
||||
access: {
|
||||
read: () => true,
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: 'productTitle', // required
|
||||
type: 'text', // required
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default Products;
|
31
src/collections/Retailers.ts
Normal file
31
src/collections/Retailers.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import { CollectionConfig } from 'payload/types';
|
||||
|
||||
const Retailers: CollectionConfig = {
|
||||
slug: 'retailers',
|
||||
// admin: {
|
||||
// useAsTitle: 'email',
|
||||
// },
|
||||
access: {
|
||||
read: () => true,
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: 'name', // required
|
||||
type: 'text', // required
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: 'location',
|
||||
type: 'point',
|
||||
label: 'Location',
|
||||
},
|
||||
{
|
||||
name: 'products', // required
|
||||
type: 'relationship', // required
|
||||
relationTo: 'products', // required
|
||||
hasMany: true,
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
export default Retailers;
|
@ -2,6 +2,12 @@ import { buildConfig } from 'payload/config';
|
||||
import path from 'path';
|
||||
// import Examples from './collections/Examples';
|
||||
import Users from './collections/Users';
|
||||
import Couriers from './collections/Couriers';
|
||||
import Dispatches from './collections/Dispatches';
|
||||
import Makers from './collections/Makers';
|
||||
import Products from './collections/Products';
|
||||
import Retailers from './collections/Retailers';
|
||||
|
||||
|
||||
export default buildConfig({
|
||||
serverURL: 'http://localhost:3000',
|
||||
@ -10,8 +16,11 @@ export default buildConfig({
|
||||
},
|
||||
collections: [
|
||||
Users,
|
||||
// Add Collections here
|
||||
// Examples,
|
||||
Couriers,
|
||||
Dispatches,
|
||||
Makers,
|
||||
Products,
|
||||
Retailers,
|
||||
],
|
||||
typescript: {
|
||||
outputFile: path.resolve(__dirname, 'payload-types.ts'),
|
||||
|
Loading…
Reference in New Issue
Block a user