Skip to content

Commit

Permalink
Merge branch 'main' into feat/sprint17_client
Browse files Browse the repository at this point in the history
  • Loading branch information
lailabjil committed Jan 23, 2024
2 parents 7f6dfa9 + a9a4eb4 commit 113ddfd
Show file tree
Hide file tree
Showing 58 changed files with 3,640 additions and 2,945 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,15 @@ jobs:
path: coverage/

sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download coverage artifact
uses: actions/download-artifact@v2
with:
name: coverage
path: coverage
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion jest.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
"^@mui/material$": "<rootDir>/node_modules/@mui/material"
},
"transformIgnorePatterns": ["node_modules/(?!(axios)/)", "<rootDir>/node_modules/"],
"setupFiles": ["fake-indexeddb/auto"]
"setupFiles": ["fake-indexeddb/auto", "<rootDir>/src/setup.ts"]
}
20 changes: 14 additions & 6 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ const App = () => {
const [error, setError] = useState<ErrorCodeEnum | undefined>(undefined);
const auth = useAuth();

const getTokenHint = () => {
return localStorage.getItem("id_token") ?? undefined;
};

const setErrorType = (err: any) => {
if (err.response.status === 403) {
setError(ErrorCodeEnum.NO_RIGHTS);
} else {
setError(ErrorCodeEnum.COMMON);
}
};

useEffect(() => {
if (
window.location.search &&
Expand Down Expand Up @@ -44,7 +56,7 @@ const App = () => {
if (navigator.onLine) {
auth.userManager
.signoutRedirect({
id_token_hint: localStorage.getItem("id_token") || undefined,
id_token_hint: getTokenHint(),
})
.then(() => auth.userManager.clearStaleState())
.then(() => auth.userManager.signoutRedirectCallback())
Expand All @@ -55,11 +67,7 @@ const App = () => {
.then(() => auth.userManager.clearStaleState())
.then(() => window.location.replace(process.env.REACT_APP_PUBLIC_URL || ""))
.catch(err => {
if (err.response.status === 403) {
setError(ErrorCodeEnum.NO_RIGHTS);
} else {
setError(ErrorCodeEnum.COMMON);
}
setErrorType(err);
});
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ const LoopNavigator = (props: LoopNavigatorProps) => {

const backClick = useCallback(
(event: React.MouseEvent) => {
onPrevious && onPrevious(event);
onPrevious?.(event);
},
[onPrevious],
);
const nextClick = useCallback(
(event: React.MouseEvent) => {
onNext && onNext(event);
onNext?.(event);
},
[onNext],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ const LoopSurveyPageHeader = (props: LoopSurveyPageHeaderProps) => {
<Box>
<Typography className={classes.infoText}>{label}</Typography>
</Box>
<Box>
<Box onClick={onClose} onKeyUp={onClose}>
<img
src={close}
alt={t("accessibility.asset.mui-icon.close")}
className={classes.actionIcon}
onClick={onClose}
/>
</Box>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ const LoopSurveyPageSimpleHeader = (props: LoopSurveyPageSimpleHeaderProps) => {
return (
<Box className={cx(classes.headerBox)}>
<Box>{simpleHeaderLabel}</Box>
<Box>
<Box onClick={onNavigateBack} onKeyUp={onNavigateBack}>
<img
src={close}
alt={t("accessibility.asset.mui-icon.close")}
className={classes.actionIcon}
onClick={onNavigateBack}
/>
</Box>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const LoopSurveyPageStep = (props: LoopSurveyPageStepProps) => {
errorIconAlt: t("page.alert-when-quit.alt-alert-icon"),
};

const specifiquesPropsOrchestrator = Object.assign({}, specifiquesProps, componentLunaticProps);
const specifiquesPropsOrchestrator = Object.assign(specifiquesProps, componentLunaticProps);
const orchestratorProps = {
source: context.source,
data: getData(idSurvey),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,39 @@ const ActivityButtons = (props: ActivityButtonsProps) => {
const { classes, cx } = useStyles();
const { t } = useTranslation();
return (
<>
<FlexCenter
className={cx(classes.ButtonsBox, isIOS && isMobile ? classes.buttonBoxPwa : "")}
<FlexCenter className={cx(classes.ButtonsBox, isIOS && isMobile ? classes.buttonBoxPwa : "")}>
<>
{!addLabel && (
<Button
variant="outlined"
onClick={onClickFinish}
className={cx(
classes.buttons,
helpStep == 3 ? classes.helpButton : "",
helpStep == 3 ? classes.helpCloseButton : "",
)}
id="clore-button"
disabled={!modifiable}
>
{finishLabel}
</Button>
)}
</>
<Button
variant="contained"
onClick={onClickAdd}
className={cx(
addLabel === undefined ? classes.buttons : classes.aloneAddButton,
helpStep == 1 ? classes.helpButton : "",
helpStep == 1 ? classes.helpAddButton : "",
)}
id="add-button"
disabled={!modifiable}
>
<>
{!addLabel && (
<Button
variant="outlined"
onClick={onClickFinish}
className={cx(
classes.buttons,
helpStep == 3 ? classes.helpButton : "",
helpStep == 3 ? classes.helpCloseButton : "",
)}
id="clore-button"
disabled={!modifiable}
>
{finishLabel}
</Button>
)}
</>
<Button
variant="contained"
onClick={onClickAdd}
className={cx(
addLabel === undefined ? classes.buttons : classes.aloneAddButton,
helpStep == 1 ? classes.helpButton : "",
helpStep == 1 ? classes.helpAddButton : "",
)}
id="add-button"
disabled={!modifiable}
>
<img src={add} alt={t("accessibility.asset.mui-icon.add")} />
{addLabel}
</Button>
</FlexCenter>
</>
<img src={add} alt={t("accessibility.asset.mui-icon.add")} />
{addLabel}
</Button>
</FlexCenter>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ const SurveyPageEditHeader = (props: SurveyPageEditHeaderProps) => {
></Button>
<Typography className={classes.infoText}>{firstNamePrefix + firstName}</Typography>
</Box>
<Box>
<Box onClick={onEditSurvey} onKeyUp={onEditSurvey}>
<img
src={moreHorizontal}
alt={t("accessibility.asset.mui-icon.more-horizontal")}
className={classes.actionIcon}
onClick={onEditSurvey}
/>
<Popover
id={id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ const SurveyPageHeader = (props: SurveyPageHeaderProps) => {
<Box>
<Typography className={classes.infoText}>{surveyDate + " - " + firstName}</Typography>
</Box>
<Box>
<Box onClick={onNavigateBack} onKeyUp={onNavigateBack}>
<img
src={close}
alt={t("accessibility.asset.mui-icon.close")}
className={classes.actionIcon}
onClick={onNavigateBack}
/>
</Box>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ const SurveyPageSimpleHeader = (props: SurveyPageSimpleHeaderProps) => {
return (
<Box className={cx(classes.headerBox, backgroundWhite ? classes.headerWhiteBox : "")}>
<Box>{simpleHeaderLabel}</Box>
<Box>
<Box onClick={onNavigateBack} onKeyUp={onNavigateBack}>
<img
src={close}
alt={t("accessibility.asset.mui-icon.close")}
className={classes.actionIcon}
onClick={onNavigateBack}
id="close-button"
/>
</Box>
Expand Down
26 changes: 16 additions & 10 deletions src/components/commons/SurveyPage/SurveyPageStep/SurveyPageStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,19 @@ const SurveyPageStep = (props: SurveyPageStepProps) => {
modifiable: modifiable,
};

const nextRouteNav = useCallback(() => {
if (validateButton) {
return validateButton;
} else {
nextRoute
? saveAndNavFullPath(idSurvey, nextRoute)
: saveAndNextStep(idSurvey, context.source, context.surveyRootPage, currentPage);
}
}, []);

const surveyPageNotStepProps = {
idSurvey: idSurvey,
validate:
validateButton ??
useCallback(
() =>
nextRoute
? saveAndNavFullPath(idSurvey, nextRoute)
: saveAndNextStep(idSurvey, context.source, context.surveyRootPage, currentPage),
[],
),
validate: nextRouteNav,
srcIcon: errorIcon,
altIcon: errorAltIcon ? t(errorAltIcon) : undefined,
onNavigateBack: useCallback(() => saveAndNav(idSurvey), []),
Expand Down Expand Up @@ -201,6 +203,10 @@ const SurveyPageStep = (props: SurveyPageStepProps) => {
);
};

const stylePageMobileTabletWhenIOS = (isOpen: boolean) => {
return isOpen ? "80vh" : "87vh";
};

const useStyles = makeStylesEdt<{
isMobile: boolean;
isIOS: boolean;
Expand All @@ -217,7 +223,7 @@ const useStyles = makeStylesEdt<{
},
pageMobileTablet: {
height: "100%",
maxHeight: isIOS ? (isOpen ? "80vh" : "87vh") : "94vh",
maxHeight: isIOS ? stylePageMobileTabletWhenIOS(isOpen) : "94vh",
},
}));

Expand Down
26 changes: 12 additions & 14 deletions src/components/commons/SurveyPage/ValidateButton/ValidateButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@ const ValidateButton = (props: ValidateButtonProps) => {
const { classes, cx } = useStyles();

return (
<>
<FlexCenter className={cx(disabled ? classes.invalidButtonBox : classes.validateButtonBox)}>
<Button
id={"validateButton"}
aria-label="validateButton"
variant="contained"
onClick={onClick}
disabled={disabled}
className={disabled ? classes.invalidButton : classes.validateButton}
>
{text}
</Button>
</FlexCenter>
</>
<FlexCenter className={cx(disabled ? classes.invalidButtonBox : classes.validateButtonBox)}>
<Button
id={"validateButton"}
aria-label="validateButton"
variant="contained"
onClick={onClick}
disabled={disabled}
className={disabled ? classes.invalidButton : classes.validateButton}
>
{text}
</Button>
</FlexCenter>
);
};

Expand Down
9 changes: 4 additions & 5 deletions src/components/edt/ActivityCard/ActivityOrRouteCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,12 @@ const ActivityOrRouteCard = (props: ActivityOrRouteCardProps) => {
);

const onEditIn = useCallback((e: React.MouseEvent) => {
onEdit && onEdit();
onEdit?.();
e.stopPropagation();
}, []);

const onDeleteIn = useCallback((e: React.MouseEvent) => {
onDelete && onDelete();
onDelete?.();
e.stopPropagation();
}, []);

Expand All @@ -249,7 +249,7 @@ const ActivityOrRouteCard = (props: ActivityOrRouteCardProps) => {
);
};

const onEditCard = useCallback((e: React.MouseEvent) => {
const onEditCard = useCallback((e: any) => {
e.stopPropagation();
setAnchorEl(e.currentTarget as HTMLButtonElement);
}, []);
Expand Down Expand Up @@ -289,12 +289,11 @@ const ActivityOrRouteCard = (props: ActivityOrRouteCardProps) => {
{renderWithScreen(activityOrRoute, classes, renderInsideAlert, t)}
</Box>
{onEdit && onDelete && modifiable && (
<Box className={classes.editBox}>
<Box className={classes.editBox} onClick={onEditCard} onKeyUp={onEditCard}>
<img
src={moreHorizontal}
alt={t("accessibility.asset.mui-icon.more-horizontal")}
className={classes.actionIcon}
onClick={onEditCard}
aria-label="editCardToggle"
/>
<Popover
Expand Down
Loading

0 comments on commit 113ddfd

Please sign in to comment.