UNPKG

@oxyhq/services

Version:

Reusable OxyHQ module to handle authentication, user management, karma system, device-based session management and more 🚀

217 lines (216 loc) • 8.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _react = _interopRequireWildcard(require("react")); var _reactNative = require("react-native"); var _OxyContext = require("../context/OxyContext"); var _sonner = require("../../lib/sonner"); var _components = require("../components"); var _useI18n = require("../hooks/useI18n"); 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 }) => { 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 themeStyles = (0, _react.useMemo)(() => { const isDarkTheme = theme === 'dark'; return { textColor: isDarkTheme ? '#FFFFFF' : '#000000', backgroundColor: isDarkTheme ? '#121212' : '#FFFFFF', secondaryBackgroundColor: isDarkTheme ? '#222222' : '#F5F5F5', borderColor: isDarkTheme ? '#444444' : '#E0E0E0', mutedTextColor: isDarkTheme ? '#8E8E93' : '#8E8E93', inputBackgroundColor: isDarkTheme ? '#1C1C1E' : '#F2F2F7', inputTextColor: isDarkTheme ? '#FFFFFF' : '#000000', placeholderTextColor: isDarkTheme ? '#8E8E93' : '#8E8E93' }; }, [theme]); 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) { 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)(_components.Header, { title: t('accountVerification.title') || 'Account Verification', theme: theme, onBack: goBack || onClose, variant: "minimal", elevation: "subtle" }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.ScrollView, { style: styles.content, children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Section, { theme: theme, 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)(_components.Section, { title: t('accountVerification.sections.request') || 'VERIFICATION REQUEST', theme: theme, 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)(_components.Section, { theme: theme, 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)(_components.Section, { theme: theme, 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