parent
45dd18d39e
commit
a72041e807
|
After Width: | Height: | Size: 394 B |
@ -0,0 +1,23 @@ |
||||
import { T9n } from 'features/T9n' |
||||
import { |
||||
NotificationWrapper, |
||||
Title, |
||||
Text, |
||||
ExclamationInCircle, |
||||
} from '../../styled' |
||||
|
||||
export const Notification = () => ( |
||||
<NotificationWrapper> |
||||
<ExclamationInCircle /> |
||||
<Title> |
||||
<T9n t='logged_out_soon' /> |
||||
</Title> |
||||
<Text> |
||||
<T9n t='logged_another_device' /> |
||||
</Text> |
||||
<Text> |
||||
<T9n t='log_with_one_device' /> |
||||
</Text> |
||||
</NotificationWrapper> |
||||
|
||||
) |
||||
@ -0,0 +1,23 @@ |
||||
import { useAuthStore } from 'features/AuthStore' |
||||
import { useEffect, useState } from 'react' |
||||
|
||||
export const useNewDevicePopup = () => { |
||||
const { isNewDeviceLogin } = useAuthStore() |
||||
|
||||
const [isOpen, setIsOpen] = useState(isNewDeviceLogin) |
||||
|
||||
useEffect(() => { |
||||
setIsOpen(isNewDeviceLogin) |
||||
}, [isNewDeviceLogin]) |
||||
|
||||
const close = () => { |
||||
setIsOpen(false) |
||||
} |
||||
|
||||
return { |
||||
close, |
||||
isOpen, |
||||
setIsOpen, |
||||
|
||||
} |
||||
} |
||||
@ -0,0 +1,32 @@ |
||||
import { T9n } from 'features/T9n' |
||||
|
||||
import { Notification } from './components/Notification' |
||||
import { useNewDevicePopup } from './hooks' |
||||
|
||||
import { |
||||
Button, |
||||
Modal, |
||||
Wrapper, |
||||
} from './styled' |
||||
|
||||
export const NewDevicePopup = () => { |
||||
const { |
||||
close, |
||||
isOpen, |
||||
} = useNewDevicePopup() |
||||
|
||||
return ( |
||||
<Modal |
||||
isOpen={isOpen} |
||||
close={close} |
||||
withCloseButton={false} |
||||
> |
||||
<Wrapper> |
||||
<Notification /> |
||||
<Button onClick={close}> |
||||
<T9n t='ok' /> |
||||
</Button> |
||||
</Wrapper> |
||||
</Modal> |
||||
) |
||||
} |
||||
@ -0,0 +1,107 @@ |
||||
import styled, { css } from 'styled-components/macro' |
||||
|
||||
import { isMobileDevice } from 'config/userAgent' |
||||
import { Modal as BaseModal } from 'features/Modal' |
||||
import { ButtonSolid } from 'features/Common/Button' |
||||
import { ModalWindow } from 'features/Modal/styled' |
||||
|
||||
export const Modal = styled(BaseModal)` |
||||
background-color: rgba(0, 0, 0, 0.7); |
||||
text-align: center; |
||||
|
||||
${ModalWindow} { |
||||
border-radius: 4px; |
||||
padding: 60px 54px 50px; |
||||
max-width: 700px; |
||||
|
||||
${isMobileDevice |
||||
? css` |
||||
width: calc(100vw - 24px); |
||||
padding: 38px 20px 24px; |
||||
@media screen and (orientation: landscape){ |
||||
padding: 20px; |
||||
} |
||||
` |
||||
: ''}; |
||||
} |
||||
` |
||||
|
||||
export const Wrapper = styled.div`` |
||||
|
||||
export const NotificationWrapper = styled.div` |
||||
width: 100%; |
||||
` |
||||
|
||||
export const Title = styled.div` |
||||
font-style: normal; |
||||
font-size: 24px; |
||||
font-weight: 700; |
||||
margin-bottom: 30px; |
||||
${isMobileDevice |
||||
? css` |
||||
font-size: 20px; |
||||
@media screen and (orientation: landscape){ |
||||
font-size: 17px; |
||||
margin-bottom: 20px; |
||||
}
|
||||
} |
||||
` |
||||
: ''}; |
||||
` |
||||
|
||||
export const Text = styled.p` |
||||
font-style: normal; |
||||
font-weight: normal; |
||||
font-size: 20px; |
||||
text-align: center; |
||||
margin-bottom: 30px; |
||||
${isMobileDevice |
||||
? css` |
||||
font-size: 14px; |
||||
line-height: 1.5; |
||||
margin-bottom: 20px; |
||||
` |
||||
: ''}; |
||||
` |
||||
|
||||
export const Button = styled(ButtonSolid)` |
||||
min-width: 134px; |
||||
width: auto; |
||||
height: 50px; |
||||
padding: 0 20px; |
||||
background-color: ${({ theme: { colors } }) => colors.button}; |
||||
color: ${({ theme: { colors } }) => colors.white}; |
||||
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3); |
||||
border-radius: 5px; |
||||
font-weight: 600; |
||||
font-size: 20px; |
||||
${isMobileDevice |
||||
? css` |
||||
height: 50px; |
||||
width: 100%; |
||||
font-size: 12px; |
||||
@media screen and (orientation: landscape){ |
||||
max-width: 290px; |
||||
} |
||||
` |
||||
: ''}; |
||||
|
||||
|
||||
` |
||||
|
||||
export const ExclamationInCircle = styled.div` |
||||
width: 88px; |
||||
height: 88px; |
||||
background: url(/images/exclamationInCircle.svg) no-repeat; |
||||
background-size: cover; |
||||
margin: 0 auto 35px; |
||||
${isMobileDevice |
||||
? css` |
||||
@media screen and (orientation: landscape){ |
||||
width: 40px; |
||||
height: 40px; |
||||
margin: 0 auto 15px; |
||||
} |
||||
` |
||||
: ''}; |
||||
` |
||||
@ -0,0 +1,26 @@ |
||||
import { AUTH_SERVICE } from '../config/routes' |
||||
|
||||
export type FailedResponse = { |
||||
error?: string, |
||||
ok: false, |
||||
} |
||||
|
||||
export type SuccessResponse = { |
||||
ok: true, |
||||
} |
||||
|
||||
export const checkDevice = async (token: string) => { |
||||
const url = `${AUTH_SERVICE}/authorize/check-device?access_token=${token}` |
||||
|
||||
const config = { |
||||
method: 'GET', |
||||
} |
||||
|
||||
const response = await fetch(url, config) |
||||
|
||||
const body: SuccessResponse | FailedResponse = await response.json() |
||||
|
||||
if (body.ok) return Promise.resolve() |
||||
|
||||
return Promise.reject(body) |
||||
} |
||||
Loading…
Reference in new issue