From 8938d663d0b96bf0b2bfc564914bede7ae3b9de5 Mon Sep 17 00:00:00 2001 From: yenugukeerthana <96348559+yenugukeerthana@users.noreply.github.com> Date: Wed, 11 Oct 2023 12:52:33 +0530 Subject: [PATCH] GOK-394 | Fix Feedback received for Inward API (#52) * Fix. Feedback received for Inward API Co-authored-by: deeptirawat1510 --- src/inventory/aushada/aushada.jsx | 50 +++++++++++++---------- src/inventory/aushada/aushada.module.scss | 3 ++ 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/inventory/aushada/aushada.jsx b/src/inventory/aushada/aushada.jsx index b0e6c13..945a5dc 100644 --- a/src/inventory/aushada/aushada.jsx +++ b/src/inventory/aushada/aushada.jsx @@ -70,6 +70,7 @@ const Aushada = (props) => { const [instituteId, setInstituteId] = useState([]); const [instituteIdExists, setInstituteIdExists] = useState(false); const locationUuid = cookies[locationCookieName].uuid; + const [isTableVisible, setIsTableVisible] = useState(false); const { data: stockRoom, error: stockRoomError } = useSWR( stockRoomURL(cookies[locationCookieName]?.name.trim()), @@ -151,6 +152,7 @@ const Aushada = (props) => { }; fetchData(); } + setIsTableVisible(true); } }, [stockIntakeButtonClick, outwardNumber,selectedDate,instituteId,items]); @@ -177,7 +179,6 @@ const Aushada = (props) => { if (items.length > 0) { setIsOutwardNumberDisabled(true); - setIsFetchStockDisabled(true); } }, [items, outwardNumber, isDateSelected,instituteIdExists]); @@ -243,7 +244,19 @@ const Aushada = (props) => { const handleDateChange = (date) => { setSelectedDate(date[0]); setIsDateSelected(true); + setStockIntakeButtonClick(false); }; + useEffect(() => { + setIsTableVisible(false); + setItems([]); + if(selectedDate==null){ + setIsDateSelected(false); + } + }, [selectedDate]); + + const notificationMessage = enableEaushadhaInwardApi + ? 'No data is received for given inward date in this location. Could you please retry?' + : 'No data is received for the outward number. Could you please retry?'; return ( <> @@ -306,35 +319,30 @@ const Aushada = (props) => { {stockReceiptError && ( -

+

{ResponseNotification('error', 'Error', 'Something went wrong while fetching URL')}

)} - {stockEmptyResonseMessage && ( -
- {ResponseNotification( - 'info', - 'info', - 'No data is received for the outward number. Could you please retry?', - setStockEmptyResonseMessage, - )} -
- )} + {stockEmptyResonseMessage && ( +
+ {ResponseNotification('info', 'Info', notificationMessage, setStockEmptyResonseMessage)} +
+ )} {inwardNumberExists && ( -

+

{ResponseNotification( - 'error', - 'Error', - 'Institute Id with this Date already fetched. Please enter a new institute id and date',setInwardNumberExists + 'info', + 'Info', + 'Institute Id with this Date already fetched. Please enter a new inward date',setInwardNumberExists )}

)} {outwardNumberExists && ( -

+

{ResponseNotification( - 'error', - 'Error', + 'info', + 'Info', 'Outward number already exists. Please enter a new outward number',setOutwardNumberExists )}

@@ -342,7 +350,7 @@ const Aushada = (props) => { {stockIntakeButtonClick && !receivedResponse && !stockReceiptError ? ( ) : ( - items && + isTableVisible && items && items.length > 0 && (
@@ -431,7 +439,7 @@ const Aushada = (props) => { ) )} - {items && items.length > 0 && ( + {isTableVisible && items && items.length > 0 && (