Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

refactor(app): remove the card-based mature content check pages

Hampusebc8238c3f16
diff --git a/fluxer_app/src/features/auth/components/modals/MatureContentCheckModal.tsx b/fluxer_app/src/features/auth/components/modals/MatureContentCheckModal.tsx
deleted file mode 100644
index 32c3cc387..000000000
--- a/fluxer_app/src/features/auth/components/modals/MatureContentCheckModal.tsx
+++ /dev/null
@@ -1,114 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-or-later
-
-import * as Modal from '@app/features/app/components/dialogs/Modal';
-import {
- CANCEL_DESCRIPTOR,
- COMPLETE_MATURE_CONTENT_CHECK_DESCRIPTOR,
-} from '@app/features/i18n/utils/CommonMessageDescriptors';
-import * as MatureContentCheckCommands from '@app/features/mature_content/commands/MatureContentCheckCommands';
-import {isMatureContentCheckAvailableInRegion} from '@app/features/moderation/utils/MatureContentGeoUtils';
-import {Button} from '@app/features/ui/button/Button';
-import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
-import {openExternalUrl} from '@app/features/ui/utils/NativeUtils';
-import {msg} from '@lingui/core/macro';
-import {useLingui} from '@lingui/react/macro';
-import {observer} from 'mobx-react-lite';
-import {useCallback, useRef, useState} from 'react';
-
-const SOMETHING_WENT_WRONG_PLEASE_TRY_AGAIN_DESCRIPTOR = msg({
- message: 'Something went wrong. Try again.',
- comment: 'Toast error shown when the mature content check request fails unexpectedly.',
-});
-const MATURE_CONTENT_CHECK_DESCRIPTOR = msg({
- message: 'Mature content check',
- comment: 'Title of the modal that starts the credit-card check for mature content access.',
-});
-const MATURE_CONTENT_CHECK_REQUIRED_DESCRIPTOR = msg({
- message:
- "UK law requires a mature content check. To continue, you'll complete a zero-amount credit card authorization through Stripe. Your card will not be charged.",
- comment:
- 'Body copy in the mature content check modal. The Stripe authorization has no amount and the card is never charged.',
-});
-const CREDIT_CARDS_ONLY_DESCRIPTOR = msg({
- message: 'Only credit cards are accepted. Debit and prepaid cards cannot be used for the mature content check.',
- comment: 'Body copy in the mature content check modal.',
-});
-const MATURE_CONTENT_CHECKS_UK_ONLY_DESCRIPTOR = msg({
- message: 'Mature content checks are currently available only in the UK.',
- comment: 'Body copy in the mature content check modal when the check is unavailable.',
-});
-export const MatureContentCheckModal = observer(() => {
- const {i18n} = useLingui();
- const [submitting, setSubmitting] = useState(false);
- const [error, setError] = useState<string | null>(null);
- const initialFocusRef = useRef<HTMLButtonElement | null>(null);
- const matureContentCheckAvailable = isMatureContentCheckAvailableInRegion();
- const handleVerify = useCallback(async () => {
- setSubmitting(true);
- setError(null);
- try {
- const url = await MatureContentCheckCommands.createMatureContentCheckSession();
- ModalCommands.pop();
- await openExternalUrl(url);
- } catch {
- setError(i18n._(SOMETHING_WENT_WRONG_PLEASE_TRY_AGAIN_DESCRIPTOR));
- } finally {
- setSubmitting(false);
- }
- }, [i18n]);
- const handleCancel = useCallback(() => {
- ModalCommands.pop();
- }, []);
- return (
- <Modal.Root
- size="small"
- initialFocusRef={initialFocusRef}
- centered
- data-flx="auth.mature-content-check-modal.modal-root"
- >
- <Modal.Header
- title={i18n._(MATURE_CONTENT_CHECK_DESCRIPTOR)}
- data-flx="auth.mature-content-check-modal.modal-header"
- />
- <Modal.Content data-flx="auth.mature-content-check-modal.modal-content">
- <Modal.ContentLayout data-flx="auth.mature-content-check-modal.modal-content-layout">
- {matureContentCheckAvailable ? (
- <>
- <Modal.Description data-flx="auth.mature-content-check-modal.modal-description">
- {i18n._(MATURE_CONTENT_CHECK_REQUIRED_DESCRIPTOR)}
- </Modal.Description>
- <Modal.Description data-flx="auth.mature-content-check-modal.modal-description--2">
- {i18n._(CREDIT_CARDS_ONLY_DESCRIPTOR)}
- </Modal.Description>
- </>
- ) : (
- <Modal.Description data-flx="auth.mature-content-check-modal.modal-description--3">
- {i18n._(MATURE_CONTENT_CHECKS_UK_ONLY_DESCRIPTOR)}
- </Modal.Description>
- )}
- {error != null && (
- <Modal.Description data-flx="auth.mature-content-check-modal.modal-description--4">
- {error}
- </Modal.Description>
- )}
- </Modal.ContentLayout>
- </Modal.Content>
- {matureContentCheckAvailable && (
- <Modal.Footer data-flx="auth.mature-content-check-modal.modal-footer">
- <Button onClick={handleCancel} variant="secondary" data-flx="auth.mature-content-check-modal.button.cancel">
- {i18n._(CANCEL_DESCRIPTOR)}
- </Button>
- <Button
- onClick={handleVerify}
- submitting={submitting}
- variant="primary"
- ref={initialFocusRef}
- data-flx="auth.mature-content-check-modal.button.verify"
- >
- {i18n._(COMPLETE_MATURE_CONTENT_CHECK_DESCRIPTOR)}
- </Button>
- </Modal.Footer>
- )}
- </Modal.Root>
- );
-});
diff --git a/fluxer_app/src/features/auth/components/pages/MatureContentCheckCallbackPage.tsx b/fluxer_app/src/features/auth/components/pages/MatureContentCheckCallbackPage.tsx
deleted file mode 100644
index 974f39a52..000000000
--- a/fluxer_app/src/features/auth/components/pages/MatureContentCheckCallbackPage.tsx
+++ /dev/null
@@ -1,89 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-or-later
-
-import {INVALID_STATUS_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';
-import {useLocation} from '@app/features/platform/components/router/RouterReact';
-import styles from '@app/features/premium/components/pages/PremiumCallbackPage.module.css';
-import {msg} from '@lingui/core/macro';
-import {useLingui} from '@lingui/react/macro';
-import {CheckCircleIcon, XCircleIcon} from '@phosphor-icons/react';
-import {observer} from 'mobx-react-lite';
-
-const MATURE_CONTENT_CHECK_SENT_DESCRIPTOR = msg({
- message: 'Mature content check sent',
- comment: 'Title on the mature content check callback page after a successful check submission.',
-});
-const MATURE_CONTENT_CHECK_SENT_BODY_DESCRIPTOR = msg({
- message:
- 'Your credit card has been checked. If the card is valid, mature content will unlock shortly. You can close this tab and return to the app.',
- comment: 'Body copy on the mature content check callback page after a successful check submission.',
-});
-const MATURE_CONTENT_CHECK_CANCELED_DESCRIPTOR = msg({
- message: 'Mature content check canceled',
- comment: 'Title on the mature content check callback page after the check was canceled.',
-});
-const MATURE_CONTENT_CHECK_CANCELED_BODY_DESCRIPTOR = msg({
- message: 'The mature content check was canceled. You can close this tab and try again from the app.',
- comment: 'Body copy on the mature content check callback page after the check was canceled.',
-});
-const INVALID_STATUS_BODY_DESCRIPTOR = msg({
- message: 'An invalid status was provided. You can close this tab and return to the app.',
- comment: 'Body copy on the mature content check callback page when the callback status is invalid.',
-});
-const MatureContentCheckCallbackPage = observer(() => {
- const {i18n} = useLingui();
- const location = useLocation();
- const queryParams = new URLSearchParams(location.search);
- const status = queryParams.get('status');
- const isSuccess = status === 'success';
- const isCancel = status === 'cancel';
- return (
- <div className={styles.container} data-flx="auth.mature-content-check-callback-page.container">
- {isSuccess && (
- <>
- <CheckCircleIcon
- className={styles.successIcon}
- weight="fill"
- data-flx="auth.mature-content-check-callback-page.success-icon"
- />
- <div className={styles.content} data-flx="auth.mature-content-check-callback-page.content">
- <h1 className={styles.title} data-flx="auth.mature-content-check-callback-page.title">
- {i18n._(MATURE_CONTENT_CHECK_SENT_DESCRIPTOR)}
- </h1>
- <p className={styles.description} data-flx="auth.mature-content-check-callback-page.description">
- {i18n._(MATURE_CONTENT_CHECK_SENT_BODY_DESCRIPTOR)}
- </p>
- </div>
- </>
- )}
- {isCancel && (
- <>
- <XCircleIcon
- className={styles.errorIcon}
- weight="fill"
- data-flx="auth.mature-content-check-callback-page.error-icon"
- />
- <div className={styles.content} data-flx="auth.mature-content-check-callback-page.content--2">
- <h1 className={styles.title} data-flx="auth.mature-content-check-callback-page.title--2">
- {i18n._(MATURE_CONTENT_CHECK_CANCELED_DESCRIPTOR)}
- </h1>
- <p className={styles.description} data-flx="auth.mature-content-check-callback-page.description--2">
- {i18n._(MATURE_CONTENT_CHECK_CANCELED_BODY_DESCRIPTOR)}
- </p>
- </div>
- </>
- )}
- {!isSuccess && !isCancel && (
- <div className={styles.content} data-flx="auth.mature-content-check-callback-page.content--3">
- <h1 className={styles.title} data-flx="auth.mature-content-check-callback-page.title--3">
- {i18n._(INVALID_STATUS_DESCRIPTOR)}
- </h1>
- <p className={styles.description} data-flx="auth.mature-content-check-callback-page.description--3">
- {i18n._(INVALID_STATUS_BODY_DESCRIPTOR)}
- </p>
- </div>
- )}
- </div>
- );
-});
-
-export default MatureContentCheckCallbackPage;