Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | 1x 10x 10x 1x 1x 10x 10x 10x 10x 10x 6x 4x 10x 10x 10x | import { cn } from '@sb/libs';
import { Pressable, Text, View } from 'react-native';
import { Warning, X } from '../../../atoms/Icons/index.native';
import { useThemeColors } from '@sb/hooks/Utilities/useThemeColors';
import { DialogBox } from '../../../molecules/DialogBox/index.native';
import { FC, isValidElement, ReactNode, useMemo, useState } from 'react';
import { ErrorType, NativeErrorContent, NativeErrorPopUpProps } from '../ErrorPopUp.types';
import {
NativeActiveElsewhere as ActiveElsewhere,
NativeBase as Base,
NativeBetAdded as BetAdded,
NativeBetAddedRegistration as BetAddedRegistration,
NativeConnectionUnavailable as ConnectionUnavailable,
NativeGermanOnly as GermanOnly,
NativeInactiveError as InactiveError,
NativeLoggedInElsewhere as LoggedInElsewhere,
NativeNewWallet as NewWallet,
NativePushNotification as PushNotification,
NativeRealityCheck as RealityCheck,
NativeSelfBlock as SelfBlock,
NativeServiceUnavailable as ServiceUnavailable,
NativeWaitingPeriod as WaitingPeriod,
} from './Components';
export const ErrorPopUp: FC<NativeErrorPopUpProps> = ({
isOpen,
onClose,
variant,
className,
language = 'de',
backdropClickClose,
animation = 'slide',
// Shared Props
onLugasClick,
onLogoutClick,
onStayLoggedInClick,
// Push Notifications
onUseNowClick,
onUseLaterClick,
// Connection unavailable Props
onTryAgainClick,
// Service unavailable Props
onReloadPageClick,
// New Wallet Props
onConfirmCreation,
onNewWalletSupportClick,
onNewWalletCheckboxChange,
}) => {
const [isNewWalletCheckboxChecked, setIsNewWalletCheckboxChecked] = useState<boolean>(false);
const handleNewWalletCheckboxChange = (isChecked: boolean) => {
onNewWalletCheckboxChange?.(isChecked);
setIsNewWalletCheckboxChecked(isChecked);
};
const ErrorPopUpData: Record<ErrorType, NativeErrorContent> = {
'base-error': Base(),
'bet-added': BetAdded(),
'self-block': SelfBlock(),
'germany-only': GermanOnly(language),
'bet-added-and-registration': BetAddedRegistration(),
'waiting-period': WaitingPeriod(onClose, onLugasClick!),
'active-elsewhere': ActiveElsewhere(onClose, onLugasClick!),
'service-unavailable': ServiceUnavailable(onReloadPageClick!),
'inactive-error': InactiveError(onClose, onStayLoggedInClick!),
'logged-in-elsewhere': LoggedInElsewhere(onClose, onLugasClick!),
'connection-unavailable': ConnectionUnavailable(onTryAgainClick!),
'reality-check': RealityCheck(onLogoutClick!, onStayLoggedInClick!),
'push-notification': PushNotification(onUseNowClick!, onUseLaterClick!),
'new-wallet': NewWallet(
onClose,
onConfirmCreation!,
onNewWalletSupportClick!,
isNewWalletCheckboxChecked,
handleNewWalletCheckboxChange
),
};
const { themedColors } = useThemeColors();
const {
title,
description,
size = 'large',
padding = 'large',
descriptionClassName,
showCloseIcon = true,
onFooterButtonClicked,
contentSpacing = true,
footerButtonLabel = 'OK',
icon = <Warning size={20} />,
className: errorContentClassName,
}: NativeErrorContent = ErrorPopUpData[variant];
const RenderErrorHeader = (): ReactNode => {
if (isValidElement(title)) {
return (
<View className="relative">
{title}
{showCloseIcon && (
<Pressable onPress={onClose} className="absolute right-0 top-0" aria-label="Close">
<X id="close-icon" size={12} color={themedColors.colorPrimary} />
</Pressable>
)}
</View>
);
}
return (
<View
className={cn('flex-row items-start', {
'gap-3 p-2': icon,
})}
>
<View className="mt-1">{icon}</View>
<Text style={{ color: themedColors.colorPrimary }} className="font-Bold text-xl uppercase">
{title}
</Text>
{showCloseIcon && (
<Pressable onPress={onClose} className="ml-auto" aria-label="Close">
<X id="close-icon" size={11} color={themedColors.colorPrimary} />
</Pressable>
)}
</View>
);
};
const RenderErrorContent = (): ReactNode => {
return (
description && (
<View className={descriptionClassName}>
{isValidElement(description) ? (
description
) : (
<Text
style={{ color: themedColors.colorPrimary }}
className="mb-2 text-lg/6 font-normal"
>
{description}
</Text>
)}
</View>
)
);
};
return (
<DialogBox
id="error-pop-up-dialogbox"
isOpen={isOpen}
animation={animation}
paddingSize={padding}
showCloseIcon={false}
content={<RenderErrorContent />}
addContentSpacing={contentSpacing}
cancelButtonLabel={footerButtonLabel}
headerTemplate={<RenderErrorHeader />}
backdropClickClose={backdropClickClose}
size={size === 'medium' ? 'default' : size}
showFooterButtons={footerButtonLabel !== ''}
onClose={onFooterButtonClicked ? onFooterButtonClicked : onClose}
className={cn('w-full rounded-none', className, errorContentClassName)}
/>
);
};
|