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
Changes from 2 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
48 changes: 30 additions & 18 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,23 @@ 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?';

const notificationAction = enableEaushadhaInwardApi
? setStockEmptyResonseMessage
: setStockEmptyResonseMessage;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why both if and else condition of ternary is same here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have updated the code and removed ternary condition.


return (
<>
Expand Down Expand Up @@ -311,38 +328,33 @@ const Aushada = (props) => {
</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 style={{ paddingTop: '20px' }}>
riyaTw marked this conversation as resolved.
Show resolved Hide resolved
{ResponseNotification('info', 'Info', notificationMessage, notificationAction)}
</div>
)}
{inwardNumberExists && (
<h3 style={{ paddingTop: '1rem' }}>
{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' }}>
{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 +443,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
Loading