Skip to content

Commit

Permalink
add toaster
Browse files Browse the repository at this point in the history
  • Loading branch information
ddecrulle committed May 24, 2024
1 parent 7ed08af commit abc0931
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.51.5",
"react-hot-toast": "^2.4.1",
"tsafe": "^1.6.6",
"tss-react": "^4.9.10",
"zod": "^3.23.8"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Orchestrator/Orchestrator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export function Orchestrator(props: OrchestratorProps) {

updateDataAndStateData({
stateData: getCurrentStateData(),
data: data,
data: data.COLLECTED,

Check failure on line 169 in src/components/Orchestrator/Orchestrator.tsx

View workflow job for this annotation

GitHub Actions / test

Type 'Record<string, Partial<{ COLLECTED: unknown; EDITED: unknown; FORCED: unknown; INPUTTED: unknown; PREVIOUS: unknown; }>> | undefined' is not assignable to type 'Record<string, Partial<{ COLLECTED: unknown; EDITED: unknown; FORCED: unknown; INPUTTED: unknown; PREVIOUS: unknown; }>>'.
onSuccess: resetChangedData,
})
}, [currentPage, pageTag])
Expand Down
2 changes: 2 additions & 0 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { routeTree } from 'router/router'
import { startReactDsfr } from '@codegouvfr/react-dsfr/spa'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { MuiDsfrThemeProvider } from '@codegouvfr/react-dsfr/mui'
import { Toaster } from 'react-hot-toast'

startReactDsfr({
defaultColorScheme: 'system',
Expand Down Expand Up @@ -44,6 +45,7 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
<QueryClientProvider client={queryClient}>
<OidcProvider>
<RouterProvider router={router} />
<Toaster />
</OidcProvider>
</QueryClientProvider>
</MuiDsfrThemeProvider>
Expand Down
15 changes: 14 additions & 1 deletion src/pages/Collect/CollectPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type { LunaticData } from '@inseefr/lunatic'
import type { StateData } from 'model/StateData'
import { useDocumentTitle } from 'hooks/useDocumentTitle'
import { useSetLogoutQuestionnaire } from 'hooks/useLogoutUrl'
import toast from 'react-hot-toast'

export function CollectPage() {
const { surveyUnitId, questionnaireId } = collectRoute.useParams()
Expand Down Expand Up @@ -45,7 +46,19 @@ export function CollectPage() {
id: surveyUnitId,
data: { data: params.data, stateData: params.stateData },
},
{ onSuccess: params.onSuccess }
{
onSuccess: () => {
params.onSuccess?.()
toast.success('Les données ont bien été sauvegardées', {
position: 'bottom-right',
})
},
onError: () =>
toast.error(
"Il y a eu une erreur, les données n'ont pas été sauvegardées",
{ position: 'bottom-right' }
),
}
)

const getDepositProof = () =>
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3065,6 +3065,11 @@ globrex@^0.1.2:
resolved "https://registry.yarnpkg.com/globrex/-/globrex-0.1.2.tgz#dd5d9ec826232730cd6793a5e33a9302985e6098"
integrity sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==

goober@^2.1.10:
version "2.1.14"
resolved "https://registry.yarnpkg.com/goober/-/goober-2.1.14.tgz#4a5c94fc34dc086a8e6035360ae1800005135acd"
integrity sha512-4UpC0NdGyAFqLNPnhCT2iHpza2q+RAY3GV85a/mRPdzyPQMsj0KmMMuetdIkzWRbJ+Hgau1EZztq8ImmiMGhsg==

gopd@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.0.1.tgz#29ff76de69dac7489b7c0918a5788e56477c332c"
Expand Down Expand Up @@ -4612,6 +4617,13 @@ react-hook-form@^7.51.5:
resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.51.5.tgz#4afbfb819312db9fea23e8237a3a0d097e128b43"
integrity sha512-J2ILT5gWx1XUIJRETiA7M19iXHlG74+6O3KApzvqB/w8S5NQR7AbU8HVZrMALdmDgWpRPYiZJl0zx8Z4L2mP6Q==

react-hot-toast@^2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/react-hot-toast/-/react-hot-toast-2.4.1.tgz#df04295eda8a7b12c4f968e54a61c8d36f4c0994"
integrity sha512-j8z+cQbWIM5LY37pR6uZR6D4LfseplqnuAO4co4u8917hBUvXlEqyP1ZzqVLcqoyUesZZv/ImreoCeHVDpE5pQ==
dependencies:
goober "^2.1.10"

react-is@^16.13.1, react-is@^16.7.0:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
Expand Down

0 comments on commit abc0931

Please sign in to comment.