@oxyhq/services
Version:
Reusable OxyHQ module to handle authentication, user management, karma system, device-based session management and more 🚀
313 lines (312 loc) • 10.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _reactNative = require("react-native");
var _OxyContext = require("../context/OxyContext");
var _version = require("../../constants/version");
var _sonner = require("../../lib/sonner");
var _fonts = require("../styles/fonts");
var _components = require("../components");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const AccountCenterScreen = ({
onClose,
theme,
navigate
}) => {
const {
user,
logout,
isLoading,
sessions
} = (0, _OxyContext.useOxy)();
const isDarkTheme = theme === 'dark';
const textColor = isDarkTheme ? '#FFFFFF' : '#000000';
const backgroundColor = isDarkTheme ? '#121212' : '#f2f2f2';
const secondaryBackgroundColor = isDarkTheme ? '#222222' : '#FFFFFF';
const borderColor = isDarkTheme ? '#444444' : '#E0E0E0';
const primaryColor = '#0066CC';
const dangerColor = '#D32F2F';
const handleLogout = async () => {
try {
await logout();
if (onClose) {
onClose();
}
} catch (error) {
console.error('Logout failed:', error);
_sonner.toast.error('There was a problem signing you out. Please try again.');
}
};
const confirmLogout = () => {
_reactNative.Alert.alert('Sign Out', 'Are you sure you want to sign out?', [{
text: 'Cancel',
style: 'cancel'
}, {
text: 'Sign Out',
onPress: handleLogout,
style: 'destructive'
}], {
cancelable: true
});
};
if (!user) {
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: [styles.container, {
backgroundColor
}],
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: [styles.message, {
color: textColor
}],
children: "Not signed in"
})
});
}
if (isLoading) {
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: [styles.container, {
backgroundColor,
justifyContent: 'center'
}],
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
size: "large",
color: primaryColor
})
});
}
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
style: [styles.container, {
backgroundColor
}],
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ProfileCard, {
user: user,
theme: theme,
onEditPress: () => navigate('AccountSettings', {
activeTab: 'profile'
}),
onClosePress: onClose,
showCloseButton: !!onClose
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.ScrollView, {
style: styles.scrollView,
contentContainerStyle: styles.scrollContainer,
showsVerticalScrollIndicator: false,
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Section, {
title: "Quick Actions",
theme: theme,
isFirst: true,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.QuickActions, {
actions: [{
id: 'overview',
icon: 'person-circle',
iconColor: '#007AFF',
title: 'Overview',
onPress: () => navigate('AccountOverview')
}, {
id: 'settings',
icon: 'settings',
iconColor: '#5856D6',
title: 'Settings',
onPress: () => navigate('AccountSettings')
}, {
id: 'sessions',
icon: 'shield-checkmark',
iconColor: '#30D158',
title: 'Sessions',
onPress: () => navigate('SessionManagement')
}, {
id: 'premium',
icon: 'star',
iconColor: '#FFD700',
title: 'Premium',
onPress: () => navigate('PremiumSubscription')
}, ...(user?.isPremium ? [{
id: 'billing',
icon: 'card',
iconColor: '#34C759',
title: 'Billing',
onPress: () => navigate('BillingManagement')
}] : []), ...(sessions && sessions.length > 1 ? [{
id: 'switch',
icon: 'swap-horizontal',
iconColor: '#FF9500',
title: 'Switch',
onPress: () => navigate('AccountSwitcher')
}] : [])],
theme: theme
})
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Section, {
title: "Account Management",
theme: theme,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.GroupedSection, {
items: [{
id: 'overview',
icon: 'person-circle',
iconColor: '#007AFF',
title: 'Account Overview',
subtitle: 'Complete account information',
onPress: () => navigate('AccountOverview')
}, {
id: 'settings',
icon: 'settings',
iconColor: '#5856D6',
title: 'Account Settings',
subtitle: 'Manage your preferences',
onPress: () => navigate('AccountSettings')
}, {
id: 'sessions',
icon: 'shield-checkmark',
iconColor: '#30D158',
title: 'Manage Sessions',
subtitle: 'Security and active devices',
onPress: () => navigate('SessionManagement')
}, {
id: 'files',
icon: 'folder',
iconColor: '#FF9500',
title: 'File Management',
subtitle: 'Upload, download, and manage your files',
onPress: () => navigate('FileManagement')
}, {
id: 'premium',
icon: 'star',
iconColor: '#FFD700',
title: 'Oxy+ Subscriptions',
subtitle: user?.isPremium ? 'Manage your premium plan' : 'Upgrade to premium features',
onPress: () => navigate('PremiumSubscription')
}, ...(user?.isPremium ? [{
id: 'billing',
icon: 'card',
iconColor: '#34C759',
title: 'Billing Management',
subtitle: 'Payment methods and invoices',
onPress: () => navigate('BillingManagement')
}] : [])],
theme: theme
})
}), sessions && sessions.length > 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Section, {
title: "Multi-Account",
theme: theme,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.GroupedSection, {
items: [{
id: 'switch',
icon: 'people',
iconColor: '#FF9500',
title: 'Switch Account',
subtitle: `${sessions.length} accounts available`,
onPress: () => navigate('AccountSwitcher')
}, {
id: 'add',
icon: 'person-add',
iconColor: '#30D158',
title: 'Add Another Account',
subtitle: 'Sign in with a different account',
onPress: () => navigate('SignIn')
}],
theme: theme
})
}), (!sessions || sessions.length <= 1) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Section, {
title: "Add Account",
theme: theme,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.GroupedSection, {
items: [{
id: 'add',
icon: 'person-add',
iconColor: '#30D158',
title: 'Add Another Account',
subtitle: 'Sign in with a different account',
onPress: () => navigate('SignIn')
}],
theme: theme
})
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Section, {
title: "More Options",
theme: theme,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.GroupedSection, {
items: [...(_reactNative.Platform.OS !== 'web' ? [{
id: 'notifications',
icon: 'notifications',
iconColor: '#FF9500',
title: 'Notifications',
subtitle: 'Manage notification settings',
onPress: () => _sonner.toast.info('Notifications feature coming soon!')
}] : []), {
id: 'help',
icon: 'help-circle',
iconColor: '#007AFF',
title: 'Help & Support',
subtitle: 'Get help and contact support',
onPress: () => _sonner.toast.info('Help & Support feature coming soon!')
}, {
id: 'appinfo',
icon: 'information-circle',
iconColor: '#8E8E93',
title: 'App Information',
subtitle: 'Version and system details',
onPress: () => navigate('AppInfo')
}],
theme: theme
})
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Section, {
theme: theme,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.GroupedItem, {
icon: "log-out",
iconColor: dangerColor,
title: isLoading ? "Signing out..." : "Sign Out",
theme: theme,
onPress: confirmLogout,
isFirst: true,
isLast: true,
showChevron: false,
disabled: isLoading,
customContent: isLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
color: dangerColor,
size: "small",
style: {
marginRight: 16
}
}) : null
})
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: styles.versionContainer,
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
style: [styles.versionText, {
color: isDarkTheme ? '#666666' : '#999999'
}],
children: ["Version ", _version.packageInfo.version]
})
})]
})]
});
};
const styles = _reactNative.StyleSheet.create({
container: {
flex: 1
},
scrollView: {
flex: 1
},
scrollContainer: {
padding: 16,
paddingBottom: 20
},
versionContainer: {
alignItems: 'center',
marginTop: 20,
marginBottom: 20
},
versionText: {
fontSize: 12,
fontFamily: _fonts.fontFamilies.phudu
},
message: {
fontSize: 16,
textAlign: 'center',
marginTop: 24
}
});
var _default = exports.default = AccountCenterScreen;
//# sourceMappingURL=AccountCenterScreen.js.map