2024-12-03 15:09:40 +01:00
|
|
|
import { AlertPopupProps } from 'types'
|
|
|
|
import { AlertPopup } from './AlertPopup'
|
2024-12-03 17:32:55 +01:00
|
|
|
import { useLocalStorage } from 'hooks'
|
2024-12-03 15:09:40 +01:00
|
|
|
|
|
|
|
type NsfwAlertPopup = Omit<AlertPopupProps, 'header' | 'label'>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Triggers when the user wants to switch the filter to see any of the NSFW options
|
|
|
|
* (including preferences)
|
|
|
|
*
|
|
|
|
* Option will be remembered for the session only and will not show the popup again
|
|
|
|
*/
|
|
|
|
export const NsfwAlertPopup = ({
|
|
|
|
handleConfirm,
|
|
|
|
handleClose
|
|
|
|
}: NsfwAlertPopup) => {
|
2024-12-03 17:32:55 +01:00
|
|
|
const [confirmNsfw, setConfirmNsfw] = useLocalStorage<boolean>(
|
2024-12-03 15:09:40 +01:00
|
|
|
'confirm-nsfw',
|
|
|
|
false
|
|
|
|
)
|
|
|
|
|
|
|
|
return (
|
|
|
|
!confirmNsfw && (
|
|
|
|
<AlertPopup
|
|
|
|
header='Confirm'
|
|
|
|
label='Are you above 18 years of age?'
|
|
|
|
handleClose={handleClose}
|
|
|
|
handleConfirm={(confirm: boolean) => {
|
|
|
|
setConfirmNsfw(confirm)
|
|
|
|
handleConfirm(confirm)
|
|
|
|
handleClose()
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|