Skip to content

Commit

Permalink
Merge branch 'main' into feat/187-membership-credential
Browse files Browse the repository at this point in the history
  • Loading branch information
f-zimmer authored Apr 19, 2024
2 parents 2526342 + f2b6565 commit 7bb1d3a
Show file tree
Hide file tree
Showing 17 changed files with 770 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ public boolean validate(OwnDemand demand) {
demand.getDay() != null &&
demand.getDemandCategoryCode() != null &&
demand.getDemandLocationBpns() != null &&
demand.getSupplierLocationBpns() != null &&
!demand.getPartner().equals(ownPartnerEntity) &&
ownPartnerEntity.getSites().stream().anyMatch(site -> site.getBpns().equals(demand.getDemandLocationBpns())) &&
demand.getPartner().getSites().stream().anyMatch(site -> site.getBpns().equals(demand.getSupplierLocationBpns()));
(demand.getSupplierLocationBpns() == null || demand.getPartner().getSites().stream().anyMatch(site -> site.getBpns().equals(demand.getSupplierLocationBpns())));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ public boolean validate(ReportedDemand demand) {
demand.getDay() != null &&
demand.getDemandCategoryCode() != null &&
demand.getDemandLocationBpns() != null &&
demand.getSupplierLocationBpns() != null &&
!demand.getPartner().equals(ownPartnerEntity) &&
ownPartnerEntity.getSites().stream().anyMatch(site -> site.getBpns().equals(demand.getSupplierLocationBpns())) &&
(demand.getSupplierLocationBpns() == null || ownPartnerEntity.getSites().stream().anyMatch(site -> site.getBpns().equals(demand.getSupplierLocationBpns()))) &&
demand.getPartner().getSites().stream().anyMatch(site -> site.getBpns().equals(demand.getDemandLocationBpns()));
}
}
1 change: 1 addition & 0 deletions frontend/.env
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ VITE_ENDPOINT_REPORTED_PRODUCT_STOCKS=stockView/reported-product-stocks?ownMater
VITE_ENDPOINT_UPDATE_REPORTED_MATERIAL_STOCKS=stockView/update-reported-material-stocks?ownMaterialNumber=
VITE_ENDPOINT_UPDATE_REPORTED_PRODUCT_STOCKS=stockView/update-reported-product-stocks?ownMaterialNumber=
VITE_ENDPOINT_PARTNER_OWNSITES=partners/ownSites
VITE_ENDPOINT_DEMAND=demand
VITE_ENDPOINT_PRODUCTION=production
VITE_ENDPOINT_PRODUCTION_RANGE=production/range

Expand Down
3 changes: 3 additions & 0 deletions frontend/.env.dockerbuild
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ VITE_ENDPOINT_REPORTED_PRODUCT_STOCKS=\$ENDPOINT_REPORTED_PRODUCT_STOCKS
VITE_ENDPOINT_UPDATE_REPORTED_MATERIAL_STOCKS=\$ENDPOINT_UPDATE_REPORTED_MATERIAL_STOCKS
VITE_ENDPOINT_UPDATE_REPORTED_PRODUCT_STOCKS=\$ENDPOINT_UPDATE_REPORTED_PRODUCT_STOCKS
VITE_ENDPOINT_PARTNER_OWNSITES=\$ENDPOINT_PARTNER_OWNSITES
VITE_ENDPOINT_DEMAND=\$ENDPOINT_DEMAND
VITE_ENDPOINT_PRODUCTION=\$ENDPOINT_PRODUCTION
VITE_ENDPOINT_PRODUCTION_RANGE=\$ENDPOINT_PRODUCTION_RANGE

VITE_IDP_DISABLE=\$IDP_DISABLE
VITE_IDP_URL=\$IDP_URL
Expand Down
42 changes: 37 additions & 5 deletions frontend/src/features/dashboard/components/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,18 @@ import { Box, Button, Stack, Typography, capitalize } from '@mui/material';
import { Delivery } from '@models/types/data/delivery';
import { DeliveryInformationModal } from './DeliveryInformationModal';
import { getPartnerType } from '../util/helpers';
import { LoadingButton } from '@catena-x/portal-shared-components';
import { Refresh } from '@mui/icons-material';
import { Demand } from '@models/types/data/demand';
import { DemandCategoryModal } from './DemandCategoryModal';
import { DEMAND_CATEGORY } from '@models/constants/demand-category';
import { useDemand } from '../hooks/useDemand';
import { useReportedDemand } from '../hooks/useReportedDemand';
import { Production } from '@models/types/data/production';
import { PlannedProductionModal } from './PlannedProductionModal';
import { useProduction } from '../hooks/useProduction';
import { useReportedProduction } from '../hooks/useReportedProduction';
import { LoadingButton } from '@catena-x/portal-shared-components';
import { Refresh } from '@mui/icons-material';

import { refreshPartnerStocks } from '@services/stocks-service';

const NUMBER_OF_DAYS = 28;
Expand All @@ -44,8 +50,10 @@ type DashboardState = {
selectedSite: Site | null;
selectedPartnerSites: Site[] | null;
deliveryDialogOptions: { open: boolean; mode: 'create' | 'edit' };
demandDialogOptions: { open: boolean; mode: 'create' | 'edit' };
productionDialogOptions: { open: boolean; mode: 'create' | 'edit' };
delivery: Delivery | null;
demand: Partial<Demand> | null;
production: Partial<Production> | null;
isRefreshing: boolean;
};
Expand All @@ -64,8 +72,10 @@ const initialState: DashboardState = {
selectedSite: null,
selectedPartnerSites: null,
deliveryDialogOptions: { open: false, mode: 'create' },
demandDialogOptions: { open: false, mode: 'edit' },
productionDialogOptions: { open: false, mode: 'edit' },
delivery: null,
demand: null,
production: null,
isRefreshing: false,
};
Expand All @@ -77,6 +87,8 @@ export const Dashboard = ({ type }: { type: 'customer' | 'supplier' }) => {
type === 'customer' ? 'material' : 'product',
state.selectedMaterial?.ownMaterialNumber ?? null
);
const { demands, refreshDemand } = useDemand(state.selectedMaterial?.ownMaterialNumber ?? null, state.selectedSite?.bpns ?? null);
const { reportedDemands } = useReportedDemand(state.selectedMaterial?.ownMaterialNumber ?? null);
const { productions, refreshProduction } = useProduction(
state.selectedMaterial?.ownMaterialNumber ?? null,
state.selectedSite?.bpns ?? null
Expand All @@ -90,8 +102,15 @@ export const Dashboard = ({ type }: { type: 'customer' | 'supplier' }) => {
.finally(() => dispatch({ type: 'isRefreshing', payload: false }));
};
const openDeliveryDialog = (d: Partial<Delivery>) => {
dispatch({ type: 'delivery', payload: d });
dispatch({ type: 'deliveryDialogOptions', payload: { open: true, mode: 'edit' } });
dispatch({ type: 'delivery', payload: d });
dispatch({ type: 'deliveryDialogOptions', payload: { open: true, mode: 'edit' } });
};
const openDemandDialog = (d: Partial<Demand>, mode: 'create' | 'edit') => {
d.measurementUnit ??= 'unit:piece';
d.demandCategoryCode ??= DEMAND_CATEGORY[0]?.key;
d.ownMaterialNumber = state.selectedMaterial?.ownMaterialNumber ?? '';
dispatch({ type: 'demand', payload: d });
dispatch({ type: 'demandDialogOptions', payload: { open: true, mode } });
};
const openProductionDialog = (p: Partial<Production>, mode: 'create' | 'edit') => {
p.material ??= {
Expand Down Expand Up @@ -145,6 +164,8 @@ export const Dashboard = ({ type }: { type: 'customer' | 'supplier' }) => {
stocks={stocks}
site={state.selectedSite}
onDeliveryClick={openDeliveryDialog}
onDemandClick={openDemandDialog}
demands={demands}
/>
)
) : (
Expand Down Expand Up @@ -189,6 +210,9 @@ export const Dashboard = ({ type }: { type: 'customer' | 'supplier' }) => {
stocks={partnerStocks}
site={ps}
onDeliveryClick={openDeliveryDialog}
onDemandClick={openDemandDialog}
demands={reportedDemands?.filter((d) => d.demandLocationBpns === ps.bpns) ?? []}
readOnly
/>
) : (
<ProductionTable
Expand Down Expand Up @@ -219,6 +243,14 @@ export const Dashboard = ({ type }: { type: 'customer' | 'supplier' }) => {
}
delivery={state.delivery}
/>
<DemandCategoryModal
open={state.demandDialogOptions.open}
mode={state.demandDialogOptions.mode}
onClose={() => dispatch({ type: 'demandDialogOptions', payload: { open: false, mode: state.demandDialogOptions.mode } })}
onSave={refreshDemand}
demand={state.demand}
demands={demands ?? []}
/>
<PlannedProductionModal
{...state.productionDialogOptions}
onClose={() => dispatch({ type: 'productionDialogOptions', payload: { open: false, mode: state.productionDialogOptions.mode } })}
Expand All @@ -228,4 +260,4 @@ export const Dashboard = ({ type }: { type: 'customer' | 'supplier' }) => {
/>
</>
);
};
}
Loading

0 comments on commit 7bb1d3a

Please sign in to comment.