overleaf-cep/services/web/frontend/stories/hooks/use-fetch-mock.tsx
Antoine Clausse f7b6246d41 [web] Use 6-digits verification in project-list notifications (bis) (#25847)
* Pull email context outside of `ResendConfirmationCodeModal`

* Use `loading` prop of button instead of deprecated Icon

* Swap notification order to clarify priority (no change in behaviour)

* Replace confirmation link action by confirmationCodeModal, and simplify code

* Change to secondary button variant in the Notification

* Display errors within the modal

* Increase ratelimit for resend-confirmation

* Copy changes

* Add stories on email confirmation notifications

* Fix other Notification stories

* Update tests

* Update services/web/frontend/js/features/settings/components/emails/confirm-email-form.tsx

Co-authored-by: Rebeka Dekany <50901361+rebekadekany@users.noreply.github.com>

* Remove placeholder on 6-digit code input

---------

Co-authored-by: Rebeka Dekany <50901361+rebekadekany@users.noreply.github.com>
GitOrigin-RevId: dad8bfd79505a2e7d065fd48791fd57c8a31e071
2025-05-28 08:05:01 +00:00

20 lines
473 B
TypeScript

import { useLayoutEffect } from 'react'
import fetchMock from 'fetch-mock'
/**
* Run callback to mock fetch routes, call removeRoutes() and unmockGlobal() when unmounted
*/
export default function useFetchMock(
callback: (value: typeof fetchMock) => void
) {
fetchMock.mockGlobal()
useLayoutEffect(() => {
fetchMock.mockGlobal()
callback(fetchMock)
return () => {
fetchMock.removeRoutes()
fetchMock.unmockGlobal()
}
}, [callback])
}