Complete basic request dispatch flow
continuous-integration/drone/push Build is passing Details

This commit is contained in:
toqvist 2024-04-07 19:40:38 +02:00
parent 00cf0d9905
commit 9be7ae81ae
11 changed files with 264 additions and 163 deletions

View File

@ -19,6 +19,7 @@
"@radix-ui/react-label": "^2.0.2", "@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-slot": "^1.0.2",
"@tanstack/react-query": "^5.28.14", "@tanstack/react-query": "^5.28.14",
"@tanstack/react-query-devtools": "^5.29.0",
"@types/leaflet": "^1.9.8", "@types/leaflet": "^1.9.8",
"@types/react": "^18.2.74", "@types/react": "^18.2.74",
"@types/react-dom": "^18.2.23", "@types/react-dom": "^18.2.23",
@ -27,6 +28,7 @@
"class-variance-authority": "^0.7.0", "class-variance-authority": "^0.7.0",
"clsx": "^2.1.0", "clsx": "^2.1.0",
"css-select": "5.1.0", "css-select": "5.1.0",
"human-id": "^4.1.1",
"leaflet": "^1.9.4", "leaflet": "^1.9.4",
"lucide-react": "^0.364.0", "lucide-react": "^0.364.0",
"react": "^18.2.0", "react": "^18.2.0",

View File

@ -44,6 +44,7 @@ export interface Maker extends Node {
stock: Product[]; stock: Product[];
createdAt: string; createdAt: string;
updatedAt: string; updatedAt: string;
admins: User[];
}; };
export interface Retailer extends Node { export interface Retailer extends Node {
@ -53,16 +54,17 @@ export interface Retailer extends Node {
stock: Product[]; stock: Product[];
createdAt: string; createdAt: string;
updatedAt: string; updatedAt: string;
admins: User[];
}; };
const DISPATCH_STATUS = ['requested', 'accepted', 'archived'] as const; const DISPATCH_STATUS = ['requested', 'accepted', 'archived'] as const;
export type DispatchStatus = typeof DISPATCH_STATUS[number]; export type DispatchStatus = typeof DISPATCH_STATUS[number];
export interface Dispatch { export interface Dispatch {
id: string; id?: string;
dispatchesCode?: string; //Human readable id code?: string; //Human readable id
createdAt: string; createdAt?: string;
updatedAt: string; updatedAt?: string;
maker: Maker; maker: Maker;
retailer: Retailer; retailer: Retailer;
@ -73,8 +75,19 @@ export interface Dispatch {
timeSensitive: boolean; timeSensitive: boolean;
status: DispatchStatus; status: DispatchStatus;
departureDate: string; departureDate?: string;
arrivalDate: string; arrivalDate?: string;
weightAllowance: number;
} }
export interface CreateDispatch {
code?: string; //Human readable id
maker: Maker | string;
retailer: Retailer | string;
products: Product[] | string[] ;
courier?: User;
timeSensitive: boolean;
status: DispatchStatus;
}

View File

@ -1,6 +1,8 @@
import { useQuery, useMutation, useQueryClient, queryOptions, QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { useQuery, useMutation, useQueryClient, queryOptions, QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
import type { ReactNode } from "react"; import type { ReactNode } from "react";
import { KiosMap } from "@/components/KiosMap" import { KiosMap } from "@/components/KiosMap";
export const queryClient = new QueryClient({ export const queryClient = new QueryClient({
defaultOptions: { defaultOptions: {
@ -18,6 +20,7 @@ export const App: React.FC<AppProps> = (props) => {
return ( return (
<div className="app"> <div className="app">
<QueryClientProvider client={queryClient}> <QueryClientProvider client={queryClient}>
<ReactQueryDevtools initialIsOpen={false} />
{props.children} {props.children}
<KiosMap/> <KiosMap/>
</QueryClientProvider> </QueryClientProvider>

View File

@ -3,13 +3,15 @@ import { MapContainer, TileLayer, Marker, CircleMarker, Popup, Polyline, LayerGr
import 'leaflet/dist/leaflet.css'; import 'leaflet/dist/leaflet.css';
import L, { LatLngBounds } from 'leaflet'; import L, { LatLngBounds } from 'leaflet';
import Contacts from './Contacts'; import Contacts from './Contacts';
import type { User, Node, Retailer, Maker, Product, Dispatch, DispatchStatus } from '../astroTypes'; import type { User, Node, Retailer, Maker, Product, Dispatch, DispatchStatus, CreateDispatch } from '../astroTypes';
import { useQuery, useMutation, useQueryClient, queryOptions } from "@tanstack/react-query"; import { useQuery, useMutation, useQueryClient, queryOptions } from "@tanstack/react-query";
import { useGetMakers, useGetDispatches, useGetRetailers, useGetUser, useGetMyself } from "../utils/hooks" import { useGetMakers, useGetDispatches, useGetRetailers, useGetUser, useGetMyself, API_URL, useGetMyRetailers, useCreateDispatch } from "../utils/hooks"
import { Button, buttonVariants } from './ui/Button'; import { Button, buttonVariants } from './ui/Button';
import { humanId, poolSize, minLength, maxLength } from 'human-id'
import { import {
Dialog, Dialog,
DialogContent, DialogContent,
@ -21,7 +23,7 @@ import {
import { LoginForm } from './LoginForm'; import { LoginForm } from './LoginForm';
import { hasAuthCookie } from '@/utils/authUtils'; import { hasAuthCookie } from '@/utils/authUtils';
//Payload longitude and latitude are mislabeled in payload (lol) //Payload longitude and latitude are mislabeled/switched in payload
const locationSwitcharoo = (location: number[]) => { const locationSwitcharoo = (location: number[]) => {
if (location.length === 2) { if (location.length === 2) {
const correctedLocation = [location[1], location[0]] const correctedLocation = [location[1], location[0]]
@ -59,13 +61,16 @@ interface NodeSelection {
export const KiosMap = () => { export const KiosMap = () => {
const [authToken, setAuthToken] = useState('') const [authToken, setAuthToken] = useState<string>('')
const { data: makers, isLoading: isLoadingMakers } = useGetMakers(); const { data: makers, isLoading: isLoadingMakers } = useGetMakers();
const { data: retailers, isLoading: isLoadingRetailers } = useGetRetailers(); const { data: retailers, isLoading: isLoadingRetailers } = useGetRetailers();
const { data: dispatches, isLoading: isLoadingDispatches } = useGetDispatches(); const { data: dispatches, isLoading: isLoadingDispatches } = useGetDispatches();
const { data: myself, isLoading: isLoadingMyself } = useGetMyself(authToken); const { data: myself, isLoading: isLoadingMyself } = useGetMyself(authToken);
const { data: myRetailers, isLoading: isLoadingMyRetailers } = useGetMyRetailers(myself);
const createDispatchMutation = useCreateDispatch();
const [selectedNode, setSelectedNode] = useState<NodeSelection>({ id: "", type: "none" }) const [selectedNode, setSelectedNode] = useState<NodeSelection>({ id: "", type: "none" })
@ -88,7 +93,6 @@ export const KiosMap = () => {
const handleSelectNode = (nodeId: string, typeParam: "maker" | "retailer" | "dispatch" | "none") => { const handleSelectNode = (nodeId: string, typeParam: "maker" | "retailer" | "dispatch" | "none") => {
setSelectedNode({ id: nodeId, type: typeParam }) setSelectedNode({ id: nodeId, type: typeParam })
console.log("set id:", nodeId)
} }
//params: dispatch: Dispatch, courier: User //params: dispatch: Dispatch, courier: User
@ -96,12 +100,24 @@ export const KiosMap = () => {
} }
const handleOpenCatalogue = () => { const handleRequestDispatch = (products: Product[], retailer: Retailer, maker: Maker | undefined) => {
} if (maker === undefined) {
console.error("Request dispatch error: Marker undefined")
//params return
const handleRequestProduct = () => { }
const dispatch: CreateDispatch = {
code: humanId({
separator: '-',
capitalize: false,
}),
products: products.map((product) => {return product.id}),
maker: maker.id,
retailer: retailer.id,
timeSensitive: false,
status: "requested",
}
console.log(dispatch)
createDispatchMutation.mutate(dispatch)
} }
const blackDotIcon = L.divIcon({ const blackDotIcon = L.divIcon({
@ -131,26 +147,22 @@ export const KiosMap = () => {
width={120} width={120}
src="/kios-logo.png" src="/kios-logo.png"
alt="" /> alt="" />
{(myself && myself.name)
?
<p>Logged in as: {myself.name}</p>
: <p>Logged in</p>
}
{ {
(!hasAuthCookie() && !authToken) && (!hasAuthCookie() && !authToken) ?
<DialogTrigger <DialogTrigger
className={`px-14 w-6 ${buttonVariants({ variant: "kios" })}`} className={`px-12 ${buttonVariants({ variant: "kios" })}`}
> >
Login Login
</DialogTrigger> </DialogTrigger>
: myself && <p>Logged in as: {myself?.name}</p>
} }
</div> </div>
<DialogContent> <DialogContent>
<DialogHeader> <DialogHeader>
<DialogTitle className="text-4xl text-center">Login</DialogTitle> <DialogTitle className="text-4xl text-center">Login</DialogTitle>
<LoginForm setAuthToken={setAuthToken} authToken={authToken}/> <LoginForm setAuthToken={setAuthToken} authToken={authToken} />
</DialogHeader> </DialogHeader>
</DialogContent> </DialogContent>
</Dialog> </Dialog>
@ -173,7 +185,7 @@ export const KiosMap = () => {
phoneNumber={selectedMaker.phoneNumber} phoneNumber={selectedMaker.phoneNumber}
role={'maker'} role={'maker'}
/> />
{(selectedMaker.stock !== undefined && selectedMaker.stock.length > 0) && {(selectedMaker !== undefined && selectedMaker.stock !== undefined && selectedMaker.stock.length > 0) &&
<Dialog> <Dialog>
<DialogTrigger <DialogTrigger
className={buttonVariants({ variant: "kios" })} className={buttonVariants({ variant: "kios" })}
@ -187,7 +199,7 @@ export const KiosMap = () => {
<ul className='flex flex-col gap-4'> <ul className='flex flex-col gap-4'>
{selectedMaker.stock.map((product, i) => { {selectedMaker.stock.map((product, i) => {
return ( return (
<li className="flex flex-row gap-4"> <li className="flex flex-row gap-4" key={product.id}>
{product.picture.url && {product.picture.url &&
<img <img
width={160} width={160}
@ -202,13 +214,24 @@ export const KiosMap = () => {
<p className='text-black text-lg' <p className='text-black text-lg'
>Weight: {product.weight}</p> >Weight: {product.weight}</p>
} }
<Button {myself ?
variant={'kios'} (myRetailers !== undefined) &&
className='w-full mt-6' <ul>
onClick={() => handleRequestProduct()} {myRetailers.map((retailer, i) => {
> return (
Request product <li key={retailer.id}>
</Button> <Button
variant="kios"
onClick={() => handleRequestDispatch([product], retailer, selectedMaker)}
>
Request product to {retailer.name}
</Button>
</li>
)
})}
</ul>
: <Button disabled>Login to request</Button>
}
</div> </div>
</li> </li>
) )
@ -240,7 +263,7 @@ export const KiosMap = () => {
</h2> </h2>
{selectedDispatch.products.map((product, i) => { {selectedDispatch.products.map((product, i) => {
return ( return (
<div className='flex flex-row items-center gap-4'> <div className='flex flex-row items-center gap-4' key={product.id}>
<img <img
src={product.picture.url} src={product.picture.url}
alt={product.picture.alt} alt={product.picture.alt}
@ -269,7 +292,6 @@ export const KiosMap = () => {
/> />
{selectedDispatch.courier !== undefined ? ( {selectedDispatch.courier !== undefined ? (
<Contacts <Contacts
name={selectedDispatch.courier.name} name={selectedDispatch.courier.name}
email={selectedDispatch.courier.email} email={selectedDispatch.courier.email}

View File

@ -15,8 +15,7 @@ import {
import { Input } from "@/components/ui/input" import { Input } from "@/components/ui/input"
import axios from "axios"; import axios from "axios";
import { setAuthCookie } from "@/utils/authUtils" import { setAuthCookie } from "@/utils/authUtils"
import { API_URL } from "@/utils/hooks"
const API_URL = "http://localhost:3001";
const headers = { const headers = {
"Content-Type": "application/json", "Content-Type": "application/json",

View File

@ -9,7 +9,7 @@ const buttonVariants = cva(
{ {
variants: { variants: {
variant: { variant: {
kios: "text-black border-2 border-gray-950 py-2 px-4 w-full hover:bg-gray-950 transition-all hover:text-white hover:font-bold rounded-none", kios: "text-black border-2 border-gray-950 py-2 px-4 hover:bg-gray-950 transition-all hover:text-white hover:font-bold rounded-none",
default: "bg-primary text-primary-foreground hover:bg-primary/90", default: "bg-primary text-primary-foreground hover:bg-primary/90",
destructive: destructive:
"bg-destructive text-destructive-foreground hover:bg-destructive/90", "bg-destructive text-destructive-foreground hover:bg-destructive/90",

View File

@ -54,10 +54,13 @@ export interface Dispatch {
id: string; id: string;
code: string; code: string;
products: string[] | Product[]; products: string[] | Product[];
courier?: string | Courier; courier?: string | User;
maker: string | Maker; maker: string | Maker;
retailer: string | Retailer; retailer: string | Retailer;
status: 'requested' | 'accepted' | 'archived'; status: 'requested' | 'accepted' | 'archived';
departure?: string;
arrival?: string;
timeSensitive?: boolean;
updatedAt: string; updatedAt: string;
createdAt: string; createdAt: string;
} }

View File

@ -1,21 +1,20 @@
import type { User, Node, Retailer, Maker, Product, Dispatch } from '../astroTypes'; import type { User, Node, Retailer, Maker, Product, Dispatch, CreateDispatch } from '../astroTypes';
import { useQuery, useMutation, useQueryClient, queryOptions } from "@tanstack/react-query"; import { useQuery, useMutation, useQueryClient, queryOptions } from "@tanstack/react-query";
import axios from "axios"; import axios from "axios";
import { hasAuthCookie } from './authUtils'; import { hasAuthCookie } from './authUtils';
import { queryClient } from '@/components/App';
const API_URL = "http://localhost:3001" export const API_URL = "http://localhost:3001"
const nonAuthHeaders = { const headers = {
"Content-Type": "application/json", "Content-Type": "application/json",
} }
const getMakers = async () => { const getMakers = async () => {
const url = `${API_URL}/api/makers` const url = `${API_URL}/api/makers`
console.log("Fetching url:", url)
const response = await axios.get(url); const response = await axios.get(url);
const makers: Maker[] = response.data.docs; const makers: Maker[] = response.data.docs;
console.log(`Fetch result from ${url}`, makers)
return makers; return makers;
} }
@ -30,11 +29,9 @@ export const useGetMakers = () => {
const getRetailers = async () => { const getRetailers = async () => {
const url = `${API_URL}/api/retailers` const url = `${API_URL}/api/retailers`
console.log("Fetching url:", url)
const response = await axios.get(url); const response = await axios.get(url);
const retailers: Retailer[] = response.data.docs; const retailers: Retailer[] = response.data.docs;
console.log(`Fetch result from ${url}`, retailers)
return retailers; return retailers;
} }
@ -49,11 +46,9 @@ export const useGetRetailers = () => {
const getUser = async (userId: string) => { const getUser = async (userId: string) => {
const url = `${API_URL}/api/users/${userId}` const url = `${API_URL}/api/users/${userId}`
console.log("Fetching url:", url)
const response = await axios.get(url); const response = await axios.get(url);
const user: User = response.data.docs; const user: User = response.data.docs;
console.log(`Fetch result from ${url}`, user)
return user; return user;
} }
@ -68,7 +63,6 @@ export const useGetUser = (userId: string) => {
const getMyself = async (authToken: string) => { const getMyself = async (authToken: string) => {
const url = `${API_URL}/api/users/me` const url = `${API_URL}/api/users/me`
console.log("Fetching url:", url)
const authHeaders = { const authHeaders = {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -81,8 +75,7 @@ const getMyself = async (authToken: string) => {
headers: authHeaders headers: authHeaders
}); });
const user: User = response.data const user: User = response.data.user
console.log(`Fetch result from ${url}`, user)
return user; return user;
} }
@ -97,12 +90,9 @@ export const useGetMyself = (authToken: string) => {
const getDispatches = async () => { const getDispatches = async () => {
const url = `${API_URL}/api/dispatches` const url = `${API_URL}/api/dispatches`
console.log("Fetching url:", url)
const response = await axios.get(url); const response = await axios.get(url);
const dispatches: Dispatch[] = response.data.docs; const dispatches: Dispatch[] = response.data.docs;
console.log(`Fetch result from ${url}`, dispatches)
return dispatches; return dispatches;
} }
@ -113,4 +103,58 @@ export const useGetDispatches = () => {
queryKey: ['dispatches'], queryKey: ['dispatches'],
enabled: true enabled: true
}) })
}
const createDispatch = async (dispatch: CreateDispatch) => {
const url = `${API_URL}/api/dispatches`;
return await axios.post(url, dispatch);
};
export const useCreateDispatch = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (dispatch: CreateDispatch) => createDispatch(dispatch),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: ['dispatches'] });
},
mutationKey: ["createDispatch"]
})
};
const getRetailersByAdminId = async (user: User | undefined) => {
if(user === undefined) {
console.error("getMyRetailers error: user undefined")
return []
}
const adminId = user.id
const url = `${API_URL}/api/retailers`
const response = await axios.get(url);
const retailers: Retailer[] = response.data.docs;
let myRetailers: Retailer[] = []
for (let retailer of retailers) {
console.log(retailer)
if(retailer.admins) {
for (let admin of retailer.admins) {
console.log(admin)
if(admin.id === adminId) {
myRetailers.push(retailer)
}
}
}
}
console.log("myRetailers:", myRetailers)
return myRetailers;
}
export const useGetMyRetailers = (user: User | undefined) => {
return useQuery<Retailer[]>({
queryFn: () => getRetailersByAdminId(user),
queryKey: ['myRetailers'],
enabled: (user !== undefined)
})
} }

View File

@ -814,80 +814,80 @@
resolved "https://registry.yarnpkg.com/@react-leaflet/core/-/core-2.1.0.tgz#383acd31259d7c9ae8fb1b02d5e18fe613c2a13d" resolved "https://registry.yarnpkg.com/@react-leaflet/core/-/core-2.1.0.tgz#383acd31259d7c9ae8fb1b02d5e18fe613c2a13d"
integrity sha512-Qk7Pfu8BSarKGqILj4x7bCSZ1pjuAPZ+qmRwH5S7mDS91VSbVVsJSrW4qA+GPrro8t69gFYVMWb1Zc4yFmPiVg== integrity sha512-Qk7Pfu8BSarKGqILj4x7bCSZ1pjuAPZ+qmRwH5S7mDS91VSbVVsJSrW4qA+GPrro8t69gFYVMWb1Zc4yFmPiVg==
"@rollup/rollup-android-arm-eabi@4.14.0": "@rollup/rollup-android-arm-eabi@4.14.1":
version "4.14.0" version "4.14.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.14.0.tgz#57936f50d0335e2e7bfac496d209606fa516add4" resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.14.1.tgz#ca0501dd836894216cb9572848c5dde4bfca3bec"
integrity sha512-jwXtxYbRt1V+CdQSy6Z+uZti7JF5irRKF8hlKfEnF/xJpcNGuuiZMBvuoYM+x9sr9iWGnzrlM0+9hvQ1kgkf1w== integrity sha512-fH8/o8nSUek8ceQnT7K4EQbSiV7jgkHq81m9lWZFIXjJ7lJzpWXbQFpT/Zh6OZYnpFykvzC3fbEvEAFZu03dPA==
"@rollup/rollup-android-arm64@4.14.0": "@rollup/rollup-android-arm64@4.14.1":
version "4.14.0" version "4.14.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.14.0.tgz#81bba83b37382a2d0e30ceced06c8d3d85138054" resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.14.1.tgz#154ca7e4f815d2e442ffc62ee7f64aee8b2547b0"
integrity sha512-fI9nduZhCccjzlsA/OuAwtFGWocxA4gqXGTLvOyiF8d+8o0fZUeSztixkYjcGq1fGZY3Tkq4yRvHPFxU+jdZ9Q== integrity sha512-Y/9OHLjzkunF+KGEoJr3heiD5X9OLa8sbT1lm0NYeKyaM3oMhhQFvPB0bNZYJwlq93j8Z6wSxh9+cyKQaxS7PQ==
"@rollup/rollup-darwin-arm64@4.14.0": "@rollup/rollup-darwin-arm64@4.14.1":
version "4.14.0" version "4.14.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.14.0.tgz#a371bd723a5c4c4a33376da72abfc3938066842b" resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.14.1.tgz#02b522ab6ccc2c504634651985ff8e657b42c055"
integrity sha512-BcnSPRM76/cD2gQC+rQNGBN6GStBs2pl/FpweW8JYuz5J/IEa0Fr4AtrPv766DB/6b2MZ/AfSIOSGw3nEIP8SA== integrity sha512-+kecg3FY84WadgcuSVm6llrABOdQAEbNdnpi5X3UwWiFVhZIZvKgGrF7kmLguvxHNQy+UuRV66cLVl3S+Rkt+Q==
"@rollup/rollup-darwin-x64@4.14.0": "@rollup/rollup-darwin-x64@4.14.1":
version "4.14.0" version "4.14.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.14.0.tgz#8baf2fda277c9729125017c65651296282412886" resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.14.1.tgz#217737f9f73de729fdfd7d529afebb6c8283f554"
integrity sha512-LDyFB9GRolGN7XI6955aFeI3wCdCUszFWumWU0deHA8VpR3nWRrjG6GtGjBrQxQKFevnUTHKCfPR4IvrW3kCgQ== integrity sha512-2pYRzEjVqq2TB/UNv47BV/8vQiXkFGVmPFwJb+1E0IFFZbIX8/jo1olxqqMbo6xCXf8kabANhp5bzCij2tFLUA==
"@rollup/rollup-linux-arm-gnueabihf@4.14.0": "@rollup/rollup-linux-arm-gnueabihf@4.14.1":
version "4.14.0" version "4.14.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.14.0.tgz#822830a8f7388d5b81d04c69415408d3bab1079b" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.14.1.tgz#a87e478ab3f697c7f4e74c8b1cac1e0667f8f4be"
integrity sha512-ygrGVhQP47mRh0AAD0zl6QqCbNsf0eTo+vgwkY6LunBcg0f2Jv365GXlDUECIyoXp1kKwL5WW6rsO429DBY/bA== integrity sha512-mS6wQ6Do6/wmrF9aTFVpIJ3/IDXhg1EZcQFYHZLHqw6AzMBjTHWnCG35HxSqUNphh0EHqSM6wRTT8HsL1C0x5g==
"@rollup/rollup-linux-arm64-gnu@4.14.0": "@rollup/rollup-linux-arm64-gnu@4.14.1":
version "4.14.0" version "4.14.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.14.0.tgz#e20fbe1bd4414c7119f9e0bba8ad17a6666c8365" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.14.1.tgz#4da6830eca27e5f4ca15f9197e5660952ca185c6"
integrity sha512-x+uJ6MAYRlHGe9wi4HQjxpaKHPM3d3JjqqCkeC5gpnnI6OWovLdXTpfa8trjxPLnWKyBsSi5kne+146GAxFt4A== integrity sha512-p9rGKYkHdFMzhckOTFubfxgyIO1vw//7IIjBBRVzyZebWlzRLeNhqxuSaZ7kCEKVkm/kuC9fVRW9HkC/zNRG2w==
"@rollup/rollup-linux-arm64-musl@4.14.0": "@rollup/rollup-linux-arm64-musl@4.14.1":
version "4.14.0" version "4.14.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.14.0.tgz#13f475596a62e1924f13fe1c8cf2c40e09a99b47" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.14.1.tgz#0b0ed35720aebc8f5e501d370a9ea0f686ead1e0"
integrity sha512-nrRw8ZTQKg6+Lttwqo6a2VxR9tOroa2m91XbdQ2sUUzHoedXlsyvY1fN4xWdqz8PKmf4orDwejxXHjh7YBGUCA== integrity sha512-nDY6Yz5xS/Y4M2i9JLQd3Rofh5OR8Bn8qe3Mv/qCVpHFlwtZSBYSPaU4mrGazWkXrdQ98GB//H0BirGR/SKFSw==
"@rollup/rollup-linux-powerpc64le-gnu@4.14.0": "@rollup/rollup-linux-powerpc64le-gnu@4.14.1":
version "4.14.0" version "4.14.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.14.0.tgz#6a431c441420d1c510a205e08c6673355a0a2ea9" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.14.1.tgz#024ad04d162726f25e62915851f7df69a9677c17"
integrity sha512-xV0d5jDb4aFu84XKr+lcUJ9y3qpIWhttO3Qev97z8DKLXR62LC3cXT/bMZXrjLF9X+P5oSmJTzAhqwUbY96PnA== integrity sha512-im7HE4VBL+aDswvcmfx88Mp1soqL9OBsdDBU8NqDEYtkri0qV0THhQsvZtZeNNlLeCUQ16PZyv7cqutjDF35qw==
"@rollup/rollup-linux-riscv64-gnu@4.14.0": "@rollup/rollup-linux-riscv64-gnu@4.14.1":
version "4.14.0" version "4.14.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.14.0.tgz#53d9448962c3f9ed7a1672269655476ea2d67567" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.14.1.tgz#180694d1cd069ddbe22022bb5b1bead3b7de581c"
integrity sha512-SDDhBQwZX6LPRoPYjAZWyL27LbcBo7WdBFWJi5PI9RPCzU8ijzkQn7tt8NXiXRiFMJCVpkuMkBf4OxSxVMizAw== integrity sha512-RWdiHuAxWmzPJgaHJdpvUUlDz8sdQz4P2uv367T2JocdDa98iRw2UjIJ4QxSyt077mXZT2X6pKfT2iYtVEvOFw==
"@rollup/rollup-linux-s390x-gnu@4.14.0": "@rollup/rollup-linux-s390x-gnu@4.14.1":
version "4.14.0" version "4.14.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.14.0.tgz#95f0c133b324da3e7e5c7d12855e0eb71d21a946" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.14.1.tgz#f7b4e2b0ca49be4e34f9ef0b548c926d94edee87"
integrity sha512-RxB/qez8zIDshNJDufYlTT0ZTVut5eCpAZ3bdXDU9yTxBzui3KhbGjROK2OYTTor7alM7XBhssgoO3CZ0XD3qA== integrity sha512-VMgaGQ5zRX6ZqV/fas65/sUGc9cPmsntq2FiGmayW9KMNfWVG/j0BAqImvU4KTeOOgYSf1F+k6at1UfNONuNjA==
"@rollup/rollup-linux-x64-gnu@4.14.0": "@rollup/rollup-linux-x64-gnu@4.14.1":
version "4.14.0" version "4.14.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.14.0.tgz#820ada75c68ead1acc486e41238ca0d8f8531478" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.14.1.tgz#0aaf79e5b9ccf7db3084fe6c3f2d2873a27d5af4"
integrity sha512-C6y6z2eCNCfhZxT9u+jAM2Fup89ZjiG5pIzZIDycs1IwESviLxwkQcFRGLjnDrP+PT+v5i4YFvlcfAs+LnreXg== integrity sha512-9Q7DGjZN+hTdJomaQ3Iub4m6VPu1r94bmK2z3UeWP3dGUecRC54tmVu9vKHTm1bOt3ASoYtEz6JSRLFzrysKlA==
"@rollup/rollup-linux-x64-musl@4.14.0": "@rollup/rollup-linux-x64-musl@4.14.1":
version "4.14.0" version "4.14.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.14.0.tgz#ca74f22e125efbe94c1148d989ef93329b464443" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.14.1.tgz#38f0a37ca5015eb07dff86a1b6f94279c179f4ed"
integrity sha512-i0QwbHYfnOMYsBEyjxcwGu5SMIi9sImDVjDg087hpzXqhBSosxkE7gyIYFHgfFl4mr7RrXksIBZ4DoLoP4FhJg== integrity sha512-JNEG/Ti55413SsreTguSx0LOVKX902OfXIKVg+TCXO6Gjans/k9O6ww9q3oLGjNDaTLxM+IHFMeXy/0RXL5R/g==
"@rollup/rollup-win32-arm64-msvc@4.14.0": "@rollup/rollup-win32-arm64-msvc@4.14.1":
version "4.14.0" version "4.14.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.14.0.tgz#269023332297051d037a9593dcba92c10fef726b" resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.14.1.tgz#84d48c55740ede42c77373f76e85f368633a0cc3"
integrity sha512-Fq52EYb0riNHLBTAcL0cun+rRwyZ10S9vKzhGKKgeD+XbwunszSY0rVMco5KbOsTlwovP2rTOkiII/fQ4ih/zQ== integrity sha512-ryS22I9y0mumlLNwDFYZRDFLwWh3aKaC72CWjFcFvxK0U6v/mOkM5Up1bTbCRAhv3kEIwW2ajROegCIQViUCeA==
"@rollup/rollup-win32-ia32-msvc@4.14.0": "@rollup/rollup-win32-ia32-msvc@4.14.1":
version "4.14.0" version "4.14.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.14.0.tgz#d7701438daf964011fd7ca33e3f13f3ff5129e7b" resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.14.1.tgz#c1e0bc39e20e760f0a526ddf14ae0543af796605"
integrity sha512-e/PBHxPdJ00O9p5Ui43+vixSgVf4NlLsmV6QneGERJ3lnjIua/kim6PRFe3iDueT1rQcgSkYP8ZBBXa/h4iPvw== integrity sha512-TdloItiGk+T0mTxKx7Hp279xy30LspMso+GzQvV2maYePMAWdmrzqSNZhUpPj3CGw12aGj57I026PgLCTu8CGg==
"@rollup/rollup-win32-x64-msvc@4.14.0": "@rollup/rollup-win32-x64-msvc@4.14.1":
version "4.14.0" version "4.14.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.14.0.tgz#0bb7ac3cd1c3292db1f39afdabfd03ccea3a3d34" resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.14.1.tgz#299eee74b7d87e116083ac5b1ce8dd9434668294"
integrity sha512-aGg7iToJjdklmxlUlJh/PaPNa4PmqHfyRMLunbL3eaMO0gp656+q1zOKkpJ/CVe9CryJv6tAN1HDoR8cNGzkag== integrity sha512-wQGI+LY/Py20zdUPq+XCem7JcPOyzIJBm3dli+56DJsQOHbnXZFEwgmnC6el1TPAfC8lBT3m+z69RmLykNUbew==
"@shikijs/core@1.2.4": "@shikijs/core@1.2.4":
version "1.2.4" version "1.2.4"
@ -899,6 +899,18 @@
resolved "https://registry.yarnpkg.com/@tanstack/query-core/-/query-core-5.29.0.tgz#d0b3d12c07d5a47f42ab0c1ed4f317106f3d4b20" resolved "https://registry.yarnpkg.com/@tanstack/query-core/-/query-core-5.29.0.tgz#d0b3d12c07d5a47f42ab0c1ed4f317106f3d4b20"
integrity sha512-WgPTRs58hm9CMzEr5jpISe8HXa3qKQ8CxewdYZeVnA54JrPY9B1CZiwsCoLpLkf0dGRZq+LcX5OiJb0bEsOFww== integrity sha512-WgPTRs58hm9CMzEr5jpISe8HXa3qKQ8CxewdYZeVnA54JrPY9B1CZiwsCoLpLkf0dGRZq+LcX5OiJb0bEsOFww==
"@tanstack/query-devtools@5.28.10":
version "5.28.10"
resolved "https://registry.yarnpkg.com/@tanstack/query-devtools/-/query-devtools-5.28.10.tgz#33e9a42dd2199fca12f0dd2d891570ecdbfd3c7b"
integrity sha512-5UN629fKa5/1K/2Pd26gaU7epxRrYiT1gy+V+pW5K6hnf1DeUKK3pANSb2eHKlecjIKIhTwyF7k9XdyE2gREvQ==
"@tanstack/react-query-devtools@^5.29.0":
version "5.29.0"
resolved "https://registry.yarnpkg.com/@tanstack/react-query-devtools/-/react-query-devtools-5.29.0.tgz#fde50304cc777c9bc8ad3f2f8afcd62412636984"
integrity sha512-WLuaU6yM4KdvBimEP1Km5lM4/p1J40cMp5I5z0Mc6a8QbBUYLK8qJcGIKelfLfDp7KmEcr59tzbRTmdH/GWvzQ==
dependencies:
"@tanstack/query-devtools" "5.28.10"
"@tanstack/react-query@^5.28.14": "@tanstack/react-query@^5.28.14":
version "5.29.0" version "5.29.0"
resolved "https://registry.yarnpkg.com/@tanstack/react-query/-/react-query-5.29.0.tgz#42b3a2de4ed1d63666f0af04392a34b5e70d49c0" resolved "https://registry.yarnpkg.com/@tanstack/react-query/-/react-query-5.29.0.tgz#42b3a2de4ed1d63666f0af04392a34b5e70d49c0"
@ -2462,6 +2474,11 @@ http-cache-semantics@^4.1.1:
resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz#abe02fcb2985460bf0323be664436ec3476a6d5a" resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz#abe02fcb2985460bf0323be664436ec3476a6d5a"
integrity sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ== integrity sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==
human-id@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/human-id/-/human-id-4.1.1.tgz#2801fbd61b9a5c1c9170f332802db6408a39a4b0"
integrity sha512-3gKm/gCSUipeLsRYZbbdA1BD83lBoWUkZ7G9VFrhWPAU76KwYo5KR8V28bpoPm/ygy0x5/GCbpRQdY7VLYCoIg==
human-signals@^5.0.0: human-signals@^5.0.0:
version "5.0.0" version "5.0.0"
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-5.0.0.tgz#42665a284f9ae0dade3ba41ebc37eb4b852f3a28" resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-5.0.0.tgz#42665a284f9ae0dade3ba41ebc37eb4b852f3a28"
@ -3626,9 +3643,9 @@ path-scurry@^1.10.2:
minipass "^5.0.0 || ^6.0.2 || ^7.0.0" minipass "^5.0.0 || ^6.0.2 || ^7.0.0"
path-to-regexp@^6.2.1: path-to-regexp@^6.2.1:
version "6.2.1" version "6.2.2"
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-6.2.1.tgz#d54934d6798eb9e5ef14e7af7962c945906918e5" resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-6.2.2.tgz#324377a83e5049cbecadc5554d6a63a9a4866b36"
integrity sha512-JLyh7xT1kizaEvcaXOQwOc2/Yhw6KZOvPf1S8401UyLk86CU79LN3vl7ztXGm/pZ+YjoyAJ4rxmHwbkBXJX+yw== integrity sha512-GQX3SSMokngb36+whdpRXE+3f9V8UzyAorlYvOGx87ufGHehNTn5lCxrKtLyZ4Yl/wEKnNnr98ZzOwwDZV5ogw==
picocolors@^1.0.0: picocolors@^1.0.0:
version "1.0.0" version "1.0.0"
@ -4087,27 +4104,27 @@ reusify@^1.0.4:
integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==
rollup@^4.13.0: rollup@^4.13.0:
version "4.14.0" version "4.14.1"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.14.0.tgz#c3e2cd479f1b2358b65c1f810fa05b51603d7be8" resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.14.1.tgz#228d5159c3f4d8745bd24819d734bc6c6ca87c09"
integrity sha512-Qe7w62TyawbDzB4yt32R0+AbIo6m1/sqO7UPzFS8Z/ksL5mrfhA0v4CavfdmFav3D+ub4QeAgsGEe84DoWe/nQ== integrity sha512-4LnHSdd3QK2pa1J6dFbfm1HN0D7vSK/ZuZTsdyUAlA6Rr1yTouUTL13HaDOGJVgby461AhrNGBS7sCGXXtT+SA==
dependencies: dependencies:
"@types/estree" "1.0.5" "@types/estree" "1.0.5"
optionalDependencies: optionalDependencies:
"@rollup/rollup-android-arm-eabi" "4.14.0" "@rollup/rollup-android-arm-eabi" "4.14.1"
"@rollup/rollup-android-arm64" "4.14.0" "@rollup/rollup-android-arm64" "4.14.1"
"@rollup/rollup-darwin-arm64" "4.14.0" "@rollup/rollup-darwin-arm64" "4.14.1"
"@rollup/rollup-darwin-x64" "4.14.0" "@rollup/rollup-darwin-x64" "4.14.1"
"@rollup/rollup-linux-arm-gnueabihf" "4.14.0" "@rollup/rollup-linux-arm-gnueabihf" "4.14.1"
"@rollup/rollup-linux-arm64-gnu" "4.14.0" "@rollup/rollup-linux-arm64-gnu" "4.14.1"
"@rollup/rollup-linux-arm64-musl" "4.14.0" "@rollup/rollup-linux-arm64-musl" "4.14.1"
"@rollup/rollup-linux-powerpc64le-gnu" "4.14.0" "@rollup/rollup-linux-powerpc64le-gnu" "4.14.1"
"@rollup/rollup-linux-riscv64-gnu" "4.14.0" "@rollup/rollup-linux-riscv64-gnu" "4.14.1"
"@rollup/rollup-linux-s390x-gnu" "4.14.0" "@rollup/rollup-linux-s390x-gnu" "4.14.1"
"@rollup/rollup-linux-x64-gnu" "4.14.0" "@rollup/rollup-linux-x64-gnu" "4.14.1"
"@rollup/rollup-linux-x64-musl" "4.14.0" "@rollup/rollup-linux-x64-musl" "4.14.1"
"@rollup/rollup-win32-arm64-msvc" "4.14.0" "@rollup/rollup-win32-arm64-msvc" "4.14.1"
"@rollup/rollup-win32-ia32-msvc" "4.14.0" "@rollup/rollup-win32-ia32-msvc" "4.14.1"
"@rollup/rollup-win32-x64-msvc" "4.14.0" "@rollup/rollup-win32-x64-msvc" "4.14.1"
fsevents "~2.3.2" fsevents "~2.3.2"
run-parallel@^1.1.9: run-parallel@^1.1.9:

View File

@ -7,7 +7,9 @@ const Dispatches: CollectionConfig = {
}, },
access: { access: {
read: () => true, read: () => true,
create: () => true
}, },
fields: [ fields: [
{ {
name: 'code', name: 'code',
@ -27,7 +29,7 @@ const Dispatches: CollectionConfig = {
{ {
name: 'courier', name: 'courier',
type: 'relationship', type: 'relationship',
relationTo: 'couriers', relationTo: 'users',
hasMany: false, hasMany: false,
required: false required: false
}, },
@ -64,28 +66,24 @@ const Dispatches: CollectionConfig = {
value: 'archived', value: 'archived',
}, },
], ],
} },
{
name: 'departure',
type: 'date',
required: false,
},
{
name: 'arrival',
type: 'date',
required: false,
},
{
name: 'timeSensitive',
type: 'checkbox',
required: false,
defaultValue: false
},
], ],
}; };
export default Dispatches; export default Dispatches;
// type Dispatch = {
// id: string;
// dispatchesCode: string; //Human readable id
// createdAt: string;
// updatedAt: string;
// maker: Maker;
// retailer: Retailer;
// products: Product[];
// courier: User;
// timeSensitive: boolean;
// status: DispatchStatus[];
// departureDate: string;
// arrivalDate: string;
// weightAllowance: number;
// }

View File

@ -6,7 +6,7 @@ const Users: CollectionConfig = {
useAsTitle: 'email', useAsTitle: 'email',
}, },
access: { access: {
read: () => true
}, },
auth: { auth: {
tokenExpiration: 7200, // How many seconds to keep the user logged in tokenExpiration: 7200, // How many seconds to keep the user logged in