Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GOK-394 | Fix Feedback received for Inward API #52

Merged
merged 3 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
Loading