-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show logged out modal on 401 and stop debounce on fritekst input
- Loading branch information
1 parent
aa99082
commit 55955b7
Showing
7 changed files
with
164 additions
and
85 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
53 changes: 53 additions & 0 deletions
53
frontend/src/components/case/innlogget/begrunnelse/logged-out-modal.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { isError } from '@app/functions/is-api-error'; | ||
import { useTranslation } from '@app/language/use-translation'; | ||
import { useUpdateCaseMutation } from '@app/redux-api/case/api'; | ||
import { getLoginRedirectPath } from '@app/user/login'; | ||
import { BodyShort, Button, Modal } from '@navikt/ds-react'; | ||
import { Link } from 'react-router-dom'; | ||
import { styled } from 'styled-components'; | ||
|
||
export const LoggedOutModal = ({ fixedCacheKey }: { fixedCacheKey: string }) => { | ||
const [, { error }] = useUpdateCaseMutation({ fixedCacheKey }); | ||
const { skjema } = useTranslation(); | ||
|
||
const unauthorized = isError(error) && error.status === 401; | ||
|
||
if (!unauthorized) { | ||
return null; | ||
} | ||
|
||
const { loggedOut, login, logout, yes } = skjema.begrunnelse.loggedOutModal; | ||
|
||
return ( | ||
<Modal | ||
open | ||
onClose={() => {}} | ||
header={{ heading: loggedOut, closeButton: false }} | ||
style={{ padding: 'var(--a-spacing-5)' }} | ||
> | ||
<ModalBody> | ||
<BodyShort>{login}</BodyShort> | ||
|
||
<Buttons> | ||
<Button as={Link} to={getLoginRedirectPath()}> | ||
{yes} | ||
</Button> | ||
<Button as={Link} to="/oauth2/logout" variant="secondary"> | ||
{logout} | ||
</Button> | ||
</Buttons> | ||
</ModalBody> | ||
</Modal> | ||
); | ||
}; | ||
|
||
const ModalBody = styled(Modal.Body)` | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--a-spacing-4); | ||
`; | ||
|
||
const Buttons = styled.div` | ||
display: flex; | ||
gap: var(--a-spacing-4); | ||
`; |
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
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