UNPKG

@oxyhq/services

Version:

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

211 lines (203 loc) • 8.76 kB
"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 _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 LegalDocumentsScreen = ({ onClose, theme, goBack, initialStep }) => { const { t } = (0, _useI18n.useI18n)(); const [loading, setLoading] = (0, _react.useState)(false); // Policy URLs from Oxy Transparency Center const POLICY_URLS = { privacy: 'https://oxy.so/company/transparency/policies/privacy', terms: 'https://oxy.so/company/transparency/policies/terms-of-service', community: 'https://oxy.so/company/transparency/policies/community-guidelines', dataRetention: 'https://oxy.so/company/transparency/policies/data-retention', contentModeration: 'https://oxy.so/company/transparency/policies/content-moderation', childSafety: 'https://oxy.so/company/transparency/policies/child-safety', cookie: 'https://oxy.so/company/transparency/policies/cookies' }; // Determine which document to show based on initialStep const documentType = initialStep === 1 ? 'privacy' : initialStep === 2 ? 'terms' : initialStep === 3 ? 'community' : initialStep === 4 ? 'dataRetention' : initialStep === 5 ? 'contentModeration' : initialStep === 6 ? 'childSafety' : initialStep === 7 ? 'cookie' : null; // Generic handler to open any policy URL const handleOpenPolicy = (0, _react.useCallback)(policyKey => { return async () => { try { setLoading(true); const url = POLICY_URLS[policyKey]; const canOpen = await _reactNative.Linking.canOpenURL(url); if (canOpen) { await _reactNative.Linking.openURL(url); } else { _sonner.toast.error(t('legal.openError') || 'Failed to open document'); } } catch (error) { console.error(`Failed to open ${policyKey} policy:`, error); _sonner.toast.error(t('legal.openError') || 'Failed to open document'); } finally { setLoading(false); } }; }, [t]); 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' }; }, [theme]); // If a specific document type is requested, open it directly _react.default.useEffect(() => { if (documentType) { handleOpenPolicy(documentType)(); } }, [documentType, handleOpenPolicy]); // Get policy title for display const getPolicyTitle = key => { const titles = { privacy: t('legal.privacyPolicy.title') || 'Privacy Policy', terms: t('legal.termsOfService.title') || 'Terms of Service', community: t('legal.communityGuidelines.title') || 'Community Guidelines', dataRetention: t('legal.dataRetention.title') || 'Data Retention Policy', contentModeration: t('legal.contentModeration.title') || 'Content Moderation Policy', childSafety: t('legal.childSafety.title') || 'Child Safety Policy', cookie: t('legal.cookiePolicy.title') || 'Cookie Policy' }; return titles[key] || 'Document'; }; // If a specific document type is requested, show loading state while opening if (documentType) { return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, { style: [styles.container, { backgroundColor: themeStyles.backgroundColor }], children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Header, { title: getPolicyTitle(documentType), theme: theme, onBack: goBack || onClose, variant: "minimal", elevation: "subtle" }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, { style: styles.loadingContainer, children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, { size: "large", color: themeStyles.textColor }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, { style: [styles.loadingText, { color: themeStyles.textColor }], children: t('legal.opening') || 'Opening document...' })] })] }); } // Default: show both options return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, { style: [styles.container, { backgroundColor: themeStyles.backgroundColor }], children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Header, { title: t('legal.title') || 'Legal Documents', theme: theme, onBack: goBack || onClose, variant: "minimal", elevation: "subtle" }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, { style: styles.content, children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Section, { title: t('legal.policies') || 'Policies & Guidelines', theme: theme, isFirst: true, children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.GroupedSection, { items: [{ id: 'privacy-policy', icon: 'shield-checkmark', iconColor: '#30D158', title: t('legal.privacyPolicy.title') || 'Privacy Policy', subtitle: t('legal.privacyPolicy.subtitle') || 'How we handle your data', onPress: handleOpenPolicy('privacy') }, { id: 'terms-of-service', icon: 'document-text', iconColor: '#007AFF', title: t('legal.termsOfService.title') || 'Terms of Service', subtitle: t('legal.termsOfService.subtitle') || 'Terms and conditions of use', onPress: handleOpenPolicy('terms') }, { id: 'community-guidelines', icon: 'people', iconColor: '#5856D6', title: t('legal.communityGuidelines.title') || 'Community Guidelines', subtitle: t('legal.communityGuidelines.subtitle') || 'Rules and expectations for our community', onPress: handleOpenPolicy('community') }, { id: 'data-retention', icon: 'time', iconColor: '#FF9500', title: t('legal.dataRetention.title') || 'Data Retention Policy', subtitle: t('legal.dataRetention.subtitle') || 'How long we keep your data', onPress: handleOpenPolicy('dataRetention') }, { id: 'content-moderation', icon: 'eye', iconColor: '#FF3B30', title: t('legal.contentModeration.title') || 'Content Moderation Policy', subtitle: t('legal.contentModeration.subtitle') || 'How we moderate content', onPress: handleOpenPolicy('contentModeration') }, { id: 'child-safety', icon: 'heart', iconColor: '#FF2D55', title: t('legal.childSafety.title') || 'Child Safety Policy', subtitle: t('legal.childSafety.subtitle') || 'Protecting minors on our platform', onPress: handleOpenPolicy('childSafety') }, { id: 'cookie-policy', icon: 'cookie', iconColor: '#8E8E93', title: t('legal.cookiePolicy.title') || 'Cookie Policy', subtitle: t('legal.cookiePolicy.subtitle') || 'How we use cookies and similar technologies', onPress: handleOpenPolicy('cookie') }], theme: theme }) }) })] }); }; const styles = _reactNative.StyleSheet.create({ container: { flex: 1 }, content: { flex: 1, padding: 16 }, loadingContainer: { flex: 1, alignItems: 'center', justifyContent: 'center', gap: 16 }, loadingText: { fontSize: 16, marginTop: 12 } }); var _default = exports.default = /*#__PURE__*/_react.default.memo(LegalDocumentsScreen); //# sourceMappingURL=LegalDocumentsScreen.js.map