namirasoft-account-react 1.3.33 → 1.3.35

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.
@@ -0,0 +1,7 @@
1
+ import { INSActionMenuProps } from "namirasoft-site-react";
2
+ export declare class Actions {
3
+ static view(ids: string[]): INSActionMenuProps;
4
+ static viewHistory(ids: string[]): INSActionMenuProps;
5
+ static edit(ids: string[]): INSActionMenuProps;
6
+ static delete(ids: string[]): INSActionMenuProps;
7
+ }
@@ -0,0 +1,40 @@
1
+ export class Actions {
2
+ static view(ids) {
3
+ return {
4
+ id: "1",
5
+ menu_item: "View",
6
+ handler() {
7
+ },
8
+ isActive() { return ids.length == 1; }
9
+ };
10
+ }
11
+ static viewHistory(ids) {
12
+ return {
13
+ id: "2",
14
+ menu_item: "View History",
15
+ handler() {
16
+ console.log("View History");
17
+ },
18
+ isActive() { return ids.length == 1; }
19
+ };
20
+ }
21
+ static edit(ids) {
22
+ return {
23
+ id: "3",
24
+ menu_item: "Edit",
25
+ handler() {
26
+ },
27
+ isActive() { return ids.length == 1; }
28
+ };
29
+ }
30
+ static delete(ids) {
31
+ return {
32
+ id: "4",
33
+ menu_item: "Delete",
34
+ handler() {
35
+ },
36
+ isActive() { return ids.length == 0; }
37
+ };
38
+ }
39
+ }
40
+ //# sourceMappingURL=Actions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Actions.js","sourceRoot":"","sources":["../../src/layouts/Actions.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,OAAO;IAEhB,MAAM,CAAC,IAAI,CAAC,GAAa;QAErB,OAAO;YACH,EAAE,EAAE,GAAG;YACP,SAAS,EAAE,MAAM;YACjB,OAAO;YAIP,CAAC;YACD,QAAQ,KAAK,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;SACzC,CAAC;IACN,CAAC;IACD,MAAM,CAAC,WAAW,CAAC,GAAa;QAE5B,OAAO;YACH,EAAE,EAAE,GAAG;YACP,SAAS,EAAE,cAAc;YACzB,OAAO;gBAEH,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YAChC,CAAC;YACD,QAAQ,KAAK,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;SACzC,CAAC;IACN,CAAC;IACD,MAAM,CAAC,IAAI,CAAC,GAAa;QAErB,OAAO;YACH,EAAE,EAAE,GAAG;YACP,SAAS,EAAE,MAAM;YACjB,OAAO;YAIP,CAAC;YACD,QAAQ,KAAK,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;SACzC,CAAC;IACN,CAAC;IACD,MAAM,CAAC,MAAM,CAAC,GAAa;QAEvB,OAAO;YACH,EAAE,EAAE,GAAG;YACP,SAAS,EAAE,QAAQ;YACnB,OAAO;YAIP,CAAC;YACD,QAAQ,KAAK,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;SACzC,CAAA;IACL,CAAC;CACJ"}
@@ -1,8 +1,11 @@
1
- import { INSARouterProps } from 'namirasoft-account-react';
2
1
  import { INSBarActionProps, INSBarHeroBannerProps, INSBarNotificationProps, INSBarTitleProps } from 'namirasoft-site-react';
2
+ import { NSASectionListProps } from './NSASectionList';
3
+ import { NSASectionNewProps } from './NSASectionNew';
4
+ import { NSASectionViewProps } from './NSASectionView';
3
5
  import { IHeaderProps } from 'namirasoft-site-react/dist/props/IHeaderProps';
4
6
  import { ReactNode } from 'react';
5
- export interface NSALayoutProps {
7
+ import { INSARouterProps } from '../INSARouterProps';
8
+ export interface NSALayoutProps<EntityType> {
6
9
  scope: string;
7
10
  logo: string;
8
11
  background?: string;
@@ -13,9 +16,10 @@ export interface NSALayoutProps {
13
16
  title?: INSBarTitleProps;
14
17
  router: INSARouterProps;
15
18
  pages?: {
16
- list?: {};
17
- new?: {};
19
+ list?: NSASectionListProps<EntityType>;
20
+ new?: NSASectionNewProps<EntityType>;
21
+ view?: NSASectionViewProps<EntityType>;
18
22
  };
19
23
  children: ReactNode;
20
24
  }
21
- export declare function NSALayout(props: NSALayoutProps): import("react/jsx-runtime").JSX.Element;
25
+ export declare function NSALayout<EntityType>(props: NSALayoutProps<EntityType>): import("react/jsx-runtime").JSX.Element;
@@ -1,12 +1,26 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
11
  import { NSLayout } from 'namirasoft-site-react';
3
12
  import { NSASectionList } from './NSASectionList';
4
13
  import { NSASectionNew } from './NSASectionNew';
14
+ import { NSASectionView } from './NSASectionView';
15
+ import { Actions } from './Actions';
5
16
  export function NSALayout(props) {
6
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
7
- const onLogout = () => {
8
- console.log("clicked");
9
- };
17
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
18
+ const onLogout = () => __awaiter(this, void 0, void 0, function* () {
19
+ yield props.router.account.server.session.Logout().then(() => {
20
+ props.router.notifier.onSuccess("You have successfully logged out");
21
+ props.router.url.redirect("https://account.namirasoft.com/login", {});
22
+ }).catch(() => { });
23
+ });
10
24
  const onNotiffication = () => {
11
25
  console.log("clicked");
12
26
  };
@@ -14,35 +28,47 @@ export function NSALayout(props) {
14
28
  { src: "https://static.namirasoft.com/image/concept/logout/white.svg", alt: "Logout", onClicked: onLogout, },
15
29
  { src: "https://static.namirasoft.com/image/concept/message/white.svg", alt: "Message", onClicked: onNotiffication, count: 1 },
16
30
  ];
17
- let user_name = props.router.account.token_manager.getUserData(user => user.first_name + " " + user.last_name, "");
31
+ let user_name = props.router.account.token_manager.getUserData(user => [user.first_name, user.last_name].filter(n => n).join(" "), "");
18
32
  let action = props.action;
19
33
  if (!action)
20
34
  action = { title: "", description: "", menus: {} };
21
- let groupname = "Action Bar";
35
+ let groupname = "Actions";
22
36
  if (((_a = props.pages) === null || _a === void 0 ? void 0 : _a.list) || ((_b = props.pages) === null || _b === void 0 ? void 0 : _b.new))
23
37
  if (!action.menus[groupname])
24
38
  action.menus[groupname] = [];
25
39
  if ((_c = props.pages) === null || _c === void 0 ? void 0 : _c.list) {
26
- action.menus[groupname].push();
27
- action.menus[groupname].push();
40
+ action.menus[groupname].push(Actions.view([]));
41
+ action.menus[groupname].push(Actions.viewHistory([]));
42
+ action.menus[groupname].push(Actions.edit([]));
43
+ action.menus[groupname].push(Actions.delete([]));
28
44
  }
29
45
  if ((_d = props.pages) === null || _d === void 0 ? void 0 : _d.new) {
30
- action.menus[groupname].push();
31
- action.menus[groupname].push();
46
+ action.menus[groupname].push(Actions.view([]));
47
+ action.menus[groupname].push(Actions.viewHistory([]));
48
+ action.menus[groupname].push(Actions.edit([]));
49
+ action.menus[groupname].push(Actions.delete([]));
50
+ }
51
+ if ((_e = props.pages) === null || _e === void 0 ? void 0 : _e.view) {
52
+ action.menus[groupname].push(Actions.view([]));
53
+ action.menus[groupname].push(Actions.viewHistory([]));
54
+ action.menus[groupname].push(Actions.edit([]));
55
+ action.menus[groupname].push(Actions.delete([]));
32
56
  }
33
57
  let content;
34
- if ((_e = props.pages) === null || _e === void 0 ? void 0 : _e.list)
35
- content = _jsx(NSASectionList, { children: props.children });
36
- else if ((_f = props.pages) === null || _f === void 0 ? void 0 : _f.new)
37
- content = _jsx(NSASectionNew, { children: props.children });
58
+ if ((_f = props.pages) === null || _f === void 0 ? void 0 : _f.list)
59
+ content = _jsx(NSASectionList, Object.assign({}, props.pages.list, { children: props.children }));
60
+ else if ((_g = props.pages) === null || _g === void 0 ? void 0 : _g.new)
61
+ content = _jsx(_Fragment, { children: _jsx(NSASectionNew, Object.assign({}, props.pages.new, { children: props.children })) });
62
+ else if ((_h = props.pages) === null || _h === void 0 ? void 0 : _h.view)
63
+ content = _jsx(NSASectionView, Object.assign({}, props.pages.view, { children: props.children }));
38
64
  else
39
65
  content = props.children;
40
66
  return (_jsx(NSLayout, Object.assign({}, props, { header: {
41
- title: (user_name + " " + ((_h = (_g = props.header) === null || _g === void 0 ? void 0 : _g.title) !== null && _h !== void 0 ? _h : "")).trim(),
42
- icons: [...icons, ...((_k = (_j = props.header) === null || _j === void 0 ? void 0 : _j.icons) !== null && _k !== void 0 ? _k : [])]
67
+ title: (user_name + " " + ((_k = (_j = props.header) === null || _j === void 0 ? void 0 : _j.title) !== null && _k !== void 0 ? _k : "")).trim(),
68
+ icons: [...icons, ...((_m = (_l = props.header) === null || _l === void 0 ? void 0 : _l.icons) !== null && _m !== void 0 ? _m : [])]
43
69
  }, action: {
44
- title: (_m = (_l = props.action) === null || _l === void 0 ? void 0 : _l.title) !== null && _m !== void 0 ? _m : "",
45
- description: (_o = props.action) === null || _o === void 0 ? void 0 : _o.description,
70
+ title: (_p = (_o = props.action) === null || _o === void 0 ? void 0 : _o.title) !== null && _p !== void 0 ? _p : "",
71
+ description: (_q = props.action) === null || _q === void 0 ? void 0 : _q.description,
46
72
  menus: action.menus
47
73
  }, children: _jsx("div", { className: "container-fluid", children: content }) })));
48
74
  }
@@ -1 +1 @@
1
- {"version":3,"file":"NSALayout.js","sourceRoot":"","sources":["../../src/layouts/NSALayout.tsx"],"names":[],"mappings":";AACA,OAAO,EAAuF,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtI,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAs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B,KAAK,CAAC,KAAK,CAAC,IAAI,cAAG,KAAK,CAAC,QAAQ,IAAkB,CAAC;;QAE9F,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC;IAE1B,OAAO,CACN,KAAC,QAAQ,oBACJ,KAAK,IACT,MAAM,EAAE;YACP,KAAK,EAAE,CAAC,SAAS,GAAG,GAAG,GAAG,CAAC,MAAA,MAAA,KAAK,CAAC,MAAM,0CAAE,KAAK,mCAAI,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE;YAC7D,KAAK,EAAE,CAAC,GAAG,KAAK,EAAE,GAAG,CAAC,MAAA,MAAA,KAAK,CAAC,MAAM,0CAAE,KAAK,mCAAI,EAAE,CAAC,CAAC;SACjD,EACD,MAAM,EAAE;YACP,KAAK,EAAE,MAAA,MAAA,KAAK,CAAC,MAAM,0CAAE,KAAK,mCAAI,EAAE;YAChC,WAAW,EAAE,MAAA,KAAK,CAAC,MAAM,0CAAE,WAAW;YACtC,KAAK,EAAE,MAAM,CAAC,KAAK;SACnB,YAED,cAAK,SAAS,EAAC,iBAAiB,YAC9B,OAAO,GACH,IACI,CACX,CAAC;AACH,CAAC"}
@@ -1,3 +1,7 @@
1
- export interface NSASectionListProps {
1
+ import { ReactNode } from "react";
2
+ export interface NSASectionListProps<EntityType> {
3
+ list: () => Promise<EntityType>;
4
+ get: (id: string) => Promise<EntityType>;
5
+ children: ReactNode;
2
6
  }
3
- export declare function NSASectionList(_: NSASectionListProps): import("react/jsx-runtime").JSX.Element;
7
+ export declare function NSASectionList<EntityType>(_: NSASectionListProps<EntityType>): import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"NSASectionList.js","sourceRoot":"","sources":["../../src/layouts/NSASectionList.tsx"],"names":[],"mappings":";AAGA,MAAM,UAAU,cAAc,CAAC,CAAsB;IAEpD,OAAO,CACN,4BACC,iBAAe,GACb,CACH,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"NSASectionList.js","sourceRoot":"","sources":["../../src/layouts/NSASectionList.tsx"],"names":[],"mappings":";AASA,MAAM,UAAU,cAAc,CAAa,CAAkC;IAE5E,OAAO,CACN,4BACC,iBAAe,GACb,CACH,CAAC;AACH,CAAC"}
@@ -1,3 +1,9 @@
1
- export interface NSALayoutNewProps {
1
+ import { ReactNode } from "react";
2
+ export interface NSASectionNewProps<EntityType> {
3
+ isEdit: boolean;
4
+ get: (id: string) => Promise<EntityType>;
5
+ create: () => Promise<void>;
6
+ update: (id: string) => Promise<void>;
7
+ children: ReactNode;
2
8
  }
3
- export declare function NSASectionNew(_: NSALayoutNewProps): import("react/jsx-runtime").JSX.Element;
9
+ export declare function NSASectionNew<EntityType>(_: NSASectionNewProps<EntityType>): import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"NSASectionNew.js","sourceRoot":"","sources":["../../src/layouts/NSASectionNew.tsx"],"names":[],"mappings":";AAGA,MAAM,UAAU,aAAa,CAAC,CAAoB;IAEjD,OAAO,CACN,4BACC,wCAEM,GACJ,CACH,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"NSASectionNew.js","sourceRoot":"","sources":["../../src/layouts/NSASectionNew.tsx"],"names":[],"mappings":";AAWA,MAAM,UAAU,aAAa,CAAa,CAAiC;IAE1E,OAAO,CACN,4BACC,wCAEM,GACJ,CACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from "react";
2
+ export interface NSASectionViewProps<EntityType> {
3
+ get: (id: string) => Promise<EntityType>;
4
+ children: ReactNode;
5
+ }
6
+ export declare function NSASectionView<EntityType>(_: NSASectionViewProps<EntityType>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ export function NSASectionView(_) {
3
+ return (_jsx(_Fragment, { children: _jsx("div", { children: "New Section" }) }));
4
+ }
5
+ //# sourceMappingURL=NSASectionView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NSASectionView.js","sourceRoot":"","sources":["../../src/layouts/NSASectionView.tsx"],"names":[],"mappings":";AAQA,MAAM,UAAU,cAAc,CAAa,CAAkC;IAE5E,OAAO,CACN,4BACC,wCAEM,GACJ,CACH,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "framework": "npm",
9
9
  "application": "package",
10
10
  "private": false,
11
- "version": "1.3.33",
11
+ "version": "1.3.35",
12
12
  "author": "Amir Abolhasani",
13
13
  "license": "MIT",
14
14
  "main": "./dist/main.js",
@@ -26,7 +26,6 @@
26
26
  "device-uuid": "^1.0.4",
27
27
  "namirasoft-account": "^1.3.24",
28
28
  "namirasoft-account-client": "^1.3.0",
29
- "namirasoft-account-react": "^1.3.31",
30
29
  "namirasoft-core": "^1.3.46",
31
30
  "namirasoft-site-react": "^1.3.181",
32
31
  "os-browserify": "^0.3.0",
@@ -0,0 +1,56 @@
1
+ import { INSActionMenuProps } from "namirasoft-site-react";
2
+
3
+ export class Actions
4
+ {
5
+ static view(ids: string[]): INSActionMenuProps
6
+ {
7
+ return {
8
+ id: "1",
9
+ menu_item: "View",
10
+ handler()
11
+ {
12
+ // if (props.redirectToView)
13
+ // props.redirectToView();
14
+ },
15
+ isActive() { return ids.length == 1; }
16
+ };
17
+ }
18
+ static viewHistory(ids: string[]): INSActionMenuProps
19
+ {
20
+ return {
21
+ id: "2",
22
+ menu_item: "View History",
23
+ handler()
24
+ {
25
+ console.log("View History");
26
+ },
27
+ isActive() { return ids.length == 1; }
28
+ };
29
+ }
30
+ static edit(ids: string[]): INSActionMenuProps
31
+ {
32
+ return {
33
+ id: "3",
34
+ menu_item: "Edit",
35
+ handler()
36
+ {
37
+ // if (props.edit)
38
+ // props.edit();
39
+ },
40
+ isActive() { return ids.length == 1; }
41
+ };
42
+ }
43
+ static delete(ids: string[]): INSActionMenuProps
44
+ {
45
+ return {
46
+ id: "4",
47
+ menu_item: "Delete",
48
+ handler()
49
+ {
50
+ // if (props.delete)
51
+ // props.delete();
52
+ },
53
+ isActive() { return ids.length == 0; }
54
+ }
55
+ }
56
+ }
@@ -1,11 +1,13 @@
1
- import { INSARouterProps } from 'namirasoft-account-react';
2
1
  import { INSBarActionProps, INSBarHeroBannerProps, INSBarNotificationProps, INSBarTitleProps, NSLayout } from 'namirasoft-site-react';
3
- import { NSASectionList } from './NSASectionList';
4
- import { NSASectionNew } from './NSASectionNew';
2
+ import { NSASectionList, NSASectionListProps } from './NSASectionList';
3
+ import { NSASectionNew, NSASectionNewProps } from './NSASectionNew';
4
+ import { NSASectionView, NSASectionViewProps } from './NSASectionView';
5
5
  import { IHeaderProps } from 'namirasoft-site-react/dist/props/IHeaderProps';
6
6
  import { ReactNode } from 'react';
7
+ import { Actions } from './Actions';
8
+ import { INSARouterProps } from '../INSARouterProps';
7
9
 
8
- export interface NSALayoutProps
10
+ export interface NSALayoutProps<EntityType>
9
11
  {
10
12
  scope: string;
11
13
  logo: string;
@@ -17,17 +19,22 @@ export interface NSALayoutProps
17
19
  title?: INSBarTitleProps;
18
20
  router: INSARouterProps;
19
21
  pages?: {
20
- list?: {};
21
- new?: {}
22
+ list?: NSASectionListProps<EntityType>;
23
+ new?: NSASectionNewProps<EntityType>;
24
+ view?: NSASectionViewProps<EntityType>;
22
25
  }
23
26
  children: ReactNode;
24
27
  }
25
28
 
26
- export function NSALayout(props: NSALayoutProps)
29
+ export function NSALayout<EntityType>(props: NSALayoutProps<EntityType>)
27
30
  {
28
- const onLogout = () =>
31
+ const onLogout = async () =>
29
32
  {
30
- console.log("clicked")
33
+ await props.router.account.server.session.Logout().then(() =>
34
+ {
35
+ props.router.notifier.onSuccess("You have successfully logged out");
36
+ props.router.url.redirect("https://account.namirasoft.com/login", {});
37
+ }).catch(() => { });
31
38
  }
32
39
 
33
40
  const onNotiffication = () =>
@@ -40,32 +47,45 @@ export function NSALayout(props: NSALayoutProps)
40
47
  { src: "https://static.namirasoft.com/image/concept/message/white.svg", alt: "Message", onClicked: onNotiffication, count: 1 },
41
48
  ];
42
49
 
43
- let user_name = props.router.account.token_manager.getUserData(user => user.first_name + " " + user.last_name, "");
50
+ let user_name = props.router.account.token_manager.getUserData(user => [user.first_name, user.last_name].filter(n => n).join(" "), "");
44
51
 
45
52
  let action: INSBarActionProps | undefined = props.action;
46
53
  if (!action)
47
54
  action = { title: "", description: "", menus: {} };
48
55
 
49
- let groupname = "Action Bar";
56
+ let groupname = "Actions";
50
57
  if (props.pages?.list || props.pages?.new)
51
58
  if (!action.menus[groupname])
52
59
  action.menus[groupname] = [];
53
60
  if (props.pages?.list)
54
61
  {
55
- action.menus[groupname].push();
56
- action.menus[groupname].push();
62
+ action.menus[groupname].push(Actions.view([]));
63
+ action.menus[groupname].push(Actions.viewHistory([]));
64
+ action.menus[groupname].push(Actions.edit([]));
65
+ action.menus[groupname].push(Actions.delete([]));
57
66
  }
58
67
  if (props.pages?.new)
59
68
  {
60
- action.menus[groupname].push();
61
- action.menus[groupname].push();
69
+ action.menus[groupname].push(Actions.view([]));
70
+ action.menus[groupname].push(Actions.viewHistory([]));
71
+ action.menus[groupname].push(Actions.edit([]));
72
+ action.menus[groupname].push(Actions.delete([]));
73
+ }
74
+ if (props.pages?.view)
75
+ {
76
+ action.menus[groupname].push(Actions.view([]));
77
+ action.menus[groupname].push(Actions.viewHistory([]));
78
+ action.menus[groupname].push(Actions.edit([]));
79
+ action.menus[groupname].push(Actions.delete([]));
62
80
  }
63
81
 
64
82
  let content;
65
83
  if (props.pages?.list)
66
- content = <NSASectionList>{props.children}</NSASectionList>;
84
+ content = <NSASectionList<EntityType> {...props.pages.list}>{props.children}</NSASectionList>;
67
85
  else if (props.pages?.new)
68
- content = <NSASectionNew>{props.children}</NSASectionNew>;
86
+ content = <><NSASectionNew<EntityType> {...props.pages.new}>{props.children}</NSASectionNew></>;
87
+ else if (props.pages?.view)
88
+ content = <NSASectionView<EntityType> {...props.pages.view}>{props.children}</NSASectionView>;
69
89
  else
70
90
  content = props.children;
71
91
 
@@ -1,7 +1,13 @@
1
- export interface NSASectionListProps
2
- { }
1
+ import { ReactNode } from "react";
3
2
 
4
- export function NSASectionList(_: NSASectionListProps)
3
+ export interface NSASectionListProps<EntityType>
4
+ {
5
+ get: (id: string) => Promise<EntityType>;
6
+ list: () => Promise<EntityType>;
7
+ children: ReactNode;
8
+ }
9
+
10
+ export function NSASectionList<EntityType>(_: NSASectionListProps<EntityType>)
5
11
  {
6
12
  return (
7
13
  <>
@@ -1,7 +1,15 @@
1
- export interface NSALayoutNewProps
2
- { }
1
+ import { ReactNode } from "react";
3
2
 
4
- export function NSASectionNew(_: NSALayoutNewProps)
3
+ export interface NSASectionNewProps<EntityType>
4
+ {
5
+ isEdit: boolean;
6
+ get: (id: string) => Promise<EntityType>;
7
+ create: () => Promise<void>;
8
+ update: (id: string) => Promise<void>;
9
+ children: ReactNode;
10
+ }
11
+
12
+ export function NSASectionNew<EntityType>(_: NSASectionNewProps<EntityType>)
5
13
  {
6
14
  return (
7
15
  <>
@@ -0,0 +1,18 @@
1
+ import { ReactNode } from "react";
2
+
3
+ export interface NSASectionViewProps<EntityType>
4
+ {
5
+ get: (id: string) => Promise<EntityType>;
6
+ children: ReactNode;
7
+ }
8
+
9
+ export function NSASectionView<EntityType>(_: NSASectionViewProps<EntityType>)
10
+ {
11
+ return (
12
+ <>
13
+ <div>
14
+ New Section
15
+ </div>
16
+ </>
17
+ );
18
+ }