Compare commits
26 Commits
6836f05d06
...
main
Author | SHA1 | Date | |
---|---|---|---|
8fb18ae000 | |||
0e1d640a42 | |||
ac9b63a33a | |||
ac387d41ad | |||
2654b4a9c4 | |||
f152476d8f | |||
26eb75646b | |||
8473d0d4d6 | |||
0d646c5d6b | |||
a74de768ac | |||
cc5879e0a8 | |||
afccda0eb9 | |||
7f5b8e7aa5 | |||
5ac899e9d9 | |||
809db72f56 | |||
b4c79e8772 | |||
efdb0f2593 | |||
a91ce41978 | |||
4372e6592a | |||
89a1f49ff6 | |||
024267c5ca | |||
c683ad2752 | |||
c373970058 | |||
105c068f62 | |||
e7db1595c8 | |||
c8455ed31f |
6
.env.example
Normal file
6
.env.example
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
MONGODB_URI=
|
||||||
|
PAYLOAD_SECRET=
|
||||||
|
# local
|
||||||
|
PAYLOAD_PUBLIC_SERVER_URL=http://localhost:3000
|
||||||
|
# Production
|
||||||
|
# PAYLOAD_PUBLIC_SERVER_URL=https://kios-admin.lumbung.space
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -38,6 +38,7 @@ bower_components
|
|||||||
|
|
||||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
build/Release
|
build/Release
|
||||||
|
build/
|
||||||
|
|
||||||
# Dependency directories
|
# Dependency directories
|
||||||
node_modules/
|
node_modules/
|
||||||
|
1
.yarnrc.yml
Normal file
1
.yarnrc.yml
Normal file
@ -0,0 +1 @@
|
|||||||
|
nodeLinker: node-modules
|
@ -1,4 +1,4 @@
|
|||||||
FROM node:18-alpine as base
|
FROM node:21-bookworm as base
|
||||||
|
|
||||||
FROM base as builder
|
FROM base as builder
|
||||||
|
|
||||||
|
22
README.md
22
README.md
@ -2,12 +2,24 @@
|
|||||||
|
|
||||||
[](https://drone.autonomic.zone/ruangrupa/lumbung-kios-cms)
|
[](https://drone.autonomic.zone/ruangrupa/lumbung-kios-cms)
|
||||||
|
|
||||||
This project was created using create-payload-app using the ts-blank template.
|
This project was created using `npx create-payload-app` using the ts-blank template.
|
||||||
|
|
||||||
## How to Use
|
## Local development
|
||||||
|
|
||||||
`yarn dev` will start up your application and reload on any changes.
|
- First, create a `.env` file in the root, and populate it with these values:
|
||||||
|
|
||||||
## Deploy
|
```
|
||||||
|
MONGODB_URI=mongodb://mongo:27017/lumbung-kios-cms
|
||||||
|
PAYLOAD_SECRET=5c8ac4a2cd754247f38ae726
|
||||||
|
PAYLOAD_PUBLIC_SERVER_URL=http://localhost:3000
|
||||||
|
```
|
||||||
|
|
||||||
|
- Run `docker-compose -f docker-compose-local.yml up` to get the application running locally.
|
||||||
|
- The application will have no data by default, so you will have to create your own test products, couriers, retailers, dispatches, and makers.
|
||||||
|
|
||||||
|
## Deployment & production setup
|
||||||
|
|
||||||
|
Push commits, it will auto-deploy to [kios-admin.lumbung.space](https://kios-admin.lumbung.space). CI/CD is powered by [Drone](https://drone.autonomic.zone/ruangrupa/lumbung-kios-cms), it uses the `Dockerfile` in the root project folder for builds. You can test builds locally using `docker build .`.
|
||||||
|
|
||||||
|
The application is running on the `ruangrupa-dedi` server as a vanilla Docker swarm stack.
|
||||||
|
|
||||||
Push commits, it will auto-deploy to [kios-admin.lumbung.space](https://kios-admin.lumbung.space).
|
|
||||||
|
31
docker-compose-local.yml
Normal file
31
docker-compose-local.yml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
payload:
|
||||||
|
image: node:21-bookworm
|
||||||
|
ports:
|
||||||
|
- '3000:3000'
|
||||||
|
volumes:
|
||||||
|
- .:/home/node/app
|
||||||
|
- node_modules:/home/node/app/node_modules
|
||||||
|
working_dir: /home/node/app/
|
||||||
|
command: sh -c "yarn install && yarn dev"
|
||||||
|
depends_on:
|
||||||
|
- mongo
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
|
||||||
|
mongo:
|
||||||
|
image: mongo:latest
|
||||||
|
ports:
|
||||||
|
- '27017:27017'
|
||||||
|
command:
|
||||||
|
- --storageEngine=wiredTiger
|
||||||
|
volumes:
|
||||||
|
- data:/data/db
|
||||||
|
logging:
|
||||||
|
driver: none
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
data:
|
||||||
|
node_modules:
|
@ -15,16 +15,17 @@
|
|||||||
"generate:graphQLSchema": "PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:graphQLSchema"
|
"generate:graphQLSchema": "PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:graphQLSchema"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"payload": "^1.5.9",
|
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"express": "^4.17.1"
|
"express": "^4.17.1",
|
||||||
|
"payload": "^1.5.9",
|
||||||
|
"sharp": "^0.33.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/express": "^4.17.9",
|
"@types/express": "^4.17.9",
|
||||||
|
"copyfiles": "^2.4.1",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"nodemon": "^2.0.6",
|
"nodemon": "^2.0.6",
|
||||||
"ts-node": "^9.1.1",
|
"ts-node": "^9.1.1",
|
||||||
"copyfiles": "^2.4.1",
|
|
||||||
"typescript": "^4.8.4"
|
"typescript": "^4.8.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,43 @@ import { CollectionConfig } from 'payload/types';
|
|||||||
|
|
||||||
const Couriers: CollectionConfig = {
|
const Couriers: CollectionConfig = {
|
||||||
slug: 'couriers',
|
slug: 'couriers',
|
||||||
|
admin: {
|
||||||
|
useAsTitle: 'name',
|
||||||
|
},
|
||||||
access: {
|
access: {
|
||||||
read: () => true,
|
read: () => true,
|
||||||
},
|
},
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: 'name', // required
|
name: 'name',
|
||||||
type: 'text', // required
|
type: 'text',
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'startingPoint',
|
||||||
|
label: 'Traveling from',
|
||||||
|
type: 'text', // TODO use geopicker here
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'destination',
|
||||||
|
label: 'Traveling to',
|
||||||
|
type: 'text' // TODO user geopicker here
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'departureDate',
|
||||||
|
label: 'Departure date',
|
||||||
|
type: 'date'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'arrivalDate',
|
||||||
|
label: 'Arrival date',
|
||||||
|
type: 'date'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'weightAllowance',
|
||||||
|
label: 'Weight Allowance (KG)',
|
||||||
|
type: 'number'
|
||||||
|
}
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,9 +2,9 @@ import { CollectionConfig } from 'payload/types';
|
|||||||
|
|
||||||
const Dispatches: CollectionConfig = {
|
const Dispatches: CollectionConfig = {
|
||||||
slug: 'dispatches',
|
slug: 'dispatches',
|
||||||
// admin: {
|
admin: {
|
||||||
// useAsTitle: 'email',
|
useAsTitle: 'dispatchesCode',
|
||||||
// },
|
},
|
||||||
access: {
|
access: {
|
||||||
read: () => true,
|
read: () => true,
|
||||||
},
|
},
|
||||||
@ -29,14 +29,42 @@ const Dispatches: CollectionConfig = {
|
|||||||
{
|
{
|
||||||
name: 'endPoint',
|
name: 'endPoint',
|
||||||
type: 'relationship',
|
type: 'relationship',
|
||||||
relationTo: 'makers',
|
relationTo: 'retailers',
|
||||||
hasMany: false,
|
hasMany: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'typeOfTransportation',
|
||||||
|
type: 'select',
|
||||||
|
hasMany: true,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: 'Air',
|
||||||
|
value: 'air'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Car',
|
||||||
|
value: 'car'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Train',
|
||||||
|
value: 'train'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Boat',
|
||||||
|
value: 'boat'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'courier',
|
name: 'courier',
|
||||||
type: 'relationship',
|
type: 'relationship',
|
||||||
relationTo: 'couriers',
|
relationTo: 'couriers',
|
||||||
hasMany: false,
|
hasMany: false,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'timeSensitive',
|
||||||
|
type: 'checkbox',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'status', // required
|
name: 'status', // required
|
||||||
@ -64,4 +92,4 @@ const Dispatches: CollectionConfig = {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Dispatches;
|
export default Dispatches;
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
import { CollectionConfig } from 'payload/types';
|
|
||||||
|
|
||||||
// Example Collection - For reference only, this must be added to payload.config.ts to be used.
|
|
||||||
const Examples: CollectionConfig = {
|
|
||||||
slug: 'examples',
|
|
||||||
admin: {
|
|
||||||
useAsTitle: 'someField',
|
|
||||||
},
|
|
||||||
fields: [
|
|
||||||
{
|
|
||||||
name: 'someField',
|
|
||||||
type: 'text',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Examples;
|
|
@ -1,10 +1,11 @@
|
|||||||
import { CollectionConfig } from 'payload/types';
|
import { CollectionConfig } from 'payload/types';
|
||||||
|
import { geoPickerField } from "../customFields/geoPicker/field";
|
||||||
|
|
||||||
const Makers: CollectionConfig = {
|
const Makers: CollectionConfig = {
|
||||||
slug: 'makers',
|
slug: 'makers',
|
||||||
// admin: {
|
admin: {
|
||||||
// useAsTitle: 'email',
|
useAsTitle: 'name',
|
||||||
// },
|
},
|
||||||
access: {
|
access: {
|
||||||
read: () => true,
|
read: () => true,
|
||||||
},
|
},
|
||||||
@ -14,6 +15,7 @@ const Makers: CollectionConfig = {
|
|||||||
type: 'text', // required
|
type: 'text', // required
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
//geoPickerField, is a bit broken right now
|
||||||
{
|
{
|
||||||
name: 'location',
|
name: 'location',
|
||||||
type: 'point',
|
type: 'point',
|
||||||
|
@ -2,9 +2,9 @@ import { CollectionConfig } from 'payload/types';
|
|||||||
|
|
||||||
const Products: CollectionConfig = {
|
const Products: CollectionConfig = {
|
||||||
slug: 'products',
|
slug: 'products',
|
||||||
// admin: {
|
admin: {
|
||||||
// useAsTitle: 'email',
|
useAsTitle: 'productTitle',
|
||||||
// },
|
},
|
||||||
access: {
|
access: {
|
||||||
read: () => true,
|
read: () => true,
|
||||||
},
|
},
|
||||||
|
@ -2,9 +2,9 @@ import { CollectionConfig } from 'payload/types';
|
|||||||
|
|
||||||
const Retailers: CollectionConfig = {
|
const Retailers: CollectionConfig = {
|
||||||
slug: 'retailers',
|
slug: 'retailers',
|
||||||
// admin: {
|
admin: {
|
||||||
// useAsTitle: 'email',
|
useAsTitle: 'name',
|
||||||
// },
|
},
|
||||||
access: {
|
access: {
|
||||||
read: () => true,
|
read: () => true,
|
||||||
},
|
},
|
||||||
@ -24,6 +24,11 @@ const Retailers: CollectionConfig = {
|
|||||||
type: 'relationship', // required
|
type: 'relationship', // required
|
||||||
relationTo: 'products', // required
|
relationTo: 'products', // required
|
||||||
hasMany: true,
|
hasMany: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'salesPoint',
|
||||||
|
type: 'text',
|
||||||
|
label: 'Where do you plan to sell/exhibit products?'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
68
src/customFields/geoPicker/GeoPicker.tsx
Normal file
68
src/customFields/geoPicker/GeoPicker.tsx
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
import * as React from 'react';
|
||||||
|
import { useField } from 'payload/components/forms';
|
||||||
|
|
||||||
|
export const GeoPicker: React.FC<{ path: string }> = ({ path }) => {
|
||||||
|
const { value, setValue } = useField<string>({ path });
|
||||||
|
const [longitude, setLongitude] = React.useState(value[0] || 0);
|
||||||
|
const [latitude, setLatitude] = React.useState(value[1] || 0);
|
||||||
|
const [error, setError] = React.useState("")
|
||||||
|
|
||||||
|
const handleCityEnter = async (e) => {
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
try {
|
||||||
|
const response = await fetch(
|
||||||
|
`https://nominatim.openstreetmap.org/search?format=json&q=${e.target.value}`
|
||||||
|
);
|
||||||
|
const data = await response.json();
|
||||||
|
if (data && data.length > 0) {
|
||||||
|
const { lat, lon } = data[0];
|
||||||
|
setLatitude(lat);
|
||||||
|
setLongitude(lon);
|
||||||
|
setValue([lon, lat]);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
setError(e)
|
||||||
|
console.error('Error fetching geolocation:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleLatitudeChange = (e) => {
|
||||||
|
setLatitude(e.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleLongitudeChange = (e) => {
|
||||||
|
setLongitude(e.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className='field-type text'>
|
||||||
|
<label className='field-label'>
|
||||||
|
City
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className='field-name'
|
||||||
|
onKeyDown={handleCityEnter}
|
||||||
|
placeholder="Enter city to get coordinates"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{error != "" &&
|
||||||
|
<p>{error}</p>
|
||||||
|
}
|
||||||
|
<div className="field-type point">
|
||||||
|
<ul className='point__wrap'>
|
||||||
|
<li>
|
||||||
|
<label className='field-label'>Location - Longitude</label>
|
||||||
|
<input id="field-longitude-location" type="number" name="location.longitude" value={longitude} onChange={handleLongitudeChange}></input>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<label className='field-label'>Location - Latitude</label>
|
||||||
|
<input id="field-latitude-latitude" type="number" name="location.latitude" value={latitude} onChange={handleLatitudeChange}></input>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
12
src/customFields/geoPicker/field.ts
Normal file
12
src/customFields/geoPicker/field.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { PointField } from 'payload/types';
|
||||||
|
import { GeoPicker } from './GeoPicker';
|
||||||
|
|
||||||
|
export const geoPickerField: PointField = {
|
||||||
|
name: 'Location',
|
||||||
|
type: 'point',
|
||||||
|
admin: {
|
||||||
|
components: {
|
||||||
|
Field: GeoPicker,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
@ -16,7 +16,7 @@ payload.init({
|
|||||||
express: app,
|
express: app,
|
||||||
onInit: () => {
|
onInit: () => {
|
||||||
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`)
|
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`)
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Add your own express routes here
|
// Add your own express routes here
|
||||||
|
Reference in New Issue
Block a user