From 0413fd6c37b8af988fb9cbc387af70e85fbee821 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> Date: Sat, 13 Apr 2024 18:55:56 -0400 Subject: [PATCH] Make confirmation popup more stylish --- src/shared/components/app/app.tsx | 31 ++++++++-- .../components/common/adult-consent-modal.tsx | 59 +++++++++++++++++++ 2 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 src/shared/components/common/adult-consent-modal.tsx diff --git a/src/shared/components/app/app.tsx b/src/shared/components/app/app.tsx index deb4e684..c2238e4f 100644 --- a/src/shared/components/app/app.tsx +++ b/src/shared/components/app/app.tsx @@ -15,11 +15,26 @@ import { Theme } from "./theme"; import AnonymousGuard from "../common/anonymous-guard"; import { destroyTippy, setupTippy } from "../../tippy"; import { adultConsentLocalStorageKey } from "../../config"; +import AdultConsentModal from "../common/adult-consent-modal"; -export class App extends Component { +interface AppState { + showAdultConsentModal: boolean; +} + +function handleAdultConsent(i: App) { + localStorage.setItem(adultConsentLocalStorageKey, "true"); + i.setState({ showAdultConsentModal: false }); +} + +export class App extends Component { private isoData: IsoDataOptionalSite = setIsoData(this.context); private readonly mainContentRef: RefObject; private readonly rootRef = createRef(); + + state: AppState = { + showAdultConsentModal: false, + }; + constructor(props: any, context: any) { super(props, context); this.mainContentRef = createRef(); @@ -32,11 +47,7 @@ export class App extends Component { siteRes?.site_view.site.content_warning && !(siteRes?.my_user || localStorage.getItem(adultConsentLocalStorageKey)) ) { - if (confirm(siteRes.site_view.site.content_warning)) { - localStorage.setItem(adultConsentLocalStorageKey, "true"); - } else { - history.back(); - } + this.setState({ showAdultConsentModal: true }); } setupTippy(this.rootRef); @@ -129,6 +140,14 @@ export class App extends Component {