@oxyhq/services
Version:
212 lines (211 loc) • 8.71 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _sonner = require("../../lib/sonner");
var _index = require("../components/index.js");
var _useI18n = require("../hooks/useI18n.js");
var _useThemeStyles = require("../hooks/useThemeStyles.js");
var _themeUtils = require("../utils/themeUtils.js");
var _OxyContext = require("../context/OxyContext.js");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const AccountVerificationScreen = ({
onClose,
theme,
goBack
}) => {
// Use useOxy() hook for OxyContext values
const {
oxyServices,
user
} = (0, _OxyContext.useOxy)();
const {
t
} = (0, _useI18n.useI18n)();
const [reason, setReason] = (0, _react.useState)('');
const [evidence, setEvidence] = (0, _react.useState)('');
const [isSubmitting, setIsSubmitting] = (0, _react.useState)(false);
const normalizedTheme = (0, _themeUtils.normalizeTheme)(theme);
const baseThemeStyles = (0, _useThemeStyles.useThemeStyles)(normalizedTheme);
const themeStyles = (0, _react.useMemo)(() => ({
...baseThemeStyles,
inputBackgroundColor: baseThemeStyles.isDarkTheme ? '#1C1C1E' : '#F2F2F7',
inputTextColor: baseThemeStyles.textColor,
placeholderTextColor: baseThemeStyles.mutedTextColor
}), [baseThemeStyles]);
const handleSubmit = (0, _react.useCallback)(async () => {
if (!reason.trim()) {
_sonner.toast.error(t('accountVerification.reasonRequired') || 'Please provide a reason for verification');
return;
}
if (!oxyServices) {
_sonner.toast.error(t('accountVerification.error') || 'Service not available');
return;
}
setIsSubmitting(true);
try {
const result = await oxyServices.requestAccountVerification(reason.trim(), evidence.trim() || undefined);
_reactNative.Alert.alert(t('accountVerification.successTitle') || 'Request Submitted', t('accountVerification.successMessage') || `Your verification request has been submitted. Request ID: ${result.requestId}`, [{
text: t('accountVerification.ok') || 'OK',
onPress: () => {
setReason('');
setEvidence('');
goBack?.();
}
}]);
} catch (error) {
if (__DEV__) {
console.error('Failed to submit verification request:', error);
}
_sonner.toast.error(error?.message || t('accountVerification.submitError') || 'Failed to submit verification request');
} finally {
setIsSubmitting(false);
}
}, [reason, evidence, oxyServices, t, goBack]);
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
style: [styles.container, {
backgroundColor: themeStyles.backgroundColor
}],
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Header, {
title: t('accountVerification.title') || 'Account Verification',
onBack: goBack || onClose,
variant: "minimal",
elevation: "subtle"
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.ScrollView, {
style: styles.content,
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Section, {
isFirst: true,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: [styles.description, {
color: themeStyles.mutedTextColor
}],
children: t('accountVerification.description') || 'Request a verified badge for your account. Verified accounts help establish authenticity and credibility.'
})
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_index.Section, {
title: t('accountVerification.sections.request') || 'VERIFICATION REQUEST',
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
style: styles.inputGroup,
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: [styles.label, {
color: themeStyles.textColor
}],
children: t('accountVerification.reasonLabel') || 'Reason for Verification *'
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TextInput, {
style: [styles.textInput, styles.textArea, {
backgroundColor: themeStyles.inputBackgroundColor,
color: themeStyles.inputTextColor,
borderColor: themeStyles.borderColor
}],
value: reason,
onChangeText: setReason,
placeholder: t('accountVerification.reasonPlaceholder') || 'Explain why you need a verified badge (e.g., public figure, brand, organization)',
placeholderTextColor: themeStyles.placeholderTextColor,
multiline: true,
numberOfLines: 4,
textAlignVertical: "top",
editable: !isSubmitting
})]
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
style: styles.inputGroup,
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: [styles.label, {
color: themeStyles.textColor
}],
children: t('accountVerification.evidenceLabel') || 'Evidence (Optional)'
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TextInput, {
style: [styles.textInput, styles.textArea, {
backgroundColor: themeStyles.inputBackgroundColor,
color: themeStyles.inputTextColor,
borderColor: themeStyles.borderColor
}],
value: evidence,
onChangeText: setEvidence,
placeholder: t('accountVerification.evidencePlaceholder') || 'Provide any supporting documentation or links (e.g., official website, social media profiles)',
placeholderTextColor: themeStyles.placeholderTextColor,
multiline: true,
numberOfLines: 4,
textAlignVertical: "top",
editable: !isSubmitting
})]
})]
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Section, {
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
style: [styles.submitButton, {
backgroundColor: isSubmitting ? themeStyles.mutedTextColor : '#007AFF'
}],
onPress: handleSubmit,
disabled: isSubmitting || !reason.trim(),
children: isSubmitting ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
color: "#FFFFFF"
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: styles.submitButtonText,
children: t('accountVerification.submit') || 'Submit Request'
})
})
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Section, {
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: [styles.note, {
color: themeStyles.mutedTextColor
}],
children: t('accountVerification.note') || 'Note: Verification requests are reviewed manually and may take several days. We will notify you once your request has been reviewed.'
})
})]
})]
});
};
const styles = _reactNative.StyleSheet.create({
container: {
flex: 1
},
content: {
flex: 1,
padding: 16
},
description: {
fontSize: 16,
lineHeight: 24,
marginBottom: 8
},
inputGroup: {
marginBottom: 24
},
label: {
fontSize: 16,
fontWeight: '500',
marginBottom: 8
},
textInput: {
borderWidth: 1,
borderRadius: 8,
padding: 12,
fontSize: 16,
minHeight: 44
},
textArea: {
minHeight: 100,
paddingTop: 12
},
submitButton: {
borderRadius: 8,
padding: 16,
alignItems: 'center',
justifyContent: 'center',
minHeight: 50
},
submitButtonText: {
color: '#FFFFFF',
fontSize: 16,
fontWeight: '600'
},
note: {
fontSize: 14,
lineHeight: 20,
fontStyle: 'italic'
}
});
var _default = exports.default = /*#__PURE__*/_react.default.memo(AccountVerificationScreen);
//# sourceMappingURL=AccountVerificationScreen.js.map