Compare commits
1 Commits
main
...
fix-admin-
| Author | SHA1 | Date |
|---|---|---|
|
|
5b65523417 |
47
src/App.tsx
47
src/App.tsx
|
|
@ -217,7 +217,7 @@ export default function App() {
|
|||
setAdminDataLoading(true);
|
||||
const headers = { Authorization: `Bearer ${userToken}` };
|
||||
try {
|
||||
const [payRes, adminsRes, practRes, subLedgerRes, modulesRes, plansRes, couponsRes, dbRes] =
|
||||
const [payRes, adminsRes, practRes, subLedgerRes, modulesRes, plansRes, couponsRes, dbRes, contentModsRes] =
|
||||
await Promise.allSettled([
|
||||
axios.get(`${API_BASE}/api/admin/razorpay/payments`, { headers }),
|
||||
axios.get(`${API_BASE}/api/admin/super-admins`, { headers }),
|
||||
|
|
@ -227,13 +227,56 @@ export default function App() {
|
|||
axios.get(`${API_BASE}/api/admin/plans`, { headers }),
|
||||
axios.get(`${API_BASE}/api/admin/coupons`, { headers }),
|
||||
axios.get(`${API_BASE}/api/admin/database/info`, { headers }),
|
||||
axios.get(`${API_BASE}/api/contents/modules`),
|
||||
]);
|
||||
|
||||
if (payRes.status === 'fulfilled') setRzpPayments(payRes.value.data.payments || []);
|
||||
if (adminsRes.status === 'fulfilled') setAdminsList(adminsRes.value.data || []);
|
||||
if (practRes.status === 'fulfilled') setPractitionersList(practRes.value.data || []);
|
||||
if (subLedgerRes.status === 'fulfilled') setUsersSubscriptions(subLedgerRes.value.data || []);
|
||||
if (modulesRes.status === 'fulfilled') setAdminModulesList(modulesRes.value.data || []);
|
||||
if (modulesRes.status === 'fulfilled') {
|
||||
const rawModules: any[] = modulesRes.value.data || [];
|
||||
const contentModules: any[] =
|
||||
contentModsRes.status === 'fulfilled' ? contentModsRes.value.data?.modules || [] : [];
|
||||
|
||||
// Generic clinical kind to category mapping
|
||||
const kindToCategory: Record<string, string> = {
|
||||
point: 'point',
|
||||
points: 'point',
|
||||
pattern: 'Patterns',
|
||||
patterns: 'Patterns',
|
||||
'five-elements': 'Patterns',
|
||||
nutrition: 'Nutrition',
|
||||
therapeutic: 'Therapeutics',
|
||||
therapeutics: 'Therapeutics',
|
||||
};
|
||||
|
||||
const resolvedModules = rawModules.map((m: any) => {
|
||||
const matched = contentModules.find(
|
||||
(c: any) =>
|
||||
(c.id && m.id && c.id === m.id) ||
|
||||
(c.slug && m.slug && c.slug.toLowerCase() === m.slug.toLowerCase()) ||
|
||||
(c.code && m.code && c.code.toLowerCase() === m.code.toLowerCase())
|
||||
);
|
||||
|
||||
const explicitCategory = matched?.metadata?.category;
|
||||
const kind = (matched?.metadata?.kind || '').toLowerCase();
|
||||
const kindCategory = kindToCategory[kind];
|
||||
|
||||
const resolvedCategory =
|
||||
explicitCategory ||
|
||||
kindCategory ||
|
||||
(m.category && m.category.toLowerCase() !== 'general' ? m.category : null) ||
|
||||
'General';
|
||||
|
||||
return {
|
||||
...m,
|
||||
category: resolvedCategory,
|
||||
};
|
||||
});
|
||||
|
||||
setAdminModulesList(resolvedModules);
|
||||
}
|
||||
if (plansRes.status === 'fulfilled') setAdminPlansList(plansRes.value.data || []);
|
||||
if (couponsRes.status === 'fulfilled') setAdminCouponsList(couponsRes.value.data || []);
|
||||
if (dbRes.status === 'fulfilled') setDbInfo(dbRes.value.data || null);
|
||||
|
|
|
|||
|
|
@ -208,10 +208,11 @@ export const ModulesTab: React.FC<ModulesTabProps> = ({
|
|||
{/* Column 3: Category */}
|
||||
<td className="py-3.5 px-3.5">
|
||||
<span className="text-[10px] font-bold text-indigo-600 bg-indigo-50 px-2.5 py-1 rounded-lg border border-indigo-100 uppercase tracking-wider">
|
||||
{mod.category || 'General'}
|
||||
{mod.category === 'point' ? 'Points' : mod.category || 'General'}
|
||||
</span>
|
||||
</td>
|
||||
|
||||
|
||||
{/* Column 4: Linked Plans */}
|
||||
<td className="py-3.5 px-3.5 font-semibold text-slate-600">
|
||||
<span className="bg-slate-100 text-slate-700 px-2 py-0.5 rounded-md text-[10px] font-bold border border-slate-200">
|
||||
|
|
|
|||
Loading…
Reference in New Issue