Skip to content

Commit

Permalink
Add check to hide extra columns for normal programs
Browse files Browse the repository at this point in the history
  • Loading branch information
roxy-dao committed Nov 14, 2024
1 parent 5896854 commit d674f72
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
Popover,
ReasonOptionNodeType,
TextArea,
useAuthContext,
useToggle,
} from '@openmsupply-client/common';
import { useResponse } from '../../api';
Expand Down Expand Up @@ -49,6 +50,7 @@ export const ResponseLineEdit = ({
isProgram,
}: ResponseLineEditProps) => {
const t = useTranslation();
const { store } = useAuthContext();
const { isOn: ourStats, toggle: toggleOurStats } = useToggle();
const { isOn: theirStats, toggle: toggleTheirStats } = useToggle();
const { data } = useResponse.line.stats(draft?.id);
Expand Down Expand Up @@ -107,7 +109,7 @@ export const ResponseLineEdit = ({
sx={{ marginBottom: 1 }}
/>
)}
{isProgram && (
{isProgram && store?.preferences.extraFieldsInRequisition && (
<>
<InputWithLabelRow
Input={
Expand Down Expand Up @@ -204,7 +206,7 @@ export const ResponseLineEdit = ({
label={t('label.amc')}
sx={{ marginBottom: 1 }}
/>
{isProgram && (
{isProgram && store?.preferences.extraFieldsInRequisition && (
<InputWithLabelRow
Input={
<NumericTextInput
Expand Down Expand Up @@ -281,7 +283,7 @@ export const ResponseLineEdit = ({
)}
</Box>
</Box>
{isProgram && (
{isProgram && store?.preferences.extraFieldsInRequisition && (
<InputWithLabelRow
Input={
<NumericTextInput
Expand Down Expand Up @@ -384,7 +386,7 @@ export const ResponseLineEdit = ({
)}
</Box>
</Box>
{isProgram && (
{isProgram && store?.preferences.extraFieldsInRequisition && (
<InputWithLabelRow
Input={
<ReasonOptionsSearchInput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
useUrlQueryParams,
ColumnDescription,
TooltipTextCell,
useAuthContext,
} from '@openmsupply-client/common';
import { ResponseLineFragment, useResponse } from './../api';
import { PackQuantityCell } from '@openmsupply-client/system';
Expand All @@ -16,6 +17,7 @@ export const useResponseColumns = () => {
updateSortQuery,
queryParams: { sortBy },
} = useUrlQueryParams({ initialSort: { key: 'itemName', dir: 'asc' } });
const { store } = useAuthContext();
const { isRemoteAuthorisation } = useResponse.utils.isRemoteAuthorisation();
const { programName } = useResponse.document.fields(['programName']);

Expand Down Expand Up @@ -71,7 +73,7 @@ export const useResponseColumns = () => {
accessor: ({ rowData }) => rowData.availableStockOnHand,
});
}
if (programName) {
if (programName && store?.preferences?.extraFieldsInRequisition) {
columnDefinitions.push(
// TODO: Global pref to show/hide the next columns
{
Expand Down Expand Up @@ -234,7 +236,7 @@ export const useResponseColumns = () => {
]);

// TODO: Global pref to show/hide column
if (programName) {
if (programName && store?.preferences?.extraFieldsInRequisition) {
columnDefinitions.push({
key: 'reason',
label: 'label.reason',
Expand Down

0 comments on commit d674f72

Please sign in to comment.