@airoom/nextmin-react 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/AuthPage.d.ts +6 -1
- package/dist/auth/AuthPage.js +4 -7
- package/dist/components/AdminApp.js +1 -1
- package/dist/nextmin.css +1 -1
- package/dist/providers/NextMinProvider.d.ts +2 -2
- package/dist/providers/NextMinProvider.js +2 -5
- package/dist/views/DashboardPage.js +15 -48
- package/dist/views/list/ListHeader.d.ts +1 -1
- package/dist/views/list/ListHeader.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
export declare function NextMinProvider({ children }: {
|
|
2
|
+
export declare function NextMinProvider({ children, navigate }: {
|
|
4
3
|
children: React.ReactNode;
|
|
4
|
+
navigate?: (url: string) => void;
|
|
5
5
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useRef } from 'react';
|
|
4
|
-
import '../../dist/nextmin.css';
|
|
5
4
|
import { HeroUIProvider } from '@heroui/react';
|
|
6
|
-
import { useRouter } from 'next/navigation';
|
|
7
5
|
import { Provider, useDispatch, useSelector } from 'react-redux';
|
|
8
6
|
import { nextminstore } from '../state/store';
|
|
9
7
|
import { fetchSchemas } from '../state/schemasSlice';
|
|
@@ -24,7 +22,6 @@ function Bootstrapper() {
|
|
|
24
22
|
}, [status, dispatch]);
|
|
25
23
|
return null;
|
|
26
24
|
}
|
|
27
|
-
export function NextMinProvider({ children }) {
|
|
28
|
-
|
|
29
|
-
return (_jsx(Provider, { store: nextminstore, children: _jsxs(HeroUIProvider, { navigate: router.push, children: [_jsx(Bootstrapper, {}), children] }) }));
|
|
25
|
+
export function NextMinProvider({ children, navigate }) {
|
|
26
|
+
return (_jsx(Provider, { store: nextminstore, children: _jsxs(HeroUIProvider, { navigate: navigate, children: [_jsx(Bootstrapper, {}), children] }) }));
|
|
30
27
|
}
|
|
@@ -4,56 +4,21 @@ import { useEffect, useMemo, useState } from 'react';
|
|
|
4
4
|
import { useSelector } from 'react-redux';
|
|
5
5
|
import { api } from '../lib/api';
|
|
6
6
|
import { Divider, Card, CardBody } from '@heroui/react';
|
|
7
|
-
function ArrowUpRightIcon(props) {
|
|
8
|
-
return (_jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": true, ...props, children: _jsx("path", { d: "M7 17L17 7M17 7H9M17 7v8", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
9
|
-
}
|
|
10
|
-
function UsersIcon(props) {
|
|
11
|
-
return (_jsxs("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": true, ...props, children: [_jsx("path", { d: "M16 21v-2a4 4 0 00-4-4H7a4 4 0 00-4 4v2", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), _jsx("circle", { cx: "9", cy: "7", r: "4", stroke: "currentColor", strokeWidth: "2" }), _jsx("path", { d: "M22 21v-2a3 3 0 00-3-3h-2", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), _jsx("path", { d: "M16 3.13a4 4 0 010 7.75", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] }));
|
|
12
|
-
}
|
|
13
|
-
function DoctorIcon(props) {
|
|
14
|
-
return (_jsxs("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": true, ...props, children: [_jsx("path", { d: "M12 12a5 5 0 100-10 5 5 0 000 10z", stroke: "currentColor", strokeWidth: "2" }), _jsx("path", { d: "M4 22v-1a7 7 0 017-7h2a7 7 0 017 7v1", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }), _jsx("path", { d: "M12 7v3M10.5 8.5h3", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" })] }));
|
|
15
|
-
}
|
|
16
|
-
function HospitalIcon(props) {
|
|
17
|
-
return (_jsxs("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": true, ...props, children: [_jsx("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", stroke: "currentColor", strokeWidth: "2" }), _jsx("path", { d: "M12 7v10M7 12h10", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" })] }));
|
|
18
|
-
}
|
|
19
|
-
function CalendarIcon(props) {
|
|
20
|
-
return (_jsxs("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": true, ...props, children: [_jsx("rect", { x: "3", y: "4", width: "18", height: "17", rx: "2", stroke: "currentColor", strokeWidth: "2" }), _jsx("path", { d: "M8 2v4M16 2v4M3 10h18", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" })] }));
|
|
21
|
-
}
|
|
22
7
|
export function DashboardPage() {
|
|
23
8
|
const schemas = useSelector((s) => s.schemas.items);
|
|
24
9
|
const status = useSelector((s) => s.schemas.status);
|
|
10
|
+
// Build cards dynamically for schemas with showCount === true
|
|
25
11
|
const cards = useMemo(() => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
model
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
key: 'doctors',
|
|
37
|
-
label: 'Total doctors',
|
|
38
|
-
icon: _jsx(DoctorIcon, { className: "text-success" }),
|
|
39
|
-
colorClass: 'bg-success/10 text-success',
|
|
40
|
-
model: byName('doctors') ? 'doctors' : undefined,
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
key: 'hospitals',
|
|
44
|
-
label: 'Total hospitals',
|
|
45
|
-
icon: _jsx(HospitalIcon, { className: "text-warning" }),
|
|
46
|
-
colorClass: 'bg-warning/10 text-warning',
|
|
47
|
-
model: byName('hospitals') ? 'hospitals' : undefined,
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
key: 'appointments',
|
|
51
|
-
label: 'Total appointments',
|
|
52
|
-
icon: _jsx(CalendarIcon, { className: "text-secondary" }),
|
|
53
|
-
colorClass: 'bg-secondary/10 text-secondary',
|
|
54
|
-
model: byName('appointments') ? 'appointments' : undefined,
|
|
55
|
-
},
|
|
56
|
-
];
|
|
12
|
+
return (schemas || [])
|
|
13
|
+
.filter((s) => s && s.showCount === true && typeof s.modelName === 'string')
|
|
14
|
+
.map((s) => {
|
|
15
|
+
const model = s.modelName.toLowerCase();
|
|
16
|
+
return {
|
|
17
|
+
key: model,
|
|
18
|
+
label: `Total ${s.modelName}`,
|
|
19
|
+
model,
|
|
20
|
+
};
|
|
21
|
+
});
|
|
57
22
|
}, [schemas]);
|
|
58
23
|
const [counts, setCounts] = useState({});
|
|
59
24
|
const [loading, setLoading] = useState(false);
|
|
@@ -100,8 +65,10 @@ export function DashboardPage() {
|
|
|
100
65
|
};
|
|
101
66
|
}, [cards, status]);
|
|
102
67
|
return (_jsxs("div", { className: "grid gap-4 px-4", children: [_jsx("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between", children: _jsx("h2", { className: "m-0 text-xl font-semibold", children: "Dashboard" }) }), _jsx(Divider, { className: "my-3" }), (error || loading) && (_jsx("div", { className: 'rounded-md px-3 py-2 ' +
|
|
103
|
-
(error
|
|
68
|
+
(error
|
|
69
|
+
? 'bg-red-100 text-red-700'
|
|
70
|
+
: 'bg-default-100 text-default-700'), children: error || 'Loading summary…' })), _jsx("div", { className: "rounded-md px-3 py-2 text-2xl text-center bg-default-50 text-foreground/80", children: "Welcome to your dashboard!" }), _jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-4", children: cards.map((c) => {
|
|
104
71
|
const value = counts[c.key];
|
|
105
|
-
return (_jsx(Card, { className: "shadow-sm border border-default-200", children:
|
|
72
|
+
return (_jsx(Card, { className: "shadow-sm border border-default-200", children: _jsx(CardBody, { className: "flex flex-row items-center justify-start gap-3", children: _jsxs("div", { children: [_jsx("div", { className: "text-sm text-foreground/60", children: c.label }), _jsx("div", { className: "text-2xl font-semibold mt-1", children: value == null ? '—' : value })] }) }) }, c.key));
|
|
106
73
|
}) })] }));
|
|
107
74
|
}
|
|
@@ -3,5 +3,5 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
import Link from 'next/link';
|
|
4
4
|
import { Button, Divider } from '@heroui/react';
|
|
5
5
|
export function ListHeader({ title, createHref, hideCreate = false, loading, }) {
|
|
6
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between", children: [_jsx("h2", { className: "m-0 text-xl font-semibold", children: title }), _jsx("div", { className: "flex items-center gap-3", children: !hideCreate && (_jsx(Link, { href: createHref, children: _jsx(Button, { size: "sm", color: "primary", isDisabled: loading, children: "Create" }) })) })] }), _jsx(Divider, { className: "my-3" })] }));
|
|
6
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between", children: [_jsx("h2", { className: "m-0 text-xl font-semibold", children: title }), _jsx("div", { className: "flex items-center gap-3", children: !hideCreate && createHref ? (_jsx(Link, { href: createHref, children: _jsx(Button, { size: "sm", color: "primary", isDisabled: loading, children: "Create" }) })) : null })] }), _jsx(Divider, { className: "my-3" })] }));
|
|
7
7
|
}
|