From 17a4a5abd59c37371ba55d07ed444ff87d76a48a Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Wed, 3 Dec 2025 03:40:00 +0000 Subject: [PATCH] Added purchase orders and couriers. --- assets/icons/couriericon.svg | 7 + assets/icons/courierserviceicon.svg | 14 ++ assets/icons/orderitemsicon.svg | 7 + assets/icons/purchaseordericon.svg | 4 +- assets/icons/salesordericon.svg | 13 + .../Dashboard/Developer/DeveloperSidebar.jsx | 12 +- .../Dashboard/Inventory/InventorySidebar.jsx | 25 +- .../Dashboard/Inventory/PurchaseOrders.jsx | 101 ++++++++ .../PurchaseOrders/NewPurchaseOrder.jsx | 89 +++++++ .../PurchaseOrders/PurchaseOrderInfo.jsx | 231 ++++++++++++++++++ .../Dashboard/Management/CourierServices.jsx | 98 ++++++++ .../CourierServices/CourierServiceInfo.jsx | 198 +++++++++++++++ .../CourierServices/NewCourierService.jsx | 86 +++++++ .../Dashboard/Management/Couriers.jsx | 97 ++++++++ .../Management/Couriers/CourierInfo.jsx | 216 ++++++++++++++++ .../Management/Couriers/NewCourier.jsx | 80 ++++++ .../Management/ManagementSidebar.jsx | 29 ++- .../Production/ProductionSidebar.jsx | 12 +- .../Dashboard/common/NewObjectForm.jsx | 144 ++++++++--- .../Dashboard/common/ObjectChildTable.jsx | 15 +- .../Dashboard/common/ObjectForm.jsx | 169 +++++++++---- .../Dashboard/common/WizardView.jsx | 6 +- src/components/Icons/CourierIcon.jsx | 6 + src/components/Icons/CourierServiceIcon.jsx | 7 + src/components/Icons/OrderItemsIcon.jsx | 6 + src/database/ObjectModels.js | 6 + src/database/models/Courier.js | 142 +++++++++++ src/database/models/CourierService.js | 170 +++++++++++++ src/database/models/Part.js | 28 ++- src/database/models/PurchaseOrder.js | 169 ++++++++++++- src/database/models/Vendor.js | 1 - src/routes/InventoryRoutes.jsx | 12 + src/routes/ManagementRoutes.jsx | 20 ++ 33 files changed, 2109 insertions(+), 111 deletions(-) create mode 100644 assets/icons/couriericon.svg create mode 100644 assets/icons/courierserviceicon.svg create mode 100644 assets/icons/orderitemsicon.svg create mode 100644 assets/icons/salesordericon.svg create mode 100644 src/components/Dashboard/Inventory/PurchaseOrders.jsx create mode 100644 src/components/Dashboard/Inventory/PurchaseOrders/NewPurchaseOrder.jsx create mode 100644 src/components/Dashboard/Inventory/PurchaseOrders/PurchaseOrderInfo.jsx create mode 100644 src/components/Dashboard/Management/CourierServices.jsx create mode 100644 src/components/Dashboard/Management/CourierServices/CourierServiceInfo.jsx create mode 100644 src/components/Dashboard/Management/CourierServices/NewCourierService.jsx create mode 100644 src/components/Dashboard/Management/Couriers.jsx create mode 100644 src/components/Dashboard/Management/Couriers/CourierInfo.jsx create mode 100644 src/components/Dashboard/Management/Couriers/NewCourier.jsx create mode 100644 src/components/Icons/CourierIcon.jsx create mode 100644 src/components/Icons/CourierServiceIcon.jsx create mode 100644 src/components/Icons/OrderItemsIcon.jsx create mode 100644 src/database/models/Courier.js create mode 100644 src/database/models/CourierService.js diff --git a/assets/icons/couriericon.svg b/assets/icons/couriericon.svg new file mode 100644 index 0000000..26bfd21 --- /dev/null +++ b/assets/icons/couriericon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/icons/courierserviceicon.svg b/assets/icons/courierserviceicon.svg new file mode 100644 index 0000000..0047f95 --- /dev/null +++ b/assets/icons/courierserviceicon.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/assets/icons/orderitemsicon.svg b/assets/icons/orderitemsicon.svg new file mode 100644 index 0000000..bcb55f4 --- /dev/null +++ b/assets/icons/orderitemsicon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/icons/purchaseordericon.svg b/assets/icons/purchaseordericon.svg index 237395f..db04b34 100644 --- a/assets/icons/purchaseordericon.svg +++ b/assets/icons/purchaseordericon.svg @@ -1,11 +1,13 @@ - + + + diff --git a/assets/icons/salesordericon.svg b/assets/icons/salesordericon.svg new file mode 100644 index 0000000..c1bea56 --- /dev/null +++ b/assets/icons/salesordericon.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/components/Dashboard/Developer/DeveloperSidebar.jsx b/src/components/Dashboard/Developer/DeveloperSidebar.jsx index 244af1b..5c7fe04 100644 --- a/src/components/Dashboard/Developer/DeveloperSidebar.jsx +++ b/src/components/Dashboard/Developer/DeveloperSidebar.jsx @@ -34,9 +34,15 @@ const routeKeyMap = { const DeveloperSidebar = (props) => { const location = useLocation() const selectedKey = (() => { - const match = Object.keys(routeKeyMap).find((path) => - location.pathname.startsWith(path) - ) + const match = Object.keys(routeKeyMap).find((path) => { + const pathSplit = path.split('/') + const locationPathSplit = location.pathname.split('/') + if (pathSplit.length > locationPathSplit.length) return false + for (let i = 0; i < pathSplit.length; i++) { + if (pathSplit[i] !== locationPathSplit[i]) return false + } + return true + }) return match ? routeKeyMap[match] : 'sessionstorage' })() diff --git a/src/components/Dashboard/Inventory/InventorySidebar.jsx b/src/components/Dashboard/Inventory/InventorySidebar.jsx index db8ea3c..f222a65 100644 --- a/src/components/Dashboard/Inventory/InventorySidebar.jsx +++ b/src/components/Dashboard/Inventory/InventorySidebar.jsx @@ -6,6 +6,7 @@ import PartStockIcon from '../../Icons/PartStockIcon' import ProductStockIcon from '../../Icons/ProductStockIcon' import StockEventIcon from '../../Icons/StockEventIcon' import StockAuditIcon from '../../Icons/StockAuditIcon' +import PurchaseOrderIcon from '../../Icons/PurchaseOrderIcon' const items = [ { @@ -34,6 +35,13 @@ const items = [ path: '/dashboard/inventory/productstocks' }, { type: 'divider' }, + { + key: 'purchaseorders', + label: 'Purchase Orders', + icon: , + path: '/dashboard/inventory/purchaseorders' + }, + { type: 'divider' }, { key: 'stockevents', label: 'Stock Events', @@ -54,16 +62,23 @@ const routeKeyMap = { '/dashboard/inventory/partstocks': 'partstocks', '/dashboard/inventory/productstocks': 'productstocks', '/dashboard/inventory/stockevents': 'stockevents', - '/dashboard/inventory/stockaudits': 'stockaudits' + '/dashboard/inventory/stockaudits': 'stockaudits', + '/dashboard/inventory/purchaseorders': 'purchaseorders' } const InventorySidebar = (props) => { const location = useLocation() const selectedKey = (() => { - const match = Object.keys(routeKeyMap).find((path) => - location.pathname.startsWith(path) - ) - return match ? routeKeyMap[match] : 'filaments' + const match = Object.keys(routeKeyMap).find((path) => { + const pathSplit = path.split('/') + const locationPathSplit = location.pathname.split('/') + if (pathSplit.length > locationPathSplit.length) return false + for (let i = 0; i < pathSplit.length; i++) { + if (pathSplit[i] !== locationPathSplit[i]) return false + } + return true + }) + return match ? routeKeyMap[match] : 'overview' })() return diff --git a/src/components/Dashboard/Inventory/PurchaseOrders.jsx b/src/components/Dashboard/Inventory/PurchaseOrders.jsx new file mode 100644 index 0000000..25e5977 --- /dev/null +++ b/src/components/Dashboard/Inventory/PurchaseOrders.jsx @@ -0,0 +1,101 @@ +import { useState, useRef } from 'react' +import { Button, Flex, Space, Modal, Dropdown, message } from 'antd' +import NewPurchaseOrder from './PurchaseOrders/NewPurchaseOrder' +import ObjectTable from '../common/ObjectTable' +import PlusIcon from '../../Icons/PlusIcon' +import ReloadIcon from '../../Icons/ReloadIcon' +import useColumnVisibility from '../hooks/useColumnVisibility' +import GridIcon from '../../Icons/GridIcon' +import ListIcon from '../../Icons/ListIcon' +import useViewMode from '../hooks/useViewMode' +import ColumnViewButton from '../common/ColumnViewButton' + +const PurchaseOrders = () => { + const [messageApi, contextHolder] = message.useMessage() + const [newPurchaseOrderOpen, setNewPurchaseOrderOpen] = useState(false) + const tableRef = useRef() + + const [viewMode, setViewMode] = useViewMode('purchaseOrders') + + const [columnVisibility, setColumnVisibility] = + useColumnVisibility('purchaseOrders') + + const actionItems = { + items: [ + { + label: 'New Purchase Order', + key: 'newPurchaseOrder', + icon: + }, + { type: 'divider' }, + { + label: 'Reload List', + key: 'reloadList', + icon: + } + ], + onClick: ({ key }) => { + if (key === 'reloadList') { + tableRef.current?.reload() + } else if (key === 'newPurchaseOrder') { + setNewPurchaseOrderOpen(true) + } + } + } + + return ( + <> + + {contextHolder} + + + + + + + + + + + + + + + + + + +