UNPKG

@oxyhq/services

Version:

OxyHQ Expo/React Native SDK — UI components, screens, and native features

186 lines (178 loc) 8.22 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 _index = require("../components/index.js"); var _useI18n = require("../hooks/useI18n.js"); var _useThemeStyles = require("../hooks/useThemeStyles.js"); var _useColorScheme = require("../hooks/useColorScheme.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 LegalDocumentsScreen = ({ onClose, theme, goBack, initialStep }) => { const { t } = (0, _useI18n.useI18n)(); const [loading, setLoading] = (0, _react.useState)(false); const colorScheme = (0, _useColorScheme.useColorScheme)(); const themeStyles = (0, _useThemeStyles.useThemeStyles)(theme || 'light', colorScheme); // 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) { if (__DEV__) { console.error(`Failed to open ${policyKey} policy:`, error); } _sonner.toast.error(t('legal.openError') || 'Failed to open document'); } finally { setLoading(false); } }; }, [t]); // 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)(_index.Header, { title: getPolicyTitle(documentType), onBack: goBack || onClose, variant: "minimal", elevation: "subtle" }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.LoadingState, { message: t('legal.opening') || 'Opening document...', color: themeStyles.textColor })] }); } // Default: show both options return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, { style: [styles.container, { backgroundColor: themeStyles.backgroundColor }], children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Header, { title: t('legal.title') || 'Legal Documents', onBack: goBack || onClose, variant: "minimal", elevation: "subtle" }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, { style: styles.content, children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Section, { title: t('legal.policies') || 'Policies & Guidelines', isFirst: true, children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.GroupedSection, { items: [{ id: 'privacy-policy', icon: 'shield-check', iconColor: themeStyles.colors.iconPersonalInfo, 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: 'file-document', iconColor: themeStyles.colors.iconSecurity, 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: 'account-group', iconColor: themeStyles.colors.iconData, 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: 'clock', iconColor: themeStyles.colors.iconStorage, 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: themeStyles.colors.iconSharing, 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') }] }) }) })] }); }; const styles = _reactNative.StyleSheet.create({ container: { flex: 1 }, content: { flex: 1, padding: 16 } }); var _default = exports.default = /*#__PURE__*/_react.default.memo(LegalDocumentsScreen); //# sourceMappingURL=LegalDocumentsScreen.js.map