Compare commits

...

26 Commits

Author SHA1 Message Date
8fb18ae000 Remove geopicker for now
All checks were successful
continuous-integration/drone/push Build is passing
2024-02-26 11:40:27 +01:00
0e1d640a42 make courier field required for dispatches
All checks were successful
continuous-integration/drone/push Build is passing
2024-02-26 00:26:04 +05:00
ac9b63a33a add sales point / exhibition place to retailers (#7)
All checks were successful
continuous-integration/drone/push Build is passing
2024-02-25 19:58:24 +05:00
ac387d41ad add courier fields (#10)
All checks were successful
continuous-integration/drone/push Build is passing
2024-02-25 19:52:11 +05:00
2654b4a9c4 add type of transporrt to dispatch 2024-02-25 19:41:00 +05:00
f152476d8f Set lon/lat on data fetch
All checks were successful
continuous-integration/drone/push Build is passing
2024-02-21 16:36:39 +01:00
26eb75646b Geopicker field saves correct values 2024-02-21 16:33:04 +01:00
8473d0d4d6 Create basic geolocation custom field 2024-02-21 13:07:31 +01:00
0d646c5d6b Change timeSensitive to bool
All checks were successful
continuous-integration/drone/push Build is passing
2024-02-20 11:03:22 +01:00
a74de768ac Add timeSensitive option for dispatch
All checks were successful
continuous-integration/drone/push Build is passing
2024-02-20 10:20:08 +01:00
cc5879e0a8 bumpt 2024-02-14 09:51:32 +01:00
afccda0eb9 Update documentation for local & prod setup
All checks were successful
continuous-integration/drone/push Build is passing
2024-01-24 16:57:22 +05:00
7f5b8e7aa5 create alternate docker compose file for local dev 2024-01-24 16:50:39 +05:00
5ac899e9d9 update readme
All checks were successful
continuous-integration/drone/push Build is passing
2024-01-23 20:21:29 +05:00
809db72f56 update dependencies and dockerfile
All checks were successful
continuous-integration/drone/push Build is passing
2024-01-23 19:58:44 +05:00
b4c79e8772 update dependencies
Some checks failed
continuous-integration/drone/push Build is failing
2024-01-23 19:24:26 +05:00
efdb0f2593 remove default login credentials 2024-01-23 19:21:32 +05:00
a91ce41978 add build folder to gitignore 2024-01-23 19:21:07 +05:00
4372e6592a Revert "change dispatches status from array to single value"
Some checks failed
continuous-integration/drone/push Build is failing
This reverts commit c683ad2752.
2024-01-19 18:00:34 +05:00
89a1f49ff6 add test login credentials
Some checks failed
continuous-integration/drone/push Build is failing
2024-01-11 14:52:39 +05:00
024267c5ca add test login credentials
Some checks failed
continuous-integration/drone/push Build is failing
2024-01-11 14:49:33 +05:00
c683ad2752 change dispatches status from array to single value
Some checks failed
continuous-integration/drone/push Build is failing
2023-01-31 14:59:01 +05:00
c373970058 bug: fix dispatches endpoint field to show retailers
All checks were successful
continuous-integration/drone/push Build is passing
2023-01-30 12:34:03 +05:00
105c068f62 Feat: adds couriers value display
All checks were successful
continuous-integration/drone/push Build is passing
2023-01-24 15:22:58 +01:00
e7db1595c8 adds env.example file
All checks were successful
continuous-integration/drone/push Build is passing
2023-01-24 15:15:54 +01:00
c8455ed31f makes sure the value titels are shown not just the ID's 2023-01-24 15:15:42 +01:00
17 changed files with 3468 additions and 1901 deletions

6
.env.example Normal file
View 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
View File

@ -38,6 +38,7 @@ bower_components
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
build/
# Dependency directories
node_modules/

1
.yarnrc.yml Normal file
View File

@ -0,0 +1 @@
nodeLinker: node-modules

View File

@ -1,4 +1,4 @@
FROM node:18-alpine as base
FROM node:21-bookworm as base
FROM base as builder

View File

@ -2,12 +2,24 @@
[![Build Status](https://drone.autonomic.zone/api/badges/ruangrupa/lumbung-kios-cms/status.svg?ref=refs/heads/main)](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
View 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:

View File

@ -15,16 +15,17 @@
"generate:graphQLSchema": "PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:graphQLSchema"
},
"dependencies": {
"payload": "^1.5.9",
"dotenv": "^8.2.0",
"express": "^4.17.1"
"express": "^4.17.1",
"payload": "^1.5.9",
"sharp": "^0.33.2"
},
"devDependencies": {
"@types/express": "^4.17.9",
"copyfiles": "^2.4.1",
"cross-env": "^7.0.3",
"nodemon": "^2.0.6",
"ts-node": "^9.1.1",
"copyfiles": "^2.4.1",
"typescript": "^4.8.4"
}
}

View File

@ -2,15 +2,43 @@ import { CollectionConfig } from 'payload/types';
const Couriers: CollectionConfig = {
slug: 'couriers',
admin: {
useAsTitle: 'name',
},
access: {
read: () => true,
},
fields: [
{
name: 'name', // required
type: 'text', // required
required: true,
},
name: 'name',
type: 'text',
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'
}
],
};

View File

@ -2,9 +2,9 @@ import { CollectionConfig } from 'payload/types';
const Dispatches: CollectionConfig = {
slug: 'dispatches',
// admin: {
// useAsTitle: 'email',
// },
admin: {
useAsTitle: 'dispatchesCode',
},
access: {
read: () => true,
},
@ -29,14 +29,42 @@ const Dispatches: CollectionConfig = {
{
name: 'endPoint',
type: 'relationship',
relationTo: 'makers',
relationTo: 'retailers',
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',
type: 'relationship',
relationTo: 'couriers',
hasMany: false,
required: true
},
{
name: 'timeSensitive',
type: 'checkbox',
},
{
name: 'status', // required
@ -64,4 +92,4 @@ const Dispatches: CollectionConfig = {
],
};
export default Dispatches;
export default Dispatches;

View File

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

View File

@ -1,10 +1,11 @@
import { CollectionConfig } from 'payload/types';
import { geoPickerField } from "../customFields/geoPicker/field";
const Makers: CollectionConfig = {
slug: 'makers',
// admin: {
// useAsTitle: 'email',
// },
admin: {
useAsTitle: 'name',
},
access: {
read: () => true,
},
@ -14,6 +15,7 @@ const Makers: CollectionConfig = {
type: 'text', // required
required: true,
},
//geoPickerField, is a bit broken right now
{
name: 'location',
type: 'point',

View File

@ -2,9 +2,9 @@ import { CollectionConfig } from 'payload/types';
const Products: CollectionConfig = {
slug: 'products',
// admin: {
// useAsTitle: 'email',
// },
admin: {
useAsTitle: 'productTitle',
},
access: {
read: () => true,
},

View File

@ -2,9 +2,9 @@ import { CollectionConfig } from 'payload/types';
const Retailers: CollectionConfig = {
slug: 'retailers',
// admin: {
// useAsTitle: 'email',
// },
admin: {
useAsTitle: 'name',
},
access: {
read: () => true,
},
@ -24,6 +24,11 @@ const Retailers: CollectionConfig = {
type: 'relationship', // required
relationTo: 'products', // required
hasMany: true,
},
{
name: 'salesPoint',
type: 'text',
label: 'Where do you plan to sell/exhibit products?'
}
],
};

View 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>
);
};

View 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,
},
},
}

View File

@ -16,7 +16,7 @@ payload.init({
express: app,
onInit: () => {
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`)
},
}
})
// Add your own express routes here

5101
yarn.lock

File diff suppressed because it is too large Load Diff