Skip to content

Commit

Permalink
Merge branch 'main' into feat/delivery-information
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminKotnik authored Apr 18, 2024
2 parents 1d79a4c + 1822e58 commit e2304ad
Show file tree
Hide file tree
Showing 26 changed files with 1,010 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,10 @@ public boolean validate(OwnProduction production) {
ownPartnerEntity.getSites().stream().anyMatch(site -> site.getBpns().equals(production.getProductionSiteBpns())) &&
((
production.getCustomerOrderNumber() != null &&
production.getCustomerOrderPositionNumber() != null &&
production.getSupplierOrderNumber() != null
production.getCustomerOrderPositionNumber() != null
) || (
production.getCustomerOrderNumber() == null &&
production.getCustomerOrderPositionNumber() == null &&
production.getCustomerOrderPositionNumber() == null &&
production.getSupplierOrderNumber() == null
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,10 @@ public boolean validate(ReportedProduction production) {
production.getPartner().getSites().stream().anyMatch(site -> site.getBpns().equals(production.getProductionSiteBpns())) &&
((
production.getCustomerOrderNumber() != null &&
production.getCustomerOrderPositionNumber() != null &&
production.getSupplierOrderNumber() != null
production.getCustomerOrderPositionNumber() != null
) || (
production.getCustomerOrderNumber() == null &&
production.getCustomerOrderPositionNumber() == null &&
production.getCustomerOrderPositionNumber() == null &&
production.getSupplierOrderNumber() == null
));
}
Expand Down
2 changes: 2 additions & 0 deletions frontend/.env
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ 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_PRODUCTION=production
VITE_ENDPOINT_PRODUCTION_RANGE=production/range

VITE_IDP_DISABLE=true
VITE_IDP_URL=http://localhost:10081/
Expand Down
1 change: 1 addition & 0 deletions frontend/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ http {
limit_req zone=zoneLimit burst=${NGINX_BURST} nodelay;
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
}
}
3 changes: 2 additions & 1 deletion frontend/src/components/TableWithRowHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ export const TableWithRowHeader = ({ rows, ...tableProps }: TableWithRowHeaderPr
title=''
columns={[{ field: 'name', headerName: '', width: 180 }]}
rows={rows}
density='standard'
rowSelection={false}
hideFooter={true}
disableColumnFilter
disableColumnMenu
sortingMode={'server'}
/>
<Box sx={{width: '100%', display: 'flex', overflowX: 'auto'}}>
<Table {...tableProps} rows={rows} disableColumnFilter disableColumnMenu sortingMode={'server'} showCellVerticalBorder showColumnVerticalBorder />
<Table {...tableProps} rows={rows} density='standard' disableColumnFilter disableColumnMenu sortingMode={'server'} showCellVerticalBorder showColumnVerticalBorder />
</Box>
</div>
</Box>
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/layout/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ type SideBarItemProps = (
};

const sideBarItems: SideBarItemProps[] = [
{
name: 'Dashboard',
icon: HomeIcon,
path: '/dashboard',
},
{
name: 'Stocks',
icon: StockIcon,
Expand All @@ -68,11 +73,6 @@ const sideBarItems: SideBarItemProps[] = [
path: '/transfers',
requiredRoles: ['PURIS_ADMIN'],
},
{
name: 'Supplier Dashboard',
icon: HomeIcon,
path: '/supplierDashboard',
},
{
name: 'Logout',
icon: TrashIcon,
Expand Down
99 changes: 99 additions & 0 deletions frontend/src/components/ui/DateTime.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
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 { DateType, Datepicker } from '@catena-x/portal-shared-components';
import Box from '@mui/material/Box';
import { useEffect, useRef, useState } from 'react';

const isValidTime = (time?: string) => {
if (!time) {
return false;
}
const splits = time.split(':');
if (splits.length !== 2) {
return false;
}
const [hours, minutes] = splits;
return parseInt(hours) >= 0 && parseInt(hours) <= 23 && parseInt(minutes) >= 0 && parseInt(minutes) <= 59;
};

type DateTimeProps = {
label: string;
placeholder: string;
locale: 'en' | 'de';
error: boolean;
value: Date | null;
onValueChange: (date: Date | null) => void;
};

export const DateTime = ({ error, value, onValueChange, ...props }: DateTimeProps) => {
const [date, setDate] = useState<Date | null>(value ? new Date(value) : null);
const timeRef = useRef<HTMLInputElement>(null);
const handleTimeChange = () => {
const time = timeRef.current?.value;
if (time && date) {
const [hours, minutes] = time.split(':');
const newDate = new Date(date);
newDate.setHours(parseInt(hours));
newDate.setMinutes(parseInt(minutes));
onValueChange(newDate);
} else {
onValueChange(null);
}
};
const handleDateChange = (newDate: DateType) => {
setDate(newDate);
if (newDate && timeRef.current) {
onValueChange(new Date(newDate));
} else {
onValueChange(null);
}
};

useEffect(() => {
if (value) {
const d = new Date(value);
setDate(d);
const hours = d.getHours().toString().padStart(2, '0');
const minutes = d.getMinutes().toString().padStart(2, '0');
timeRef.current!.value = `${hours}:${minutes}`;
}
}, [value]);
return (
<Box display="flex" gap=".25rem" width="100%" marginTop="auto">
<Box display="flex" flexGrow="1" sx={{ '& .MuiFormControl-root, & .MuiBox-root': { minWidth: '100% !important' } }}>
<Datepicker
{...props}
error={error && !date}
value={date?.toISOString().split('T')[0]}
readOnly={false}
onChangeItem={(event) => handleDateChange(event)}
/>
</Box>
<input
ref={timeRef}
className={`${error && !isValidTime(timeRef.current?.value) ? 'error' : ''}`}
type="time"
id={"time"+props.label.toLowerCase()}
name={"etoc"+props.label.toLowerCase()}
onChange={handleTimeChange}
/>
</Box>
);
};
Loading

0 comments on commit e2304ad

Please sign in to comment.