feat: added edit functionality for demand dialog#1028
feat: added edit functionality for demand dialog#1028tom-rm-meyer-ISST merged 13 commits intoeclipse-tractusx:feat/edit-modalsfrom
Conversation
| <FormLabel sx={{ marginBottom: '.5rem', display: 'block' }}>Day*</FormLabel> | ||
| <div className="date-picker" data-testid="demand-day-field"> | ||
| <Datepicker | ||
| id="day" |
There was a problem hiding this comment.
Hi @tom-rm-meyer-ISST ,
I have implemented the Edit functionality for the Demand modal, similar to how it works for the Stock modal.
All required fields are set as editable, based on the specifications mentioned in the ticket, and the functionality is working as expected.
However, I’m encountering an issue with the Day field:
- The API response does return a value for
day, but for some reason, it’s not being patched into the form when attempting to edit a specific record. - I’ve already collaborated with a colleague and we’ve tried multiple approaches to resolve it, but the issue persists.
If you have any suggestions or can assist in looking into this issue, it would be greatly appreciated.
There was a problem hiding this comment.
Hi @tom,
We are using : import { DateType, Datepicker } from '@catena-x/portal-shared-components'; for the date and time handling.
After reviewing the Catena-X Datepicker implementation, we noticed that it maintains its own internal state
and only initializes that state from the defaultvalue prop using an internal useEffect. Because of this design, the value prop passed from the parent component is ignored during the initial render.
For ex (current code):
<Datepicker value={date?.toISOString().split('T')[0]} /> does not prefill the date properly on mount, since the component never updates its internal state based onthe value prop.
During our R&D, we observed that using defaultvalue (instead of value ) allows the date to prefill correctly on initial render. It appears that the Datepicker expects defaultvalue for initialization and only becomes responsive to user changes after that.
Below are the changes we applied:
function formatDateYYYYMMDD(date: string | Date): string {
if(typeof date === "string" ){
return date.split('T')[0];
}
const d = date;
const year = d.getFullYear();
const month = String(d.getMonth() + 1).padStart(2, "0");
const day = String(d.getDate()).padStart(2, "0");
return ${year}-${month}-${day};
}
const formattedDefault = useMemo(() => {
if (!value) return undefined;
return new Date(formatDateYYYYMMDD(value));
}, [value]);
return (
<Stack width="100%">
<FormLabel>{props.label}</FormLabel>
<div className="date-time-picker">
<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}
// value={date?.toISOString().split('T')[0]}
defaultValue={formattedDefault} --> new Code
readOnly={false}
onChangeItem={(event) => handleDateChange(event)}
/>
</Box>
I have tested this locally, and it works fine - the date now prefills correctly on initial render and updates properly when changed.
Please review these changes and let me know if you have any additional suggestions or alternative
approaches.
There was a problem hiding this comment.
Thanks for the investigation! I don't see the need for the formatting. Using the defaultValue only works fine in the modal during local test.
tom-rm-meyer-ISST
left a comment
There was a problem hiding this comment.
Thanks for your work!
Please merge the feature branch / rebase.
Please recheck your license headers:
- ADD IAV 2025 as copyright holder to changed files.
- ADD only IAV, contributors to EF 2025 as copyright holder to new files.
Some other findings you can see via comments - thanks in advance!
| <FormLabel sx={{ marginBottom: '.5rem', display: 'block' }}>Day*</FormLabel> | ||
| <div className="date-picker" data-testid="demand-day-field"> | ||
| <Datepicker | ||
| id="day" |
There was a problem hiding this comment.
Thanks for the investigation! I don't see the need for the formatting. Using the defaultValue only works fine in the modal during local test.
|
Thanks for the detailed review and comments. As suggested, I have made the changes and committed them in this branch. I request you to kindly review the updates and let me know if anything further is required. |
tom-rm-meyer-ISST
left a comment
There was a problem hiding this comment.
Answered comment, checked rest. If you incorporate that small change as proposed, I gonna merge.
sorry for delays. If you're out, please let me know. Then I merge and do the rest myself on the feature branch
tom-rm-meyer-ISST
left a comment
There was a problem hiding this comment.
LGTM, thanks a lot!
dc70b36
into
eclipse-tractusx:feat/edit-modals
* feat: implemented update logic for deliveries (#1004) * feat: implemented update logic for deliveries * fix: bug in validation logic * fix: improved feedback for invalid inputs * fix: arrival-type validations * feat(material details view): add edit functionality for stock modals (#1026) * Implemented Edit functionality for Stock dialog * updated entry in changelog * 1022 PR (Edit stock Modal) changes * Removed mode from dataModal for Stock * resolved quantity update issue for stock modal * resolved update quantity stock issue * feat: added edit functionality for demand dialog (#1028) * Added Edit functionality for Demand modal * Added entry for demand modal * Demand modal Date patched changes * Implemented edit functionality for Stock modal * resolved quantity update issue for demand modal * Revert "Implemented edit functionality for Stock modal" This reverts commit 53b4b44. * Revert "feat(material-details view): added material no. (#1005)" This reverts commit 13a5488. * PR #1028 review changes * Fixed date patch issue * Hide edit for reported demand * feat: add edit functionality for production modal (#1037) * Implemented edit functionality for Production modal * Added entry for production modal in changelog * Typo correction * Made PR1037 review changes * Hide edid for reported productions * chore: fix merge faults * fix: don't allow editation for reported stocks * docs(user guide): added update modal features (#1070) * chore: correct IAV company name in license header --------- Co-authored-by: René Schröder <131770181+ReneSchroederLJ@users.noreply.github.com> Co-authored-by: Akash-IAV <extern.akash.pandit@iav.de>
Description
resolves #1009
Pre-review checks
Please ensure to do as many of the following checks as possible, before asking for committer review: