diff --git a/.gitignore b/.gitignore index d0eb167..e427ff3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,3 @@ node_modules/ */node_modules/ */build/ - -**/node_modules/ -**/build/ -.DS_Store -.env \ No newline at end of file diff --git a/backend/src/db/api/shipments.js b/backend/src/db/api/shipments.js index b5197b7..e14bcb7 100644 --- a/backend/src/db/api/shipments.js +++ b/backend/src/db/api/shipments.js @@ -24,7 +24,6 @@ module.exports = class ShipmentsDBApi { state: data.state || null, customerCharge: data.customerCharge || null, actualCharge: data.actualCharge || null, - businessname: data.businessname || null, importHash: data.importHash || null, createdById: currentUser.id, updatedById: currentUser.id, @@ -60,7 +59,6 @@ module.exports = class ShipmentsDBApi { state: item.state || null, customerCharge: item.customerCharge || null, actualCharge: item.actualCharge || null, - businessname: item.businessname || null, importHash: item.importHash || null, createdById: currentUser.id, updatedById: currentUser.id, @@ -106,9 +104,6 @@ module.exports = class ShipmentsDBApi { if (data.actualCharge !== undefined) updatePayload.actualCharge = data.actualCharge; - if (data.businessname !== undefined) - updatePayload.businessname = data.businessname; - updatePayload.updatedById = currentUser.id; await shipments.update(updatePayload, { transaction }); @@ -304,17 +299,6 @@ module.exports = class ShipmentsDBApi { }; } - if (filter.businessname) { - where = { - ...where, - [Op.and]: Utils.ilike( - 'shipments', - 'businessname', - filter.businessname, - ), - }; - } - if (filter.customerChargeRange) { const [start, end] = filter.customerChargeRange; diff --git a/backend/src/db/migrations/1744527865779.js b/backend/src/db/migrations/1744527865779.js deleted file mode 100644 index 0994445..0000000 --- a/backend/src/db/migrations/1744527865779.js +++ /dev/null @@ -1,49 +0,0 @@ -module.exports = { - /** - * @param {QueryInterface} queryInterface - * @param {Sequelize} Sequelize - * @returns {Promise} - */ - async up(queryInterface, Sequelize) { - /** - * @type {Transaction} - */ - const transaction = await queryInterface.sequelize.transaction(); - try { - await queryInterface.addColumn( - 'shipments', - 'businessname', - { - type: Sequelize.DataTypes.TEXT, - }, - { transaction }, - ); - - await transaction.commit(); - } catch (err) { - await transaction.rollback(); - throw err; - } - }, - /** - * @param {QueryInterface} queryInterface - * @param {Sequelize} Sequelize - * @returns {Promise} - */ - async down(queryInterface, Sequelize) { - /** - * @type {Transaction} - */ - const transaction = await queryInterface.sequelize.transaction(); - try { - await queryInterface.removeColumn('shipments', 'businessname', { - transaction, - }); - - await transaction.commit(); - } catch (err) { - await transaction.rollback(); - throw err; - } - }, -}; diff --git a/backend/src/db/models/shipments.js b/backend/src/db/models/shipments.js index 8c7f6f1..112e8dd 100644 --- a/backend/src/db/models/shipments.js +++ b/backend/src/db/models/shipments.js @@ -50,10 +50,6 @@ module.exports = function (sequelize, DataTypes) { type: DataTypes.DECIMAL, }, - businessname: { - type: DataTypes.TEXT, - }, - importHash: { type: DataTypes.STRING(255), allowNull: true, diff --git a/backend/src/db/seeders/20231127130745-sample-data.js b/backend/src/db/seeders/20231127130745-sample-data.js index d878c8b..d6f776a 100644 --- a/backend/src/db/seeders/20231127130745-sample-data.js +++ b/backend/src/db/seeders/20231127130745-sample-data.js @@ -9,7 +9,7 @@ const Shipments = db.shipments; const ProductsData = [ { - productName: 'John Dalton', + productName: 'Andreas Vesalius', // type code here for "images" field @@ -23,7 +23,7 @@ const ProductsData = [ }, { - productName: 'Edward Teller', + productName: 'Thomas Hunt Morgan', // type code here for "images" field @@ -37,7 +37,7 @@ const ProductsData = [ }, { - productName: 'Richard Feynman', + productName: 'Willard Libby', // type code here for "images" field @@ -49,29 +49,73 @@ const ProductsData = [ height: 5, }, + + { + productName: 'Theodosius Dobzhansky', + + // type code here for "images" field + + weight: 4, + + length: 25, + + width: 12, + + height: 6, + }, + + { + productName: 'Gertrude Belle Elion', + + // type code here for "images" field + + weight: 5, + + length: 30, + + width: 15, + + height: 8, + }, ]; const QuotesData = [ { - carrierName: 'Paul Dirac', + carrierName: 'Rudolf Virchow', - quotePrice: 78.38, + quotePrice: 51.15, // type code here for "relation_one" field }, { - carrierName: 'Paul Ehrlich', + carrierName: 'Tycho Brahe', - quotePrice: 99.12, + quotePrice: 62.23, // type code here for "relation_one" field }, { - carrierName: 'Michael Faraday', + carrierName: 'Karl Landsteiner', - quotePrice: 93.69, + quotePrice: 48.62, + + // type code here for "relation_one" field + }, + + { + carrierName: 'Jean Baptiste Lamarck', + + quotePrice: 52.37, + + // type code here for "relation_one" field + }, + + { + carrierName: 'Sheldon Glashow', + + quotePrice: 43.24, // type code here for "relation_one" field }, @@ -79,81 +123,123 @@ const QuotesData = [ const ShipmentsData = [ { - customer: 'Edward Teller', - - phoneNumber: 'Emil Kraepelin', - - address: 'Frederick Sanger', - - address2: 'Anton van Leeuwenhoek', - - zipCode: 'Ernst Mayr', - - city: 'Stephen Hawking', - - state: 'Max Born', - - // type code here for "relation_many" field - - // type code here for "relation_one" field - - customerCharge: 71.54, - - actualCharge: 83.68, - - businessname: 'Willard Libby', - }, - - { - customer: 'Rudolf Virchow', - - phoneNumber: 'Comte de Buffon', - - address: 'Hans Bethe', - - address2: 'Edward Teller', - - zipCode: 'Willard Libby', - - city: 'Ernst Mayr', - - state: 'Joseph J. Thomson', - - // type code here for "relation_many" field - - // type code here for "relation_one" field - - customerCharge: 38.34, - - actualCharge: 45.04, - - businessname: 'Frederick Sanger', - }, - - { - customer: 'James Clerk Maxwell', + customer: 'Alfred Wegener', phoneNumber: 'Charles Sherrington', - address: 'Trofim Lysenko', + address: 'Heike Kamerlingh Onnes', - address2: 'Werner Heisenberg', + address2: 'Konrad Lorenz', - zipCode: 'Charles Darwin', + zipCode: 'Frederick Gowland Hopkins', - city: 'Joseph J. Thomson', + city: 'Nicolaus Copernicus', - state: 'Carl Gauss (Karl Friedrich Gauss)', + state: 'Edward O. Wilson', // type code here for "relation_many" field // type code here for "relation_one" field - customerCharge: 43.34, + customerCharge: 30.03, - actualCharge: 10.66, + actualCharge: 95.91, + }, - businessname: 'James Clerk Maxwell', + { + customer: 'Hermann von Helmholtz', + + phoneNumber: 'Justus Liebig', + + address: 'Marie Curie', + + address2: 'Alfred Wegener', + + zipCode: 'Hans Bethe', + + city: 'Enrico Fermi', + + state: 'Sigmund Freud', + + // type code here for "relation_many" field + + // type code here for "relation_one" field + + customerCharge: 53.43, + + actualCharge: 58.21, + }, + + { + customer: 'B. F. Skinner', + + phoneNumber: 'Gregor Mendel', + + address: 'Carl Gauss (Karl Friedrich Gauss)', + + address2: 'Alfred Wegener', + + zipCode: 'Frederick Sanger', + + city: 'Galileo Galilei', + + state: 'James Watson', + + // type code here for "relation_many" field + + // type code here for "relation_one" field + + customerCharge: 13.46, + + actualCharge: 92.16, + }, + + { + customer: 'Ernest Rutherford', + + phoneNumber: 'Carl Gauss (Karl Friedrich Gauss)', + + address: 'John von Neumann', + + address2: 'Jonas Salk', + + zipCode: 'Leonard Euler', + + city: 'Claude Levi-Strauss', + + state: 'Pierre Simon de Laplace', + + // type code here for "relation_many" field + + // type code here for "relation_one" field + + customerCharge: 35.87, + + actualCharge: 33.48, + }, + + { + customer: 'Arthur Eddington', + + phoneNumber: 'J. Robert Oppenheimer', + + address: 'Francis Crick', + + address2: 'Anton van Leeuwenhoek', + + zipCode: 'George Gaylord Simpson', + + city: 'Claude Levi-Strauss', + + state: 'Nicolaus Copernicus', + + // type code here for "relation_many" field + + // type code here for "relation_one" field + + customerCharge: 57.76, + + actualCharge: 52.63, }, ]; @@ -192,6 +278,28 @@ async function associateQuoteWithShipment() { if (Quote2?.setShipment) { await Quote2.setShipment(relatedShipment2); } + + const relatedShipment3 = await Shipments.findOne({ + offset: Math.floor(Math.random() * (await Shipments.count())), + }); + const Quote3 = await Quotes.findOne({ + order: [['id', 'ASC']], + offset: 3, + }); + if (Quote3?.setShipment) { + await Quote3.setShipment(relatedShipment3); + } + + const relatedShipment4 = await Shipments.findOne({ + offset: Math.floor(Math.random() * (await Shipments.count())), + }); + const Quote4 = await Quotes.findOne({ + order: [['id', 'ASC']], + offset: 4, + }); + if (Quote4?.setShipment) { + await Quote4.setShipment(relatedShipment4); + } } // Similar logic for "relation_many" @@ -229,6 +337,28 @@ async function associateShipmentWithQuote() { if (Shipment2?.setQuote) { await Shipment2.setQuote(relatedQuote2); } + + const relatedQuote3 = await Quotes.findOne({ + offset: Math.floor(Math.random() * (await Quotes.count())), + }); + const Shipment3 = await Shipments.findOne({ + order: [['id', 'ASC']], + offset: 3, + }); + if (Shipment3?.setQuote) { + await Shipment3.setQuote(relatedQuote3); + } + + const relatedQuote4 = await Quotes.findOne({ + offset: Math.floor(Math.random() * (await Quotes.count())), + }); + const Shipment4 = await Shipments.findOne({ + order: [['id', 'ASC']], + offset: 4, + }); + if (Shipment4?.setQuote) { + await Shipment4.setQuote(relatedQuote4); + } } module.exports = { diff --git a/backend/src/routes/shipments.js b/backend/src/routes/shipments.js index 0db56b1..5c8fdea 100644 --- a/backend/src/routes/shipments.js +++ b/backend/src/routes/shipments.js @@ -41,9 +41,6 @@ router.use(checkCrudPermissions('shipments')); * state: * type: string * default: state - * businessname: - * type: string - * default: businessname * customerCharge: * type: integer @@ -341,7 +338,6 @@ router.get( 'zipCode', 'city', 'state', - 'businessname', 'customerCharge', 'actualCharge', diff --git a/backend/src/services/search.js b/backend/src/services/search.js index f4648cc..dda4049 100644 --- a/backend/src/services/search.js +++ b/backend/src/services/search.js @@ -61,8 +61,6 @@ module.exports = class SearchService { 'city', 'state', - - 'businessname', ], }; const columnsInt = { diff --git a/frontend/src/components/Products/CardProducts.tsx b/frontend/src/components/Products/CardProducts.tsx index 383597f..1a843a7 100644 --- a/frontend/src/components/Products/CardProducts.tsx +++ b/frontend/src/components/Products/CardProducts.tsx @@ -59,7 +59,7 @@ const CardProducts = ({ className={`flex items-center ${bgColor} p-6 md:p-0 md:block gap-x-4 border-b border-gray-900/5 bg-gray-50 dark:bg-dark-800 relative`} > - -
-
- Businessname -
-
-
- {item.businessname} -
-
-
))} diff --git a/frontend/src/components/Shipments/ListShipments.tsx b/frontend/src/components/Shipments/ListShipments.tsx index cfe4c87..684633b 100644 --- a/frontend/src/components/Shipments/ListShipments.tsx +++ b/frontend/src/components/Shipments/ListShipments.tsx @@ -119,11 +119,6 @@ const ListShipments = ({

Actual Charge

{item.actualCharge}

- -
-

Businessname

-

{item.businessname}

-
+ dataFormatter.productsManyListFormatter(value).join(', '), + renderEditCell: (params) => ( + + ), + }, + + { + field: 'quote', + headerName: 'Quote', + flex: 1, + minWidth: 120, + filterable: false, + headerClassName: 'datagrid--header', + cellClassName: 'datagrid--cell', + + editable: hasUpdatePermission, + + sortable: false, + type: 'singleSelect', + getOptionValue: (value: any) => value?.id, + getOptionLabel: (value: any) => value?.label, + valueOptions: await callOptionsApi('quotes'), + valueGetter: (params: GridValueGetterParams) => + params?.value?.id ?? params?.value, + }, + + { + field: 'customerCharge', + headerName: 'Customer Charge', + flex: 1, + minWidth: 120, + filterable: false, + headerClassName: 'datagrid--header', + cellClassName: 'datagrid--cell', + + editable: hasUpdatePermission, + + type: 'number', + }, + + { + field: 'actualCharge', + headerName: 'Actual Charge', + flex: 1, + minWidth: 120, + filterable: false, + headerClassName: 'datagrid--header', + cellClassName: 'datagrid--cell', + + editable: hasUpdatePermission, + + type: 'number', + }, + + { + field: 'actions', + type: 'actions', + minWidth: 30, + headerClassName: 'datagrid--header', + cellClassName: 'datagrid--cell', + getActions: (params: GridRowParams) => { + return [ + , + ]; }, - { - field: 'customer', - headerName: 'Customer', - flex: 1, - minWidth: 120, - filterable: false, - headerClassName: 'datagrid--header', - cellClassName: 'datagrid--cell', - editable: hasUpdatePermission, - }, - { - field: 'address', - headerName: 'Address', - flex: 1, - minWidth: 120, - filterable: false, - headerClassName: 'datagrid--header', - cellClassName: 'datagrid--cell', - editable: hasUpdatePermission, - }, - { - field: 'state', - headerName: 'State', - flex: 1, - minWidth: 120, - filterable: false, - headerClassName: 'datagrid--header', - cellClassName: 'datagrid--cell', - editable: hasUpdatePermission, - }, - { - field: 'zipCode', - headerName: 'Zip Code', - flex: 1, - minWidth: 120, - filterable: false, - headerClassName: 'datagrid--header', - cellClassName: 'datagrid--cell', - editable: hasUpdatePermission, - }, - { - field: 'customerCharge', - headerName: 'Customer Charge', - flex: 1, - minWidth: 120, - filterable: false, - headerClassName: 'datagrid--header', - cellClassName: 'datagrid--cell', - editable: hasUpdatePermission, - type: 'number', - }, - { - field: 'actualCharge', - headerName: 'Actual Charge', - flex: 1, - minWidth: 120, - filterable: false, - headerClassName: 'datagrid--header', - cellClassName: 'datagrid--cell', - editable: hasUpdatePermission, - type: 'number', - }, - ]; + }, + ]; }; diff --git a/frontend/src/menuAside.ts b/frontend/src/menuAside.ts index b839683..228929a 100644 --- a/frontend/src/menuAside.ts +++ b/frontend/src/menuAside.ts @@ -7,42 +7,71 @@ const menuAside: MenuAsideItem[] = [ icon: icon.mdiViewDashboardOutline, label: 'Dashboard', }, - { - href: '/shipments/shipments-list', - icon: icon.mdiTruck ? icon.mdiTruck : icon.mdiTable, - label: 'Shipments', - permissions: 'READ_SHIPMENTS', - }, - { - href: '/products/products-list', - icon: icon.mdiPackageVariant ? icon.mdiPackageVariant : icon.mdiTable, - label: 'Products', - permissions: 'READ_PRODUCTS', - }, - { divider: true }, + { href: '/users/users-list', - icon: icon.mdiAccountGroup ? icon.mdiAccountGroup : icon.mdiTable, label: 'Users', + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + icon: icon.mdiAccountGroup ? icon.mdiAccountGroup : icon.mdiTable, permissions: 'READ_USERS', }, + { + href: '/products/products-list', + label: 'Products', + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + icon: icon.mdiPackageVariant ? icon.mdiPackageVariant : icon.mdiTable, + permissions: 'READ_PRODUCTS', + }, + { + href: '/quotes/quotes-list', + label: 'Quotes', + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + icon: icon.mdiCurrencyUsd ? icon.mdiCurrencyUsd : icon.mdiTable, + permissions: 'READ_QUOTES', + }, + { + href: '/shipments/shipments-list', + label: 'Shipments', + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + icon: icon.mdiTruck ? icon.mdiTruck : icon.mdiTable, + permissions: 'READ_SHIPMENTS', + }, { href: '/roles/roles-list', - icon: icon.mdiShieldAccountVariantOutline ? icon.mdiShieldAccountVariantOutline : icon.mdiTable, label: 'Roles', + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + icon: icon.mdiShieldAccountVariantOutline + ? icon.mdiShieldAccountVariantOutline + : icon.mdiTable, permissions: 'READ_ROLES', }, { href: '/permissions/permissions-list', - icon: icon.mdiShieldAccountOutline ? icon.mdiShieldAccountOutline : icon.mdiTable, label: 'Permissions', + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + icon: icon.mdiShieldAccountOutline + ? icon.mdiShieldAccountOutline + : icon.mdiTable, permissions: 'READ_PERMISSIONS', }, - { divider: true }, { href: '/profile', - icon: icon.mdiAccountCircle, label: 'Profile', + icon: icon.mdiAccountCircle, + }, + + { + href: '/api-docs', + target: '_blank', + label: 'Swagger API', + icon: icon.mdiFileCode, + permissions: 'READ_API_DOCS', }, ]; diff --git a/frontend/src/pages/quotes/quotes-view.tsx b/frontend/src/pages/quotes/quotes-view.tsx index 88277cf..0dd0a3b 100644 --- a/frontend/src/pages/quotes/quotes-view.tsx +++ b/frontend/src/pages/quotes/quotes-view.tsx @@ -97,8 +97,6 @@ const QuotesView = () => { Customer Charge Actual Charge - - Businessname @@ -132,8 +130,6 @@ const QuotesView = () => { {item.actualCharge} - - {item.businessname} ))} diff --git a/frontend/src/pages/shipments/[shipmentsId].tsx b/frontend/src/pages/shipments/[shipmentsId].tsx index 5148a77..aa147f9 100644 --- a/frontend/src/pages/shipments/[shipmentsId].tsx +++ b/frontend/src/pages/shipments/[shipmentsId].tsx @@ -57,8 +57,6 @@ const EditShipments = () => { customerCharge: '', actualCharge: '', - - businessname: '', }; const [initialValues, setInitialValues] = useState(initVals); @@ -179,10 +177,6 @@ const EditShipments = () => { /> - - - - diff --git a/frontend/src/pages/shipments/shipments-edit.tsx b/frontend/src/pages/shipments/shipments-edit.tsx index 1452964..80e949b 100644 --- a/frontend/src/pages/shipments/shipments-edit.tsx +++ b/frontend/src/pages/shipments/shipments-edit.tsx @@ -57,8 +57,6 @@ const EditShipmentsPage = () => { customerCharge: '', actualCharge: '', - - businessname: '', }; const [initialValues, setInitialValues] = useState(initVals); @@ -177,10 +175,6 @@ const EditShipmentsPage = () => { /> - - - - diff --git a/frontend/src/pages/shipments/shipments-list.tsx b/frontend/src/pages/shipments/shipments-list.tsx index 5ddf5d7..c48fb92 100644 --- a/frontend/src/pages/shipments/shipments-list.tsx +++ b/frontend/src/pages/shipments/shipments-list.tsx @@ -36,7 +36,6 @@ const ShipmentsTablesPage = () => { { label: 'Zip Code', title: 'zipCode' }, { label: 'City', title: 'city' }, { label: 'State', title: 'state' }, - { label: 'Businessname', title: 'businessname' }, { label: 'Customer Charge', title: 'customerCharge', number: 'true' }, { label: 'Actual Charge', title: 'actualCharge', number: 'true' }, diff --git a/frontend/src/pages/shipments/shipments-new.tsx b/frontend/src/pages/shipments/shipments-new.tsx index 6be0ff2..6a865e2 100644 --- a/frontend/src/pages/shipments/shipments-new.tsx +++ b/frontend/src/pages/shipments/shipments-new.tsx @@ -54,8 +54,6 @@ const initialValues = { customerCharge: '', actualCharge: '', - - businessname: '', }; const ShipmentsNew = () => { @@ -149,10 +147,6 @@ const ShipmentsNew = () => { /> - - - - diff --git a/frontend/src/pages/shipments/shipments-table.tsx b/frontend/src/pages/shipments/shipments-table.tsx index d42d971..d25de31 100644 --- a/frontend/src/pages/shipments/shipments-table.tsx +++ b/frontend/src/pages/shipments/shipments-table.tsx @@ -36,7 +36,6 @@ const ShipmentsTablesPage = () => { { label: 'Zip Code', title: 'zipCode' }, { label: 'City', title: 'city' }, { label: 'State', title: 'state' }, - { label: 'Businessname', title: 'businessname' }, { label: 'Customer Charge', title: 'customerCharge', number: 'true' }, { label: 'Actual Charge', title: 'actualCharge', number: 'true' }, diff --git a/frontend/src/pages/shipments/shipments-view.tsx b/frontend/src/pages/shipments/shipments-view.tsx index 94efba1..e85b79d 100644 --- a/frontend/src/pages/shipments/shipments-view.tsx +++ b/frontend/src/pages/shipments/shipments-view.tsx @@ -161,11 +161,6 @@ const ShipmentsView = () => {

{shipments?.actualCharge || 'No data'}

-
-

Businessname

-

{shipments?.businessname}

-
- <>

Quotes Shipment