Skip to content

Commit

Permalink
GOK-394 | Fix Feedback received for Inward API (#52)
Browse files Browse the repository at this point in the history
* Fix. Feedback received for Inward API

Co-authored-by: deeptirawat1510 <[email protected]>
  • Loading branch information
yenugukeerthana and deeptirawat1510 authored Oct 11, 2023
1 parent 91a8835 commit 8938d66
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 21 deletions.
50 changes: 29 additions & 21 deletions src/inventory/aushada/aushada.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down Expand Up @@ -151,6 +152,7 @@ const Aushada = (props) => {
};
fetchData();
}
setIsTableVisible(true);
}
}, [stockIntakeButtonClick, outwardNumber,selectedDate,instituteId,items]);

Expand All @@ -177,7 +179,6 @@ const Aushada = (props) => {

if (items.length > 0) {
setIsOutwardNumberDisabled(true);
setIsFetchStockDisabled(true);
}
}, [items, outwardNumber, isDateSelected,instituteIdExists]);

Expand Down Expand Up @@ -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 (
<>
Expand Down Expand Up @@ -306,43 +319,38 @@ const Aushada = (props) => {
</Column>
</Row>
{stockReceiptError && (
<h3 style={{ paddingTop: '1rem' }}>
<h3 className={styles.notification}>
{ResponseNotification('error', 'Error', 'Something went wrong while fetching URL')}
</h3>
)}

{stockEmptyResonseMessage && (
<div style={{ paddingTop: '20px' }}>
{ResponseNotification(
'info',
'info',
'No data is received for the outward number. Could you please retry?',
setStockEmptyResonseMessage,
)}
</div>
)}
{stockEmptyResonseMessage && (
<div className={styles.notification}>
{ResponseNotification('info', 'Info', notificationMessage, setStockEmptyResonseMessage)}
</div>
)}
{inwardNumberExists && (
<h3 style={{ paddingTop: '1rem' }}>
<h3 className={styles.notification}>
{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
)}
</h3>
)}
{outwardNumberExists && (
<h3 style={{ paddingTop: '1rem' }}>
<h3 className={styles.notification}>
{ResponseNotification(
'error',
'Error',
'info',
'Info',
'Outward number already exists. Please enter a new outward number',setOutwardNumberExists
)}
</h3>
)}
{stockIntakeButtonClick && !receivedResponse && !stockReceiptError ? (
<Loading />
) : (
items &&
isTableVisible && items &&
items.length > 0 && (
<Column sm={16} style={{ paddingTop: '1rem' }}>
<div className={styles.stockReceiptTable}>
Expand Down Expand Up @@ -431,7 +439,7 @@ const Aushada = (props) => {
)
)}

{items && items.length > 0 && (
{isTableVisible && items && items.length > 0 && (
<ButtonSet className={styles.buttonSet}>
<Button kind='secondary' onClick={handleCancel}>
Cancel
Expand Down
3 changes: 3 additions & 0 deletions src/inventory/aushada/aushada.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@
.totalQuantityInput {
min-width: 7rem;
}
.notification{
padding-top: 1rem;
}

0 comments on commit 8938d66

Please sign in to comment.