@oxyhq/services
Version:
Reusable OxyHQ module to handle authentication, user management, karma system, device-based session management and more 🚀
105 lines (104 loc) • 3.22 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _OxyContext = require("../../context/OxyContext");
var _components = require("../../components");
var _useI18n = require("../../hooks/useI18n");
var _jsxRuntime = require("react/jsx-runtime");
const KarmaRulesScreen = ({
goBack,
theme
}) => {
const {
oxyServices
} = (0, _OxyContext.useOxy)();
const {
t
} = (0, _useI18n.useI18n)();
const [rules, setRules] = (0, _react.useState)([]);
const [isLoading, setIsLoading] = (0, _react.useState)(true);
const [error, setError] = (0, _react.useState)(null);
const isDarkTheme = theme === 'dark';
const backgroundColor = isDarkTheme ? '#121212' : '#FFFFFF';
const textColor = isDarkTheme ? '#FFFFFF' : '#000000';
const primaryColor = '#d169e5';
(0, _react.useEffect)(() => {
setIsLoading(true);
setError(null);
oxyServices.getKarmaRules().then(data => setRules(Array.isArray(data) ? data : [])).catch(err => setError(err.message || 'Failed to load rules')).finally(() => setIsLoading(false));
}, [oxyServices]);
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
style: [styles.container, {
backgroundColor
}],
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Header, {
title: t('karma.rules.title') || 'Karma Rules',
subtitle: t('karma.rules.subtitle') || 'How to earn karma points',
theme: theme,
onBack: goBack,
elevation: "subtle"
}), isLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
size: "large",
color: primaryColor,
style: {
marginTop: 40
}
}) : error ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: [styles.error, {
color: '#D32F2F'
}],
children: error
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, {
contentContainerStyle: styles.listContainer,
children: rules.length === 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: [styles.placeholder, {
color: textColor
}],
children: t('karma.rules.empty') || 'No rules found.'
}) : rules.map((rule, idx) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: styles.ruleRow,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: [styles.ruleDesc, {
color: textColor
}],
children: rule.description
})
}, rule.id || idx))
})]
});
};
const styles = _reactNative.StyleSheet.create({
container: {
flex: 1
},
listContainer: {
paddingBottom: 40,
paddingTop: 20
},
ruleRow: {
paddingVertical: 14,
paddingHorizontal: 24,
borderBottomWidth: 1,
borderColor: '#eee'
},
ruleDesc: {
fontSize: 16
},
placeholder: {
fontSize: 16,
color: '#888',
textAlign: 'center',
marginTop: 40
},
error: {
fontSize: 16,
textAlign: 'center',
marginTop: 40
}
});
var _default = exports.default = KarmaRulesScreen;
//# sourceMappingURL=KarmaRulesScreen.js.map