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

inventory form updates #1455

Merged
merged 4 commits into from
Aug 1, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,16 @@ const AddLocationInventoryForm = (props: LocationInventoryFormProps) => {
/>
</FormItem>

<FormItem
id={serialNumber}
rules={validationRules[serialNumber]}
name={serialNumber}
label={t('Serial number')}
>
<Input disabled={!attractiveProduct} placeholder={t('Serial number')} />
</FormItem>
{attractiveProduct ? (
<FormItem
id={serialNumber}
rules={validationRules[serialNumber]}
name={serialNumber}
label={t('Serial number')}
>
<Input placeholder={t('Serial number')} />
</FormItem>
) : null}

<FormItem id={donor} name={donor} label={t('Donor')}>
<ValueSetAsyncSelect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export const AddLocationInventory = (props: AddLocationInventoryProps) => {
const { fhirBaseURL, listId, commodityListId } = props;
const { t } = useTranslation();
const { inventoryId, servicePointId } = useParams<RouteParams>();
const pageTitle = inventoryId ? t('Edit locations Inventory') : t('Add locations Inventory');
const pageTitle = inventoryId
? t('Edit Service Point Inventory')
: t('Add Service Point Inventory');

const inventoryResource = useQuery(
[fhirBaseURL, inventoryId],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ test('form validation works', async () => {
'Delivery date is required',
'Accountability end date is required',
'UNICEF section is required',
'PO number is required',
]);
});

Expand Down Expand Up @@ -320,6 +319,9 @@ test('#1384 - correctly updates location inventory', async () => {
expect(preFetchScope.isDone()).toBeTruthy();
});

// serial number is initially not shown on the form
expect(screen.queryByText('Serial number')).not.toBeInTheDocument();

// simulate value selection for product
const productSelectComponent = document.querySelector(`input#${product}`)!;
fireEvent.mouseDown(productSelectComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ test('renders correctly', async () => {

await waitForElementToBeRemoved(document.querySelector('.ant-spin'));

screen.getByText('Add locations Inventory');
screen.getByText('Add Service Point Inventory');
// form items
screen.getByText('Product name');
screen.getByText('Quantity');
screen.getByText('Delivery date');
screen.getByText('Accountability end date');
screen.getByText('UNICEF section');
screen.getByText('Serial number');
expect(screen.queryByAltText('Serial number')).not.toBeInTheDocument();
screen.getByText('Donor');
screen.getByText('PO number');
screen.getByText('Expiry date');
Expand Down Expand Up @@ -160,5 +160,5 @@ test('renders correctly on edit', async () => {

await waitForElementToBeRemoved(document.querySelector('.ant-spin'));

screen.getByText('Edit locations Inventory');
screen.getByText('Edit Service Point Inventory');
});
Original file line number Diff line number Diff line change
Expand Up @@ -582,10 +582,7 @@ export const validationRulesFactory = (t: TFunction, isAttractiveProduct: boolea
{ required: true, message: t('Accountability end date is required') },
] as Rule[],
[serialNumber]: [{ type: 'string', message: t('Must be a valid string') }] as Rule[],
[PONumber]: [
{ type: 'string', message: t('Must be a valid string') },
{ required: true, message: t('PO number is required') },
] as Rule[],
[PONumber]: [{ type: 'string', message: t('Must be a valid string') }] as Rule[],
};
if (isAttractiveProduct) {
rules[serialNumber].push({ required: true, message: t('Serial number is required') });
Expand Down
Loading