2022-01-12 12:54:04 +00:00
|
|
|
import { Alert } from 'react-native';
|
|
|
|
|
2022-06-06 14:17:51 +00:00
|
|
|
import I18n from '../../../i18n';
|
2022-01-12 12:54:04 +00:00
|
|
|
|
|
|
|
export const showErrorAlert = (message: string, title?: string, onPress = () => {}): void =>
|
2022-07-06 20:05:13 +00:00
|
|
|
Alert.alert(title || '', message, [{ text: 'OK', onPress }], { cancelable: true });
|
2022-01-12 12:54:04 +00:00
|
|
|
|
|
|
|
interface IShowConfirmationAlert {
|
|
|
|
title?: string;
|
|
|
|
message: string;
|
|
|
|
confirmationText: string;
|
|
|
|
dismissText?: string;
|
|
|
|
onPress: () => void;
|
|
|
|
onCancel?: () => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const showConfirmationAlert = ({
|
|
|
|
title,
|
|
|
|
message,
|
|
|
|
confirmationText,
|
|
|
|
dismissText = I18n.t('Cancel'),
|
|
|
|
onPress,
|
|
|
|
onCancel
|
|
|
|
}: IShowConfirmationAlert): void =>
|
|
|
|
Alert.alert(
|
|
|
|
title || I18n.t('Are_you_sure_question_mark'),
|
|
|
|
message,
|
|
|
|
[
|
|
|
|
{
|
|
|
|
text: dismissText,
|
|
|
|
onPress: onCancel,
|
|
|
|
style: 'cancel'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: confirmationText,
|
|
|
|
style: 'destructive',
|
|
|
|
onPress
|
|
|
|
}
|
|
|
|
],
|
|
|
|
{ cancelable: false }
|
|
|
|
);
|