diff --git a/frontend/src/components/RouteGuard.tsx b/frontend/src/components/RouteGuard.tsx index 1db97fba..c19e86d0 100644 --- a/frontend/src/components/RouteGuard.tsx +++ b/frontend/src/components/RouteGuard.tsx @@ -1,7 +1,6 @@ /* -Copyright (c) 2022-2024 Volkswagen AG -Copyright (c) 2022-2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) -Copyright (c) 2022-2024 Contributors to the Eclipse Foundation +Copyright (c) 2024 Volkswagen AG +Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional information regarding copyright ownership. diff --git a/frontend/src/components/layout/Layout.tsx b/frontend/src/components/layout/Layout.tsx index 817f9de5..4d519efe 100644 --- a/frontend/src/components/layout/Layout.tsx +++ b/frontend/src/components/layout/Layout.tsx @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional diff --git a/frontend/src/components/layout/SideBar.tsx b/frontend/src/components/layout/SideBar.tsx index 80e72c26..502a31f0 100644 --- a/frontend/src/components/layout/SideBar.tsx +++ b/frontend/src/components/layout/SideBar.tsx @@ -1,7 +1,7 @@ /* -Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) -Copyright (c) 2024 Contributors to the Eclipse Foundation +Copyright (c) 2023-24 Volkswagen AG +Copyright (c) 2023-24 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) +Copyright (c) 2023-24 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional information regarding copyright ownership. diff --git a/frontend/src/contexts/authContext.tsx b/frontend/src/contexts/authContext.tsx index 541a98fe..04026d1a 100644 --- a/frontend/src/contexts/authContext.tsx +++ b/frontend/src/contexts/authContext.tsx @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional diff --git a/frontend/src/features/stock-view/components/MaterialStockView.tsx b/frontend/src/features/stock-view/components/MaterialStockView.tsx deleted file mode 100644 index c3700645..00000000 --- a/frontend/src/features/stock-view/components/MaterialStockView.tsx +++ /dev/null @@ -1,45 +0,0 @@ -/* -Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) -Copyright (c) 2024 Contributors to the Eclipse Foundation - -See the NOTICE file(s) distributed with this work for additional -information regarding copyright ownership. - -This program and the accompanying materials are made available under the -terms of the Apache License, Version 2.0 which is available at -https://www.apache.org/licenses/LICENSE-2.0. - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations -under the License. - -SPDX-License-Identifier: Apache-2.0 -*/ - -import { useState } from 'react'; -import { useMaterials } from '../hooks/useMaterials'; -import { StockUpdateForm } from './StockUpdateForm'; -import { PartnerStockTable } from './PartnerStockTable'; -import { StockTable } from './StockTable'; -import { MaterialStock } from '@models/types/data/stock'; - -export const MaterialStockView = () => { - const { materials } = useMaterials(); - const [selectedMaterial, setSelectedMaterial] = useState(null); - return ( -
-
- -
- type='material' onSelection={setSelectedMaterial} /> - -
- ); -} diff --git a/frontend/src/features/stock-view/components/PartnerStockTable.tsx b/frontend/src/features/stock-view/components/PartnerStockTable.tsx index ea317424..4bd15df9 100644 --- a/frontend/src/features/stock-view/components/PartnerStockTable.tsx +++ b/frontend/src/features/stock-view/components/PartnerStockTable.tsx @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional @@ -20,27 +19,27 @@ SPDX-License-Identifier: Apache-2.0 */ import { LoadingButton, Table } from '@catena-x/portal-shared-components'; -import { MaterialStock, ProductStock } from '@models/types/data/stock'; -import { usePartnerStocks } from '../hooks/usePartnerStocks'; +import { Stock, StockType } from '@models/types/data/stock'; import { getUnitOfMeasurement } from '@util/helpers'; -import { refreshPartnerStocks } from '@services/stocks-service'; -import { useState } from 'react'; -type PartnerStockTableProps = { - type: 'material' | 'product'; - materialNumber?: string | null; +type PartnerStockTableProps = { + type: T; + materialName?: string | null; + partnerStocks: Stock[]; + isRefreshing: boolean; + onRefresh: () => void; }; const partnerStockTableColumns = [ { field: 'partner', - valueGetter: (data: { row: MaterialStock | ProductStock }) => data.row.partner?.name, + valueGetter: (data: { row: Stock }) => data.row.partner?.name, headerName: 'Partner', flex: 5, }, { field: 'quantity', - valueGetter: (data: { row: MaterialStock | ProductStock }) => + valueGetter: (data: { row: Stock }) => data.row.quantity + ' ' + getUnitOfMeasurement(data.row.measurementUnit), headerName: 'Quantity', flex: 3, @@ -57,7 +56,7 @@ const partnerStockTableColumns = [ }, { field: 'customerOrder', - renderCell: (params: { row: MaterialStock | ProductStock }) => ( + renderCell: (params: { row: Stock }) => (
{params.row.customerOrderNumber} {params.row.customerOrderPositionNumber} @@ -73,24 +72,17 @@ const partnerStockTableColumns = [ }, { field: 'lastUpdatedOn', - valueGetter: (data: { row: MaterialStock }) => new Date(data.row.lastUpdatedOn)?.toLocaleString(), + valueGetter: (data: { row: Stock }) => new Date(data.row.lastUpdatedOn)?.toLocaleString(), headerName: 'Last Updated On', flex: 3, }, ]; -export const PartnerStockTable = ({ materialNumber, type }: PartnerStockTableProps) => { - const { partnerStocks } = usePartnerStocks(type, materialNumber); - const [refreshing, setRefreshing] = useState(false); - - const handleStockRefresh = () => { - setRefreshing(true); - refreshPartnerStocks(type, materialNumber ?? null).then(()=>setRefreshing(false)); - }; +export const PartnerStockTable = ({ type, materialName, partnerStocks, onRefresh, isRefreshing }: PartnerStockTableProps) => { return (
row.uuid} hideFooter={true} >
- handleStockRefresh()} /> + onRefresh()} />
); }; diff --git a/frontend/src/features/stock-view/components/ProductStockView.tsx b/frontend/src/features/stock-view/components/ProductStockView.tsx deleted file mode 100644 index d2d9f473..00000000 --- a/frontend/src/features/stock-view/components/ProductStockView.tsx +++ /dev/null @@ -1,45 +0,0 @@ -/* -Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) -Copyright (c) 2024 Contributors to the Eclipse Foundation - -See the NOTICE file(s) distributed with this work for additional -information regarding copyright ownership. - -This program and the accompanying products are made available under the -terms of the Apache License, Version 2.0 which is available at -https://www.apache.org/licenses/LICENSE-2.0. - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations -under the License. - -SPDX-License-Identifier: Apache-2.0 -*/ - -import { useState } from 'react'; -import { StockUpdateForm } from './StockUpdateForm'; -import { PartnerStockTable } from './PartnerStockTable'; -import { StockTable } from './StockTable'; -import { useProducts } from '../hooks/useProducts'; -import { ProductStock } from '@models/types/data/stock'; - -export const ProductStockView = () => { - const { products } = useProducts(); - const [selectedProduct, setSelectedProduct] = useState(null); - return ( -
-
- -
- type='product' onSelection={setSelectedProduct} /> - -
- ); -} diff --git a/frontend/src/features/stock-view/components/StockDetailsView.tsx b/frontend/src/features/stock-view/components/StockDetailsView.tsx new file mode 100644 index 00000000..f94271c8 --- /dev/null +++ b/frontend/src/features/stock-view/components/StockDetailsView.tsx @@ -0,0 +1,92 @@ +/* +Copyright (c) 2024 Volkswagen AG +Copyright (c) 2024 Contributors to the Eclipse Foundation + +See the NOTICE file(s) distributed with this work for additional +information regarding copyright ownership. + +This program and the accompanying materials are made available under the +terms of the Apache License, Version 2.0 which is available at +https://www.apache.org/licenses/LICENSE-2.0. + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations +under the License. + +SPDX-License-Identifier: Apache-2.0 +*/ + +import { useState } from 'react'; + +import { Stock, StockType } from '@models/types/data/stock'; +import { postStocks, putStocks, refreshPartnerStocks } from '@services/stocks-service'; + +import { useMaterials } from '../hooks/useMaterials'; +import { StockUpdateForm } from './StockUpdateForm'; +import { PartnerStockTable } from './PartnerStockTable'; +import { StockTable } from './StockTable'; +import { useStocks } from '../hooks/useStocks'; +import { usePartnerStocks } from '../hooks/usePartnerStocks'; + +type StockDetailsViewProps = { + type: T; +}; + +export const StockDetailsView = ({ type }: StockDetailsViewProps) => { + const { materials } = useMaterials(type); + const { stocks, refreshStocks } = useStocks(type); + const [selectedMaterial, setSelectedMaterial] = useState(null); + const { partnerStocks, refreshPartnerStocks: refresh } = usePartnerStocks( + type, + type === 'product' ? selectedMaterial?.material?.materialNumberSupplier : selectedMaterial?.material?.materialNumberCustomer + ); + const [saving, setSaving] = useState(false); + const [refreshing, setRefreshing] = useState(false); + + const handleStockRefresh = () => { + setRefreshing(true); + refreshPartnerStocks( + type, + (type == 'product' ? selectedMaterial?.material?.materialNumberSupplier : selectedMaterial?.material?.materialNumberCustomer) ?? + null + ).then(() => { + refresh(); + setRefreshing(false); + }); + }; + + const saveStock = (stock: Stock) => { + if (saving) return; + stock.uuid ??= + stocks?.find( + (s) => + s.stockLocationBpna === stock.stockLocationBpna && + s.stockLocationBpns === stock.stockLocationBpns && + (s.material.materialNumberCustomer === stock.material.materialNumberCustomer || + s.material.materialNumberSupplier === stock.material.materialNumberSupplier) && + s.partner?.uuid === stock.partner?.uuid + )?.uuid ?? null; + (stock.uuid == null ? postStocks(type, stock) : putStocks(type, stock)).then(() => { + setSaving(false); + refreshStocks(); + }); + }; + + return ( +
+
+ +
+ + +
+ ); +}; diff --git a/frontend/src/features/stock-view/components/StockTable.tsx b/frontend/src/features/stock-view/components/StockTable.tsx index f124da04..223c8793 100644 --- a/frontend/src/features/stock-view/components/StockTable.tsx +++ b/frontend/src/features/stock-view/components/StockTable.tsx @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional @@ -20,20 +19,21 @@ SPDX-License-Identifier: Apache-2.0 */ import { Table } from '@catena-x/portal-shared-components'; -import { MaterialStock, ProductStock } from '@models/types/data/stock'; +import { Stock, StockType } from '@models/types/data/stock'; +import { capitalize } from '@mui/material'; import { getUnitOfMeasurement } from '@util/helpers'; -import { useStocks } from '../hooks/useStocks'; -type StockTableProps = { - type: 'material' | 'product'; - onSelection: (stock: T) => void; +type StockTableProps = { + type: StockType; + stocks: Stock[]; + onSelection: (stock: Stock) => void; }; -const createStockTableColumns = (type: 'material' | 'product') => [ +const createStockTableColumns = (type: StockType) => [ { field: 'materialNumber', - headerName: type === 'material' ? 'Material' : 'Product', - renderCell: (params: { row: MaterialStock }) => ( + headerName: capitalize(type), + renderCell: (params: { row: Stock }) => (
{params.row.material?.name} ({type === 'material' ? params.row.material?.materialNumberCustomer : params.row.material?.materialNumberSupplier}) @@ -43,13 +43,13 @@ const createStockTableColumns = (type: 'material' | 'product') => [ }, { field: 'quantity', - valueGetter: (data: { row: MaterialStock }) => data.row.quantity + ' ' + getUnitOfMeasurement(data.row.measurementUnit), + valueGetter: (data: { row: Stock }) => data.row.quantity + ' ' + getUnitOfMeasurement(data.row.measurementUnit), headerName: 'Quantity', flex: 2, }, { field: 'partner', - renderCell: (params: { row: MaterialStock }) => ( + renderCell: (params: { row: Stock }) => (
{params.row.partner?.name} ({params.row.partner?.bpnl}) @@ -89,8 +89,7 @@ const createStockTableColumns = (type: 'material' | 'product') => [ flex: 3, }, ]; -export const StockTable = ({ onSelection, type }: StockTableProps) => { - const { stocks } = useStocks(type); +export const StockTable = ({ onSelection, type, stocks }: StockTableProps) => { return ( ) => { + return stock?.material && stock?.partner && stock?.quantity && stock?.measurementUnit && stock?.stockLocationBpns && stock?.stockLocationBpna; +} -const stockReducer = ( - state: Partial | Partial, - action: { - type: 'replace' | keyof MaterialStock | keyof ProductStock; - payload: MaterialStock[keyof MaterialStock] | ProductStock[keyof ProductStock] | MaterialStock | ProductStock; - } -) => { - if (action.type === 'replace') { - return action.payload as MaterialStock | ProductStock; - } - return { - ...state, - [action.type]: action.payload, - }; +type StockUpdateFormProps = { + items: MaterialDescriptor[] | null; + type: T; + selectedItem: Stock | null; + isSaving: boolean; + onSubmit: (stock: Stock) => void; }; -export const StockUpdateForm = ({ items, type, selectedItem }: StockUpdateFormProps) => { +export const StockUpdateForm = ({ items, type, selectedItem, isSaving, onSubmit }: StockUpdateFormProps) => { const { sites } = useSites(); - const [saving, setSaving] = useState(false); + const stockReducer = ( + state: Partial, + action: { + type: keyof Stock | "replace"; + payload: Stock[keyof Stock] | Stock; + } + ) => { + if (action.type === 'replace') { + return action.payload as Stock; + } + return { + ...state, + [action.type]: action.payload as Stock[typeof action.type], + }; + }; const [newStock, dispatch] = useReducer(stockReducer, selectedItem ?? {}); const { partners } = usePartners( type, (type === 'material' ? newStock?.material?.materialNumberCustomer : newStock?.material?.materialNumberSupplier) ?? null ); - const handleSave = () => { - if (saving) return; - setSaving(true); - if (type === 'material') { - if (newStock.uuid) { - postMaterialStocks(newStock as MaterialStock).then(() => setSaving(false)); - } else { - putMaterialStocks(newStock as MaterialStock).then(() => setSaving(false)); - } - } else { - if (newStock.uuid) { - postProductStocks(newStock as ProductStock).then(() => setSaving(false)); - } else { - putProductStocks(newStock as ProductStock).then(() => setSaving(false)); - } - } - }; useEffect(() => { dispatch({ type: 'replace', payload: selectedItem }); }, [selectedItem]); - + const handleSubmit = () => { + if (validateStock(newStock)) { + onSubmit(newStock as Stock); + } + } return (
@@ -101,7 +92,7 @@ export const StockUpdateForm = ({ items, type, selectedItem }: StockUpdateFormPr } options={items ?? []} getOptionLabel={(option) => option.ownMaterialNumber ?? ''} - renderInput={(params) => } + renderInput={(params) => } onChange={(_, newValue) => dispatch({ type: 'material', @@ -124,7 +115,7 @@ export const StockUpdateForm = ({ items, type, selectedItem }: StockUpdateFormPr options={partners ?? []} getOptionLabel={(option) => option?.name ?? ''} renderInput={(params) => } - onChange={(_, value) => dispatch({ type: 'partner', payload: value ?? null })} + onChange={(_, value) => dispatch({ type: 'partner', payload: value ?? null})} />
@@ -134,7 +125,9 @@ export const StockUpdateForm = ({ items, type, selectedItem }: StockUpdateFormPr type="number" placeholder="Enter quantity" value={newStock?.quantity} - onChange={(event) => dispatch({ type: 'quantity', payload: event.target.value })} + onChange={(event) => + dispatch({ type: 'quantity', payload: event.target.value }) + } />
option?.value ?? ''} renderInput={(params) => } - onChange={(_, value) => dispatch({ type: 'measurementUnit', payload: value?.key ?? null })} + onChange={(_, value) => + dispatch({ type: 'measurementUnit', payload: value?.key ?? null }) + } />
@@ -165,14 +160,18 @@ export const StockUpdateForm = ({ items, type, selectedItem }: StockUpdateFormPr value={newStock?.stockLocationBpns ?? null} options={sites?.map((site) => site.bpns) ?? []} renderInput={(params) => } - onChange={(_, value) => dispatch({ type: 'stockLocationBpns', payload: value ?? null })} + onChange={(_, value) => + dispatch({ type: 'stockLocationBpns', payload: value ?? null }) + } /> site.bpns === newStock?.stockLocationBpns)?.addresses.map((addr) => addr.bpna) ?? []} renderInput={(params) => } - onChange={(_, value) => dispatch({ type: 'stockLocationBpna', payload: value ?? null })} + onChange={(_, value) => + dispatch({ type: 'stockLocationBpna', payload: value ?? null }) + } />
dispatch({ type: 'customerOrderNumber', payload: event.target.value })} + onChange={(event) => + dispatch({ type: 'customerOrderNumber', payload: event.target.value }) + } /> dispatch({ type: 'customerOrderPositionNumber', payload: event.target.value })} + onChange={(event) => + dispatch({ + type: 'customerOrderPositionNumber', + payload: event.target.value, + }) + } />
dispatch({ type: 'supplierOrderNumber', payload: event.target.value })} + onChange={(event) => + dispatch({ type: 'supplierOrderNumber', payload: event.target.value }) + } />
@@ -204,9 +212,9 @@ export const StockUpdateForm = ({ items, type, selectedItem }: StockUpdateFormPr className="w-full" variant="contained" color="primary" - loading={saving} + loading={isSaving} loadIndicator="Saving..." - onButtonClick={() => handleSave()} + onButtonClick={handleSubmit} label="Add or Update" fullWidth={true} > diff --git a/frontend/src/features/stock-view/hooks/useCustomerStocks.ts b/frontend/src/features/stock-view/hooks/useCustomerStocks.ts deleted file mode 100644 index 9c0acef6..00000000 --- a/frontend/src/features/stock-view/hooks/useCustomerStocks.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) -Copyright (c) 2024 Contributors to the Eclipse Foundation - -See the NOTICE file(s) distributed with this work for additional -information regarding copyright ownership. - -This program and the accompanying materials are made available under the -terms of the Apache License, Version 2.0 which is available at -https://www.apache.org/licenses/LICENSE-2.0. - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations -under the License. - -SPDX-License-Identifier: Apache-2.0 -*/ - -import { config } from '@models/constants/config'; -import { ProductStock } from '@models/types/data/stock'; -import { useFetch } from '@hooks/useFetch'; - -export const useCustomerStocks = (materialNumber?: string | null) => { - const { - data: customerStocks, - error: customerStocksError, - isLoading: isLoadingCustomerStocks, - } = useFetch(config.app.BACKEND_BASE_URL + config.app.ENDPOINT_REPORTED_PRODUCT_STOCKS + materialNumber); - return { - customerStocks, - customerStocksError, - isLoadingCustomerStocks, - }; -}; diff --git a/frontend/src/features/stock-view/hooks/useCustomers.ts b/frontend/src/features/stock-view/hooks/useCustomers.ts deleted file mode 100644 index b8cf7432..00000000 --- a/frontend/src/features/stock-view/hooks/useCustomers.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) -Copyright (c) 2024 Contributors to the Eclipse Foundation - -See the NOTICE file(s) distributed with this work for additional -information regarding copyright ownership. - -This program and the accompanying materials are made available under the -terms of the Apache License, Version 2.0 which is available at -https://www.apache.org/licenses/LICENSE-2.0. - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations -under the License. - -SPDX-License-Identifier: Apache-2.0 -*/ - -import { useFetch } from '@hooks/useFetch'; -import { config } from '@models/constants/config'; -import { Partner } from '@models/types/edc/partner'; - -export const useCustomers = (materialNumber: string) => { - const { data: customers, isLoading: isLoadingCustomers } = useFetch( - `${config.app.BACKEND_BASE_URL}${config.app.ENDPOINT_SUPPLIER}${materialNumber}` - ); - return { - customers, - isLoadingCustomers, - }; -} diff --git a/frontend/src/features/stock-view/hooks/useMaterials.ts b/frontend/src/features/stock-view/hooks/useMaterials.ts index 0b59e267..9258ffd1 100644 --- a/frontend/src/features/stock-view/hooks/useMaterials.ts +++ b/frontend/src/features/stock-view/hooks/useMaterials.ts @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional @@ -22,13 +21,15 @@ SPDX-License-Identifier: Apache-2.0 import { config } from '@models/constants/config'; import { MaterialDescriptor } from '@models/types/data/material-descriptor'; import { useFetch } from '@hooks/useFetch'; +import { StockType } from '@models/types/data/stock'; -export const useMaterials = () => { +export const useMaterials = (type: StockType) => { + const endpoint = type === 'material' ? config.app.ENDPOINT_MATERIALS : config.app.ENDPOINT_PRODUCTS; const { data: materials, error: materialsError, isLoading: isLoadingMaterials, - } = useFetch(config.app.BACKEND_BASE_URL + config.app.ENDPOINT_MATERIALS); + } = useFetch(config.app.BACKEND_BASE_URL + endpoint); return { materials, materialsError, diff --git a/frontend/src/features/stock-view/hooks/usePartnerStocks.ts b/frontend/src/features/stock-view/hooks/usePartnerStocks.ts index 1c64e783..6a16b92b 100644 --- a/frontend/src/features/stock-view/hooks/usePartnerStocks.ts +++ b/frontend/src/features/stock-view/hooks/usePartnerStocks.ts @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional @@ -20,19 +19,21 @@ SPDX-License-Identifier: Apache-2.0 */ import { config } from '@models/constants/config'; -import { MaterialStock, ProductStock } from '@models/types/data/stock'; +import { Stock, StockType } from '@models/types/data/stock'; import { useFetch } from '@hooks/useFetch'; -export const usePartnerStocks = (type: 'material' | 'product', materialNumber?: string | null) => { +export const usePartnerStocks = (type: T, materialNumber?: string | null) => { const url = type === 'material' ? config.app.ENDPOINT_REPORTED_MATERIAL_STOCKS : config.app.ENDPOINT_REPORTED_PRODUCT_STOCKS; const { data: partnerStocks, error: partnerStocksError, isLoading: isLoadingPartnerStocks, - } = useFetch(config.app.BACKEND_BASE_URL + url + materialNumber) + refresh: refreshPartnerStocks, + } = useFetch(config.app.BACKEND_BASE_URL + url + materialNumber) return { partnerStocks, partnerStocksError, isLoadingPartnerStocks, + refreshPartnerStocks, }; }; diff --git a/frontend/src/features/stock-view/hooks/usePartners.ts b/frontend/src/features/stock-view/hooks/usePartners.ts index 3141786b..cdfab62e 100644 --- a/frontend/src/features/stock-view/hooks/usePartners.ts +++ b/frontend/src/features/stock-view/hooks/usePartners.ts @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional diff --git a/frontend/src/features/stock-view/hooks/useProductStocks.ts b/frontend/src/features/stock-view/hooks/useProductStocks.ts deleted file mode 100644 index 075c62b6..00000000 --- a/frontend/src/features/stock-view/hooks/useProductStocks.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) -Copyright (c) 2024 Contributors to the Eclipse Foundation - -See the NOTICE file(s) distributed with this work for additional -information regarding copyright ownership. - -This program and the accompanying materials are made available under the -terms of the Apache License, Version 2.0 which is available at -https://www.apache.org/licenses/LICENSE-2.0. - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations -under the License. - -SPDX-License-Identifier: Apache-2.0 -*/ - -import { config } from '@models/constants/config'; -import { ProductStock } from '@models/types/data/stock'; -import { useFetch } from '@hooks/useFetch'; - -export const useProductStock = () => { - const { - data: productStocks, - error: productStocksError, - isLoading: isLoadingProductStocks, - } = useFetch(config.app.BACKEND_BASE_URL + config.app.ENDPOINT_PRODUCT_STOCKS); - return { - productStocks, - productStocksError, - isLoadingProductStocks, - }; -}; diff --git a/frontend/src/features/stock-view/hooks/useProducts.ts b/frontend/src/features/stock-view/hooks/useProducts.ts deleted file mode 100644 index 3b5e2d1a..00000000 --- a/frontend/src/features/stock-view/hooks/useProducts.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) -Copyright (c) 2024 Contributors to the Eclipse Foundation - -See the NOTICE file(s) distributed with this work for additional -information regarding copyright ownership. - -This program and the accompanying materials are made available under the -terms of the Apache License, Version 2.0 which is available at -https://www.apache.org/licenses/LICENSE-2.0. - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations -under the License. - -SPDX-License-Identifier: Apache-2.0 -*/ - -import { config } from '@models/constants/config'; -import { ProductDescriptor } from '@models/types/data/product-descriptor'; -import { useFetch } from '@hooks/useFetch'; - -export const useProducts = () => { - const { - data: products, - error: productsError, - isLoading: isLoadingProducts, - } = useFetch(config.app.BACKEND_BASE_URL + config.app.ENDPOINT_PRODUCTS); - return { - products, - productsError, - isLoadingProducts, - }; -} diff --git a/frontend/src/features/stock-view/hooks/useSites.ts b/frontend/src/features/stock-view/hooks/useSites.ts index 4dafb084..1369c559 100644 --- a/frontend/src/features/stock-view/hooks/useSites.ts +++ b/frontend/src/features/stock-view/hooks/useSites.ts @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional diff --git a/frontend/src/features/stock-view/hooks/useStocks.ts b/frontend/src/features/stock-view/hooks/useStocks.ts index 2269acfd..97667b08 100644 --- a/frontend/src/features/stock-view/hooks/useStocks.ts +++ b/frontend/src/features/stock-view/hooks/useStocks.ts @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional @@ -20,19 +19,22 @@ SPDX-License-Identifier: Apache-2.0 */ import { config } from '@models/constants/config'; -import { MaterialStock, ProductStock } from '@models/types/data/stock'; import { useFetch } from '@hooks/useFetch'; +import { Stock, StockType } from '@models/types/data/stock'; -export const useStocks = (type: 'material' | 'product') => { + +export const useStocks = (type: T) => { const url = type === 'material' ? config.app.ENDPOINT_MATERIAL_STOCKS : config.app.ENDPOINT_PRODUCT_STOCKS; const { data: stocks, error: stocksError, isLoading: isLoadingStocks, - } = useFetch(config.app.BACKEND_BASE_URL + url); + refresh: refreshStocks, + } = useFetch(config.app.BACKEND_BASE_URL + url); return { stocks, stocksError, isLoadingStocks, + refreshStocks, }; }; diff --git a/frontend/src/features/stock-view/hooks/useSuppliers.ts b/frontend/src/features/stock-view/hooks/useSuppliers.ts deleted file mode 100644 index 275a0995..00000000 --- a/frontend/src/features/stock-view/hooks/useSuppliers.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) -Copyright (c) 2024 Contributors to the Eclipse Foundation - -See the NOTICE file(s) distributed with this work for additional -information regarding copyright ownership. - -This program and the accompanying materials are made available under the -terms of the Apache License, Version 2.0 which is available at -https://www.apache.org/licenses/LICENSE-2.0. - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations -under the License. - -SPDX-License-Identifier: Apache-2.0 -*/ - -import { useFetch } from '@hooks/useFetch'; -import { config } from '@models/constants/config'; -import { Partner } from '@models/types/edc/partner'; - -export const useSuppliers = (materialNumber: string) => { - const { data: suppliers, isLoading: isLoadingSuppliers } = useFetch( - `${config.app.BACKEND_BASE_URL}${config.app.ENDPOINT_SUPPLIER}${materialNumber}` - ); - return { - suppliers, - isLoadingSuppliers, - }; -} diff --git a/frontend/src/hooks/edc/useCatalog.ts b/frontend/src/hooks/edc/useCatalog.ts index 1fa800d1..d9186b42 100644 --- a/frontend/src/hooks/edc/useCatalog.ts +++ b/frontend/src/hooks/edc/useCatalog.ts @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional diff --git a/frontend/src/hooks/edc/useNegotiations.ts b/frontend/src/hooks/edc/useNegotiations.ts index 9686511f..3d0bf0dc 100644 --- a/frontend/src/hooks/edc/useNegotiations.ts +++ b/frontend/src/hooks/edc/useNegotiations.ts @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional diff --git a/frontend/src/hooks/edc/useTransfers.ts b/frontend/src/hooks/edc/useTransfers.ts index 9619acae..725dba50 100644 --- a/frontend/src/hooks/edc/useTransfers.ts +++ b/frontend/src/hooks/edc/useTransfers.ts @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional diff --git a/frontend/src/hooks/useAuth.ts b/frontend/src/hooks/useAuth.ts index 060f0d56..3f890952 100644 --- a/frontend/src/hooks/useAuth.ts +++ b/frontend/src/hooks/useAuth.ts @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional diff --git a/frontend/src/hooks/useFetch.ts b/frontend/src/hooks/useFetch.ts index d2e37dd5..12888794 100644 --- a/frontend/src/hooks/useFetch.ts +++ b/frontend/src/hooks/useFetch.ts @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional @@ -19,7 +18,7 @@ under the License. SPDX-License-Identifier: Apache-2.0 */ -import { useEffect, useState } from 'react'; +import { useCallback, useEffect, useState } from 'react'; import { config } from '@models/constants/config'; const defaultHeaders = { @@ -32,7 +31,7 @@ export const useFetch = (url?: string, options?: RequestInit) => { const [error, setError] = useState(null); const [isLoading, setIsLoading] = useState(true); - useEffect(() => { + const fetchData = useCallback(async () => { if (!url) { setIsLoading(false); return; @@ -47,9 +46,11 @@ export const useFetch = (url?: string, options?: RequestInit) => { .then((data) => { if (shouldCancel) return; setData(data); + setError(null); }) .catch((err) => { if (shouldCancel) return; + setData(null); setError(err); }) .finally(() => setIsLoading(false)); @@ -57,9 +58,18 @@ export const useFetch = (url?: string, options?: RequestInit) => { shouldCancel = true; }; }, [url, options]); + + useEffect(() => { + fetchData(); + }, [fetchData]); + + const refresh = () => { + fetchData(); + } return { data, error, isLoading, + refresh, }; -} +}; diff --git a/frontend/src/models/constants/config.ts b/frontend/src/models/constants/config.ts index 7311ebb9..220ef1f6 100644 --- a/frontend/src/models/constants/config.ts +++ b/frontend/src/models/constants/config.ts @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional diff --git a/frontend/src/models/constants/roles.ts b/frontend/src/models/constants/roles.ts index 08463dad..28353cd6 100644 --- a/frontend/src/models/constants/roles.ts +++ b/frontend/src/models/constants/roles.ts @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional diff --git a/frontend/src/models/constants/uom.ts b/frontend/src/models/constants/uom.ts index ca944237..705bf61f 100644 --- a/frontend/src/models/constants/uom.ts +++ b/frontend/src/models/constants/uom.ts @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional @@ -19,7 +18,7 @@ under the License. SPDX-License-Identifier: Apache-2.0 */ -import stockViewUom from '../../assets/stockViewUom.json'; +import stockViewUom from '@assets/stockViewUom.json'; import { UnitOfMeasurement } from '../types/data/uom'; export const UNITS_OF_MEASUREMENT = stockViewUom as UnitOfMeasurement[]; diff --git a/frontend/src/models/types/auth/auth.ts b/frontend/src/models/types/auth/auth.ts index 2c2f53e5..e5186689 100644 --- a/frontend/src/models/types/auth/auth.ts +++ b/frontend/src/models/types/auth/auth.ts @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional diff --git a/frontend/src/models/types/auth/role.ts b/frontend/src/models/types/auth/role.ts index 731b24ab..3f8a5d3e 100644 --- a/frontend/src/models/types/auth/role.ts +++ b/frontend/src/models/types/auth/role.ts @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional @@ -19,6 +18,6 @@ under the License. SPDX-License-Identifier: Apache-2.0 */ -import { roles } from '../../constants/roles'; +import { roles } from '@models/constants/roles'; export type Role = (typeof roles)[number]; diff --git a/frontend/src/models/types/auth/user.ts b/frontend/src/models/types/auth/user.ts index a6234034..81cc0fed 100644 --- a/frontend/src/models/types/auth/user.ts +++ b/frontend/src/models/types/auth/user.ts @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional diff --git a/frontend/src/models/types/data/stock.ts b/frontend/src/models/types/data/stock.ts index b5748e99..0a4cea02 100644 --- a/frontend/src/models/types/data/stock.ts +++ b/frontend/src/models/types/data/stock.ts @@ -25,7 +25,9 @@ import { Partner } from '../edc/partner'; import { UnitOfMeasurementKey } from './uom'; type MaterialDetails = { - uuid: UUID | null; + uuid?: UUID | null; + materialFlag: boolean; + productFlag: boolean; materialNumberCustomer: string | null; materialNumberSupplier: string | null; materialNumberCx: string | null; @@ -33,7 +35,8 @@ type MaterialDetails = { }; export type Stock = { - uuid: UUID | null; + uuid?: UUID | null; + material: MaterialDetails quantity: number; measurementUnit: UnitOfMeasurementKey; stockLocationBpns: BPNS; @@ -46,16 +49,4 @@ export type Stock = { isBlocked: boolean; }; -export type MaterialStock = { - material: { - materialFlag: true; - productFlag: false; - } & MaterialDetails; -} & Stock; - -export type ProductStock = { - material: { - materialFlag: false; - productFlag: true; - } & MaterialDetails; -} & Stock; +export type StockType = 'material' | 'product'; diff --git a/frontend/src/services/stocks-service.ts b/frontend/src/services/stocks-service.ts index 86fee4e8..04c8dd56 100644 --- a/frontend/src/services/stocks-service.ts +++ b/frontend/src/services/stocks-service.ts @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional @@ -20,10 +19,11 @@ SPDX-License-Identifier: Apache-2.0 */ import { config } from '@models/constants/config'; -import { MaterialStock, ProductStock } from '@models/types/data/stock'; +import { Stock, StockType } from '@models/types/data/stock'; -export const postProductStocks =async (stock: ProductStock) => { - return fetch(config.app.BACKEND_BASE_URL + config.app.ENDPOINT_PRODUCT_STOCKS, { +export const postStocks = async (type: StockType, stock: Stock) => { + const endpoint = type === 'product' ? config.app.ENDPOINT_PRODUCT_STOCKS : config.app.ENDPOINT_MATERIAL_STOCKS; + return fetch(config.app.BACKEND_BASE_URL + endpoint, { method: 'POST', body: JSON.stringify(stock), headers: { @@ -33,8 +33,9 @@ export const postProductStocks =async (stock: ProductStock) => { }); } -export const putProductStocks = async (stock: ProductStock) => { - return fetch(config.app.BACKEND_BASE_URL + config.app.ENDPOINT_PRODUCT_STOCKS, { +export const putStocks = async (type: StockType, stock: Stock) => { + const endpoint = type === 'product' ? config.app.ENDPOINT_PRODUCT_STOCKS : config.app.ENDPOINT_MATERIAL_STOCKS; + return fetch(config.app.BACKEND_BASE_URL + endpoint, { method: 'PUT', body: JSON.stringify(stock), headers: { @@ -44,29 +45,7 @@ export const putProductStocks = async (stock: ProductStock) => { }); } -export const postMaterialStocks = async (stock: MaterialStock) => { - return fetch(config.app.BACKEND_BASE_URL + config.app.ENDPOINT_MATERIAL_STOCKS, { - method: 'POST', - body: JSON.stringify(stock), - headers: { - 'Content-Type': 'application/json', - 'X-API-KEY': config.app.BACKEND_API_KEY, - }, - }); -} - -export const putMaterialStocks = async (stock: MaterialStock) => { - return fetch(config.app.BACKEND_BASE_URL + config.app.ENDPOINT_MATERIAL_STOCKS, { - method: 'PUT', - body: JSON.stringify(stock), - headers: { - 'Content-Type': 'application/json', - 'X-API-KEY': config.app.BACKEND_API_KEY, - }, - }); -} - -export const refreshPartnerStocks = (type: 'material' | 'product', materialNumber: string | null) => { +export const refreshPartnerStocks = (type: StockType, materialNumber: string | null) => { const endpoint = type === 'product' ? config.app.ENDPOINT_UPDATE_REPORTED_PRODUCT_STOCKS : config.app.ENDPOINT_UPDATE_REPORTED_MATERIAL_STOCKS; return fetch(`${config.app.BACKEND_BASE_URL}${endpoint}${materialNumber}`, { method: 'GET', diff --git a/frontend/src/util/helpers.ts b/frontend/src/util/helpers.ts index 7d3e9808..263f3f6c 100644 --- a/frontend/src/util/helpers.ts +++ b/frontend/src/util/helpers.ts @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional diff --git a/frontend/src/views/AboutLicenseView.tsx b/frontend/src/views/AboutLicenseView.tsx index 37108f2b..bb7a2489 100644 --- a/frontend/src/views/AboutLicenseView.tsx +++ b/frontend/src/views/AboutLicenseView.tsx @@ -1,7 +1,7 @@ /* -Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) -Copyright (c) 2024 Contributors to the Eclipse Foundation +Copyright (c) 2023-2024 Volkswagen AG +Copyright (c) 2023-2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) +Copyright (c) 2023-2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional information regarding copyright ownership. diff --git a/frontend/src/views/CatalogView.tsx b/frontend/src/views/CatalogView.tsx index 9a5b8b84..4a4c141e 100644 --- a/frontend/src/views/CatalogView.tsx +++ b/frontend/src/views/CatalogView.tsx @@ -1,7 +1,7 @@ /* -Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) -Copyright (c) 2024 Contributors to the Eclipse Foundation +Copyright (c) 2023-2024 Volkswagen AG +Copyright (c) 2023-2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) +Copyright (c) 2023-2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional information regarding copyright ownership. diff --git a/frontend/src/views/NegotiationView.tsx b/frontend/src/views/NegotiationView.tsx index 7cc2a304..fb9958c6 100644 --- a/frontend/src/views/NegotiationView.tsx +++ b/frontend/src/views/NegotiationView.tsx @@ -1,7 +1,7 @@ /* -Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) -Copyright (c) 2024 Contributors to the Eclipse Foundation +Copyright (c) 2023-2024 Volkswagen AG +Copyright (c) 2023-2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) +Copyright (c) 2023-2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional information regarding copyright ownership. @@ -19,24 +19,65 @@ under the License. SPDX-License-Identifier: Apache-2.0 */ +import Card from '@mui/material/Card'; + import { useNegotiations } from '@hooks/edc/useNegotiations'; +import { Negotiation } from '@models/types/edc/negotiation'; + +type NegotiationCardProps = { + negotiation: Negotiation; +}; + +const NegotiationCard = ({negotiation }: NegotiationCardProps) => { + return ( + +

Negotiation

+
+
+
+ Negotiation Id: + {negotiation['@id']} +
+
+ Aggreement Id: + {negotiation['edc:contractAgreementId']} +
+
+ Type: + {negotiation['edc:type']} +
+
+ State: + {negotiation['edc:state']} +
+
+ CounterParty: + {negotiation['edc:counterPartyId']} +
+
+ Counterparty EDC URL: + {negotiation['edc:counterPartyAddress']} +
+
+ Timestamp: + {new Date(negotiation['edc:createdAt']).toLocaleString()} +
+
+
+
+ ); +}; export const NegotiationView = () => { const { negotiations } = useNegotiations(); return (

Negotiation

-
    +
      {negotiations && negotiations.length > 0 ? ( negotiations.map((negotiation) => (
    • -

      Transfer Id: {negotiation['@id']}

      - Agreement Id: {negotiation['edc:contractAgreementId']} - Type: {negotiation['edc:type']} - State: {negotiation['edc:state']} - Counterparty: {negotiation['edc:counterPartyId']} - Counterparty EDC URL: {negotiation['edc:counterPartyAddress']} - Timestamp: {negotiation['edc:createdAt']} +
    • )) ) : ( diff --git a/frontend/src/views/StockView.tsx b/frontend/src/views/StockView.tsx index 044b08ff..6f89a2a7 100644 --- a/frontend/src/views/StockView.tsx +++ b/frontend/src/views/StockView.tsx @@ -21,9 +21,8 @@ SPDX-License-Identifier: Apache-2.0 import { useState } from 'react'; import { Tab, TabPanel, Tabs } from '@catena-x/portal-shared-components'; -import { MaterialStockView } from '@features/stock-view/components/MaterialStockView'; import { ConfidentialBanner } from '@components/ConfidentialBanner'; -import { ProductStockView } from '@features/stock-view/components/ProductStockView'; +import { StockDetailsView } from '@features/stock-view/components/StockDetailsView'; export const StockView = () => { const [selectedTab, setSelectedTab] = useState(0); @@ -38,13 +37,13 @@ export const StockView = () => {
      - + - +
); -} +}; diff --git a/frontend/src/views/SupplierDashboardView.tsx b/frontend/src/views/SupplierDashboardView.tsx index bcd892f8..5ab49cf3 100644 --- a/frontend/src/views/SupplierDashboardView.tsx +++ b/frontend/src/views/SupplierDashboardView.tsx @@ -1,7 +1,7 @@ /* -Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) -Copyright (c) 2024 Contributors to the Eclipse Foundation +Copyright (c) 2023-2024 Volkswagen AG +Copyright (c) 2023-2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) +Copyright (c) 2023-2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional information regarding copyright ownership. diff --git a/frontend/src/views/TransferView.tsx b/frontend/src/views/TransferView.tsx index 5b3e8183..fb723301 100644 --- a/frontend/src/views/TransferView.tsx +++ b/frontend/src/views/TransferView.tsx @@ -1,7 +1,7 @@ /* -Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) -Copyright (c) 2024 Contributors to the Eclipse Foundation +Copyright (c) 2022-2024 Volkswagen AG +Copyright (c) 2022-2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) +Copyright (c) 2022-2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional information regarding copyright ownership. @@ -19,25 +19,69 @@ under the License. SPDX-License-Identifier: Apache-2.0 */ +import Card from '@mui/material/Card'; + import { useTransfers } from '@hooks/edc/useTransfers'; +import { Transfer } from '@models/types/edc/transfer'; + +type TransferCardProps = { + transfer: Transfer; +}; + +const TransferCard = ({ transfer }: TransferCardProps) => { + return ( + +

Transfer

+
+
+
+ Transfer Id: + {transfer['@id']} +
+
+ Correlation Id: + {transfer['edc:correlationId']} +
+
+ State: + {transfer['edc:state']} +
+
+ State Timestamp: + {new Date(transfer['edc:stateTimestamp']).toLocaleString()} +
+
+ Type: + {transfer['edc:type']} +
+
+ Asset Id: + {transfer['edc:assetId']} +
+
+ Contract Id: + {transfer['edc:contractId']} +
+
+ Connector Id: + {transfer['edc:connectorId']} +
+
+
+
+ ); +}; export const TransferView = () => { const { transfers } = useTransfers(); return (

Transfers

-
    +
      {transfers && transfers.length > 0 ? ( transfers.map((transfer) => (
    • -

      Transfer Id: {transfer['@id']}

      - Correlation Id: {transfer['edc:correlationId']} - State: {transfer['edc:state']} - State Timestamp: {transfer['edc:stateTimestamp']} - Type: {transfer['edc:type']} - Asset Id: {transfer['edc:assetId']} - Contract Id: {transfer['edc:contractId']} - Connector Id: {transfer['edc:connectorId']} +
    • )) ) : ( @@ -46,4 +90,4 @@ export const TransferView = () => {
); -} +}; diff --git a/frontend/src/views/errors/ErrorView.tsx b/frontend/src/views/errors/ErrorView.tsx index 7a975fc1..6c305008 100644 --- a/frontend/src/views/errors/ErrorView.tsx +++ b/frontend/src/views/errors/ErrorView.tsx @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional diff --git a/frontend/src/views/errors/NotFoundView.tsx b/frontend/src/views/errors/NotFoundView.tsx index 58d8ba59..59e605f4 100644 --- a/frontend/src/views/errors/NotFoundView.tsx +++ b/frontend/src/views/errors/NotFoundView.tsx @@ -1,6 +1,5 @@ /* Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) Copyright (c) 2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional diff --git a/frontend/src/views/errors/UnauthorizedView.tsx b/frontend/src/views/errors/UnauthorizedView.tsx index 85835951..e7662229 100644 --- a/frontend/src/views/errors/UnauthorizedView.tsx +++ b/frontend/src/views/errors/UnauthorizedView.tsx @@ -1,7 +1,6 @@ /* -Copyright (c) 2024 Volkswagen AG -Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) -Copyright (c) 2024 Contributors to the Eclipse Foundation +Copyright (c) 2023-2024 Volkswagen AG +Copyright (c) 2023-2024 Contributors to the Eclipse Foundation See the NOTICE file(s) distributed with this work for additional information regarding copyright ownership.