Skip to content

Commit

Permalink
fix: auth and routing
Browse files Browse the repository at this point in the history
  • Loading branch information
RenauxLeaInsee committed Sep 25, 2024
1 parent 40fa853 commit 4090088
Show file tree
Hide file tree
Showing 33 changed files with 1,038 additions and 371 deletions.
51 changes: 51 additions & 0 deletions public/static/img/document-download.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions public/static/img/document-signature.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions public/static/img/document.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions public/static/img/mail-send.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sonar.projectKey=InseeFr_Platine-My-Surveys
sonar.organization=inseefr
sonar.exclusions=src/i18n/resources/en.tsx,src/i18n/resources/fr.tsx,src/types/api.ts
sonar.exclusions=src/i18n/resources/en.tsx,src/i18n/resources/fr.tsx,src/types/api.ts,src/assets/**
2 changes: 0 additions & 2 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ export function Footer({ className }: { className?: string }) {
partnersLogos={{
main: {
alt: t("ssp logo alt"),
// TODO: change link
href: "#",
imgUrl: sspLogo,
},
}}
Expand Down
57 changes: 23 additions & 34 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import { Header as DsfrHeader } from "@codegouvfr/react-dsfr/Header";
import logoInsee from "assets/logo-insee.png";
import { declareComponentKeys, useTranslation } from "i18n";
import { fr } from "@codegouvfr/react-dsfr";
import { useIsAuthenticated, useLogout } from "hooks/useAuth";

export function Header({ className }: { className?: string }) {
const { t } = useTranslation("Header");

const { isAuthenticated } = useIsAuthenticated();
const logout = useLogout();

return (
<DsfrHeader
className={className}
Expand All @@ -26,35 +21,29 @@ export function Header({ className }: { className?: string }) {
title: t("home link title"),
}}
quickAccessItems={
!isAuthenticated
? [
{
iconId: "fr-icon-customer-service-fill",
linkProps: {
to: "/assistance",
},
text: t("contact support"),
},
{
iconId: "fr-icon-account-circle-fill",
linkProps: {
to: "/mon-compte",
},
text: t("my account"),
},
{
iconId: "fr-icon-logout-box-r-line",

buttonProps: {
className: fr.cx("fr-btn--tertiary", "fr-nav"),
onClick: () =>
logout &&
logout({ redirectTo: "specific url", url: `${import.meta.env.VITE_PORTAIL_URL}/` }),
},
text: t("logout"),
},
]
: []
[]
// TODO: add navigation later
// isAuthenticated
// ? [
// {
// iconId: "fr-icon-account-circle-fill",
// linkProps: {
// to: "/mon-compte",
// },
// text: t("my account"),
// },
// {
// iconId: "fr-icon-logout-box-r-line",
// buttonProps: {
// className: fr.cx("fr-btn--tertiary", "fr-nav"),
// onClick: () =>
// logout &&
// logout({ redirectTo: "specific url", url: `${import.meta.env.VITE_PORTAIL_URL}/` }),
// },
// text: t("logout"),
// },
// ]
// : []
}
serviceTitle={t("service tagline")}
operatorLogo={{
Expand Down
4 changes: 2 additions & 2 deletions src/components/myAccount/PersonalInformationsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { APISchemas } from "types/api";
import { useForm } from "hooks/useForm";
import { personnalInformationsSchema } from "types/schemas";
import { useState } from "react";
import { useFetchMutation } from "hooks/useFetchQuery";
import { useFetchMutationPilotage } from "hooks/useFetchQuery";

type Props = {
contact: APISchemas["ContactDetailsDto"];
Expand All @@ -29,7 +29,7 @@ export const PersonalInformationsForm = ({ contact, onClose, onSave }: Props) =>
defaultValues: contact,
});

const { mutateAsync, isPending } = useFetchMutation("/api/contacts/{id}", "put");
const { mutateAsync, isPending } = useFetchMutationPilotage("/api/contacts/{id}", "put");

const onSubmit = handleSubmit(async data => {
await mutateAsync({
Expand Down
4 changes: 2 additions & 2 deletions src/components/myAccount/PostalAddressInformationsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { declareComponentKeys, useTranslation } from "i18n";
import { useForm } from "hooks/useForm";
import { addressSchema } from "types/schemas";
import { Input } from "@codegouvfr/react-dsfr/Input";
import { useFetchMutation } from "hooks/useFetchQuery";
import { useFetchMutationPilotage } from "hooks/useFetchQuery";

type Props = {
contact: APISchemas["ContactDetailsDto"];
Expand All @@ -20,7 +20,7 @@ export const PostalAddressInformationsForm = ({ contact, onClose, onSave }: Prop
defaultValues: contact.address,
});

const { mutateAsync, isPending } = useFetchMutation("/api/contacts/{id}", "put");
const { mutateAsync, isPending } = useFetchMutationPilotage("/api/contacts/{id}", "put");

const onSubmit = handleSubmit(async data => {
await mutateAsync({
Expand Down
4 changes: 2 additions & 2 deletions src/components/mySurveys/MySurveys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { SurveysDatagrid, getColumns } from "./SurveysDatagrid";
import CircularProgress from "@mui/material/CircularProgress";
import { SurveyCard } from "./SurveyCard";
import { SearchIcon } from "assets/Search";
import { useFetchQuery } from "hooks/useFetchQuery";
import { useFetchQueryPilotage } from "hooks/useFetchQuery";

type Props = {
className?: string;
Expand All @@ -16,7 +16,7 @@ export function MySurveys({ className }: Props) {
const { classes, cx } = useStyles();

const { t } = useTranslation("MySurveys");
const { data, isLoading } = useFetchQuery("/api/contacts/questionings");
const { data, isLoading } = useFetchQueryPilotage("/api/contacts/questionings");
const surveys = data ?? [];

const columns = getColumns(t);
Expand Down
Loading

0 comments on commit 4090088

Please sign in to comment.