-
Notifications
You must be signed in to change notification settings - Fork 16
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
5162 response requisition indicator UI #5523
Changes from 46 commits
894ebc7
d34945c
077e646
48159aa
e06fb0f
48c3c31
1eaa4b6
26cf0de
9b4a6ad
40868c6
65869c8
dd587b6
1931780
8858995
25c76e6
cf56818
d0bf66a
babb20c
e0fa5d2
93a14ef
62f8486
4bd972b
3ee7376
66eda41
84be792
1e9f628
e75041c
fb32148
288b2e7
a8a5525
c5e1a68
0ae3de4
b2bb406
84f493f
387ce3c
64cf13d
3e116e7
02e36c1
205b170
1d47a7d
32ba994
561e33a
6f3a96e
12e83ca
01a6800
9e50d76
c7cbeb9
95e4f8f
f6ee45f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ import { | |
BasicModal, | ||
Box, | ||
FnUtils, | ||
IndicatorLineRowNode, | ||
} from '@openmsupply-client/common'; | ||
import { AppRoute } from '@openmsupply-client/config'; | ||
import { | ||
|
@@ -25,7 +26,13 @@ import { Footer } from './Footer'; | |
import { AppBarButtons } from './AppBarButtons'; | ||
import { SidePanel } from './SidePanel'; | ||
import { ContentArea } from './ContentArea'; | ||
import { useResponse, ResponseLineFragment } from '../api'; | ||
import { | ||
useResponse, | ||
ResponseLineFragment, | ||
ResponseFragment, | ||
ProgramIndicatorFragment, | ||
} from '../api'; | ||
import { IndicatorsTab } from './IndicatorsTab'; | ||
import { ResponseRequisitionLineErrorProvider } from '../context'; | ||
|
||
export const DetailView: FC = () => { | ||
|
@@ -35,6 +42,13 @@ export const DetailView: FC = () => { | |
const isDisabled = useResponse.utils.isDisabled(); | ||
const { onOpen, isOpen, onClose } = useEditModal<ItemRowFragment>(); | ||
const { mutateAsync } = useResponse.line.insert(); | ||
const { data: programIndicators, isLoading: isProgramIndicatorsLoading } = | ||
useResponse.document.indicators( | ||
data?.otherPartyId ?? '', | ||
data?.period?.id ?? '', | ||
data?.program?.id ?? '', | ||
!!data | ||
); | ||
|
||
const onRowClick = useCallback((line: ResponseLineFragment) => { | ||
navigate( | ||
|
@@ -46,6 +60,27 @@ export const DetailView: FC = () => { | |
); | ||
}, []); | ||
|
||
const onProgramIndicatorClick = useCallback( | ||
( | ||
programIndicator?: ProgramIndicatorFragment, | ||
indicatorLine?: IndicatorLineRowNode, | ||
response?: ResponseFragment | ||
) => { | ||
// TODO: Snack? | ||
if (!response || !indicatorLine) return; | ||
Comment on lines
+69
to
+70
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wanna add a snack to let the users know why they can't click the button if they happen to click is and there's nothing there? or remove this and disable the buttons down below There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hehe please π |
||
navigate( | ||
RouteBuilder.create(AppRoute.Distribution) | ||
.addPart(AppRoute.CustomerRequisition) | ||
.addPart(String(response.requisitionNumber)) | ||
.addPart(AppRoute.Indicators) | ||
.addPart(String(programIndicator?.code)) | ||
.addPart(String(indicatorLine.id)) | ||
.build() | ||
); | ||
}, | ||
[] | ||
); | ||
|
||
if (isLoading) return <DetailViewSkeleton />; | ||
|
||
const tabs = [ | ||
|
@@ -67,6 +102,20 @@ export const DetailView: FC = () => { | |
}, | ||
]; | ||
|
||
if (data?.programName && !!data?.otherParty.store) { | ||
tabs.push({ | ||
Component: ( | ||
<IndicatorsTab | ||
onClick={onProgramIndicatorClick} | ||
isLoading={isLoading || isProgramIndicatorsLoading} | ||
response={data} | ||
indicators={programIndicators?.nodes} | ||
/> | ||
), | ||
value: t('label.indicators'), | ||
}); | ||
} | ||
|
||
return !!data ? ( | ||
<ResponseRequisitionLineErrorProvider> | ||
<TableProvider | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import React, { FC } from 'react'; | ||
import { | ||
Box, | ||
AppFooterPortal, | ||
DialogButton, | ||
RouteBuilder, | ||
useNavigate, | ||
useParams, | ||
} from '@openmsupply-client/common'; | ||
import { AppRoute } from '@openmsupply-client/config'; | ||
import { IndicatorLineRowFragment } from '../../api'; | ||
|
||
interface FooterProps { | ||
hasNext: boolean; | ||
next: IndicatorLineRowFragment | null; | ||
hasPrevious: boolean; | ||
previous: IndicatorLineRowFragment | null; | ||
requisitionNumber?: number; | ||
} | ||
|
||
export const Footer: FC<FooterProps> = ({ | ||
hasNext, | ||
next, | ||
hasPrevious, | ||
previous, | ||
requisitionNumber, | ||
}) => { | ||
const navigate = useNavigate(); | ||
const { programIndicatorCode } = useParams(); | ||
|
||
return ( | ||
<AppFooterPortal | ||
Content={ | ||
<Box | ||
gap={2} | ||
display="flex" | ||
flexDirection="row" | ||
alignItems="center" | ||
height={64} | ||
> | ||
<Box | ||
flex={1} | ||
display="flex" | ||
justifyContent="flex-end" | ||
gap={2} | ||
marginLeft="auto" | ||
> | ||
<DialogButton | ||
variant="previous" | ||
disabled={!hasPrevious} | ||
onClick={() => | ||
navigate( | ||
RouteBuilder.create(AppRoute.Distribution) | ||
.addPart(AppRoute.CustomerRequisition) | ||
.addPart(String(requisitionNumber)) | ||
.addPart(AppRoute.Indicators) | ||
.addPart(String(programIndicatorCode)) | ||
.addPart(String(previous?.id)) | ||
.build() | ||
) | ||
} | ||
/> | ||
<DialogButton | ||
variant="next" | ||
disabled={!hasNext} | ||
onClick={() => | ||
navigate( | ||
RouteBuilder.create(AppRoute.Distribution) | ||
.addPart(AppRoute.CustomerRequisition) | ||
.addPart(String(requisitionNumber)) | ||
.addPart(AppRoute.Indicators) | ||
.addPart(String(programIndicatorCode)) | ||
.addPart(String(next?.id)) | ||
.build() | ||
) | ||
} | ||
/> | ||
</Box> | ||
</Box> | ||
} | ||
/> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User probably won't understand what this means... since we're only checking if Number is the correct type, maybe we can change the error message to be friendlier