-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[VAS-1070] feat; Change station and channel detail view on pending up…
…date (#586) * [VAS-1070] improved station API and removed wrapper status value from body * [VAS-1070] integrated new station and channel detail API and removed unused ones. * [VAS-1070] fix unit tests * [VAS-1070] handled station and channel with pending update * [VAS-1070] added common component for alert in station and channel detail page * [VAS-1070] removed created by when undefined * [VAS-1070] fix unit tests * [VAS-1070] fix title * [VAS-1070] rename variable
- Loading branch information
1 parent
a27f297
commit c331f88
Showing
34 changed files
with
1,208 additions
and
1,232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { Alert, Typography } from '@mui/material'; | ||
import { Box } from '@mui/system'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { WrapperStatusEnum } from '../../api/generated/portal/ChannelDetailsResource'; | ||
import { useUserRole } from '../../hooks/useUserRole'; | ||
|
||
type Props = { | ||
componentPath: string; | ||
wrapperStatus: WrapperStatusEnum; | ||
note: string; | ||
pendingUpdate: boolean; | ||
}; | ||
|
||
// eslint-disable-next-line sonarjs/cognitive-complexity | ||
export default function GetAlert({ | ||
componentPath, | ||
wrapperStatus, | ||
note, | ||
pendingUpdate, | ||
}: Readonly<Props>) { | ||
const { t } = useTranslation(); | ||
const { userIsPagopaOperator } = useUserRole(); | ||
|
||
if (wrapperStatus !== WrapperStatusEnum.APPROVED) { | ||
const isToBeValidated = | ||
wrapperStatus === WrapperStatusEnum.TO_CHECK || | ||
wrapperStatus === WrapperStatusEnum.TO_CHECK_UPDATE; | ||
const isToBeFixed = | ||
wrapperStatus === WrapperStatusEnum.TO_FIX || | ||
wrapperStatus === WrapperStatusEnum.TO_FIX_UPDATE; | ||
|
||
const userHasToTakeAction = | ||
(isToBeValidated && userIsPagopaOperator) || (isToBeFixed && !userIsPagopaOperator); | ||
return ( | ||
<Box my={2} data-testId="on-validation-alert-test-id"> | ||
<Alert | ||
severity={userHasToTakeAction ? 'warning' : 'info'} | ||
variant="outlined" | ||
sx={{ py: 2 }} | ||
> | ||
<GetAlertContent | ||
isToBeFixed={isToBeFixed} | ||
isToBeValidated={isToBeValidated} | ||
userIsPagopaOperator={userIsPagopaOperator} | ||
componentPath={componentPath} | ||
note={note} | ||
t={t} | ||
/> | ||
</Alert> | ||
</Box> | ||
); | ||
} else if (pendingUpdate) { | ||
return ( | ||
<Box my={2} data-testId="pending-update-alert-test-id"> | ||
<Alert severity="warning" variant="outlined" sx={{ py: 2 }}> | ||
<Typography fontWeight={'fontWeightMedium'} sx={{ whiteSpace: 'pre-line' }}> | ||
{t(`${componentPath}.alert.pendingUpdate`)} | ||
</Typography> | ||
</Alert> | ||
</Box> | ||
); | ||
} | ||
return null; | ||
} | ||
|
||
function GetAlertContent({ | ||
isToBeFixed, | ||
isToBeValidated, | ||
userIsPagopaOperator, | ||
componentPath, | ||
note, | ||
t, | ||
}: Readonly<{ | ||
isToBeFixed: boolean; | ||
isToBeValidated: boolean; | ||
userIsPagopaOperator: boolean; | ||
componentPath: string; | ||
note: string; | ||
t: (key: string) => string; | ||
}>) { | ||
if (isToBeFixed) { | ||
return ( | ||
<> | ||
<Typography fontWeight={'fontWeightMedium'} data-testId="to-fix-alert-test-id"> | ||
{t(`${componentPath}.alert.toFixTitle`)} | ||
</Typography> | ||
<Typography>{note.trim() ? note : t(`${componentPath}.alert.toFixMessage`)}</Typography> | ||
</> | ||
); | ||
} | ||
if (isToBeValidated && userIsPagopaOperator) { | ||
return <Typography data-testId="to-check-alert-test-id">{t(`${componentPath}.alert.toCheckMessage`)}</Typography>; | ||
} | ||
if (isToBeValidated && !userIsPagopaOperator) { | ||
return <Typography data-testId="waiting-for-review-alert-test-id">{t(`${componentPath}.alert.waitingForRevision`)}</Typography>; | ||
} | ||
return null; | ||
} |
8 changes: 4 additions & 4 deletions
8
src/components/StatusChip.tsx → src/components/WrapperCommon/StatusChip.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.