namirasoft-account-react 1.3.179 → 1.3.180
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.
|
@@ -5,13 +5,13 @@ export interface NSAProductListProps {
|
|
|
5
5
|
}
|
|
6
6
|
interface NSAProductListState {
|
|
7
7
|
products: ProductFullRow[] | null;
|
|
8
|
+
search: string;
|
|
8
9
|
}
|
|
9
10
|
export declare class NSAProductListModal extends Component<NSAProductListProps, NSAProductListState> {
|
|
10
11
|
private toastRef;
|
|
11
12
|
constructor(props: NSAProductListProps);
|
|
12
13
|
componentDidMount(): void;
|
|
13
14
|
componentWillUnmount(): void;
|
|
14
|
-
private handleProducts;
|
|
15
15
|
private onClickOutside;
|
|
16
16
|
private onSearchChange;
|
|
17
17
|
render(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -8,39 +8,27 @@ export class NSAProductListModal extends Component {
|
|
|
8
8
|
constructor(props) {
|
|
9
9
|
super(props);
|
|
10
10
|
this.toastRef = createRef();
|
|
11
|
-
this.state = { products: null };
|
|
11
|
+
this.state = { products: null, search: "" };
|
|
12
12
|
this.onClickOutside = this.onClickOutside.bind(this);
|
|
13
|
-
this.handleProducts = this.handleProducts.bind(this);
|
|
14
13
|
this.onSearchChange = this.onSearchChange.bind(this);
|
|
15
14
|
}
|
|
16
15
|
componentDidMount() {
|
|
17
|
-
|
|
16
|
+
let server = new NamirasoftAPIProductServer(console.error);
|
|
17
|
+
server.product.List(null, null, null).then((res) => {
|
|
18
|
+
this.setState({ products: res.rows });
|
|
19
|
+
}).catch(() => { });
|
|
18
20
|
document.addEventListener('mousedown', this.onClickOutside);
|
|
19
21
|
}
|
|
20
22
|
componentWillUnmount() {
|
|
21
23
|
document.removeEventListener('mousedown', this.onClickOutside);
|
|
22
24
|
}
|
|
23
|
-
handleProducts(search) {
|
|
24
|
-
let tokens = search.split(' ').filter(x => x.trim()).map(x => x.toLowerCase());
|
|
25
|
-
let server = new NamirasoftAPIProductServer(console.error);
|
|
26
|
-
server.product.List(null, null, null).then((res) => {
|
|
27
|
-
let filteredProducts = res.rows.filter((product) => {
|
|
28
|
-
let name = product.name.toLowerCase();
|
|
29
|
-
for (let i = 0; i < tokens.length; i++)
|
|
30
|
-
if (name.toLowerCase().includes(tokens[i]))
|
|
31
|
-
return false;
|
|
32
|
-
return true;
|
|
33
|
-
});
|
|
34
|
-
this.setState({ products: filteredProducts });
|
|
35
|
-
}).catch(() => { });
|
|
36
|
-
}
|
|
37
25
|
onClickOutside(event) {
|
|
38
26
|
if (this.toastRef.current && !this.toastRef.current.contains(event.target)) {
|
|
39
27
|
this.props.onClose();
|
|
40
28
|
}
|
|
41
29
|
}
|
|
42
30
|
onSearchChange(e) {
|
|
43
|
-
this.
|
|
31
|
+
this.setState({ search: e.getValue() });
|
|
44
32
|
}
|
|
45
33
|
render() {
|
|
46
34
|
let content = null;
|
|
@@ -48,7 +36,20 @@ export class NSAProductListModal extends Component {
|
|
|
48
36
|
content = _jsx(NSLoading, {});
|
|
49
37
|
}
|
|
50
38
|
else {
|
|
51
|
-
|
|
39
|
+
let tokens = this.state.search.split(' ').filter(x => x.trim()).map(x => x.toLowerCase());
|
|
40
|
+
let products = this.state.products;
|
|
41
|
+
if (this.state.search)
|
|
42
|
+
products = products.filter((product) => {
|
|
43
|
+
let name = product.name.toLowerCase();
|
|
44
|
+
for (let i = 0; i < tokens.length; i++)
|
|
45
|
+
if (!name.toLowerCase().includes(tokens[i]))
|
|
46
|
+
return false;
|
|
47
|
+
return true;
|
|
48
|
+
});
|
|
49
|
+
let getName = (name) => {
|
|
50
|
+
return name.replace("Namirasoft ", "").trim();
|
|
51
|
+
};
|
|
52
|
+
content = (_jsx("div", { className: Styles.nsa_product_list_border, children: products.map((product) => (_jsxs("div", { className: Styles.nsa_product_list, children: [_jsx("img", { src: `${product.logo}`, alt: product.name, width: 64, height: 64, className: "rounded-circle" }), _jsx("div", { children: _jsx("span", { children: `${getName(product.name)}` }) })] }, product.id))) }));
|
|
52
53
|
}
|
|
53
54
|
return (_jsxs(_Fragment, { children: [_jsx("div", { className: Styles.nsa_product_container, ref: this.toastRef, children: _jsxs("div", { className: Styles.nsa_product_group, children: [_jsx("div", { className: "d-flex w-100 justify-content-end px-4", children: _jsx("img", { src: CloseToast, alt: "Close", width: 18, height: 18, onClick: (e) => {
|
|
54
55
|
e.stopPropagation();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NSAProductListModal.js","sourceRoot":"","sources":["../../src/components/NSAProductListModal.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,MAAM,MAAM,kCAAkC,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAkB,MAAM,wBAAwB,CAAC;AACpF,OAAO,UAAU,MAAM,iCAAiC,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"NSAProductListModal.js","sourceRoot":"","sources":["../../src/components/NSAProductListModal.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,MAAM,MAAM,kCAAkC,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAkB,MAAM,wBAAwB,CAAC;AACpF,OAAO,UAAU,MAAM,iCAAiC,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAa/D,MAAM,OAAO,mBAAoB,SAAQ,SAAmD;IAIxF,YAAY,KAA0B;QAElC,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,QAAQ,GAAG,SAAS,EAAE,CAAC;QAC5B,IAAI,CAAC,KAAK,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;QAC5C,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAA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AAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,GAAQ,GACvC,KAJoC,OAAO,CAAC,EAAE,CAKlD,CACT,CAAC,GACA,CACT,CAAC;SACL;QAED,OAAO,CACH,8BACI,cAAK,SAAS,EAAE,MAAM,CAAC,qBAAqB,EAAE,GAAG,EAAE,IAAI,CAAC,QAAQ,YAC5D,eAAK,SAAS,EAAE,MAAM,CAAC,iBAAiB,aACpC,cAAK,SAAS,EAAC,uCAAuC,YAClD,cACI,GAAG,EAAE,UAAU,EACf,GAAG,EAAC,OAAO,EACX,KAAK,EAAE,EAAE,EACT,MAAM,EAAE,EAAE,EACV,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;wCAEX,CAAC,CAAC,eAAe,EAAE,CAAC;wCACpB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;oCACzB,CAAC,EACD,SAAS,EAAE,MAAM,CAAC,cAAc,GAClC,GACA,EACN,KAAC,WAAW,IAAC,KAAK,EAAC,EAAE,EAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,cAAc,GAAI,EACtG,OAAO,IACN,GACJ,EACN,cAAK,SAAS,EAAE,MAAM,CAAC,oBAAoB,GAAQ,IACpD,CACN,CAAC;IACN,CAAC;CACJ;AAED,eAAe,mBAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -12,6 +12,7 @@ export interface NSAProductListProps
|
|
|
12
12
|
interface NSAProductListState
|
|
13
13
|
{
|
|
14
14
|
products: ProductFullRow[] | null;
|
|
15
|
+
search: string;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export class NSAProductListModal extends Component<NSAProductListProps, NSAProductListState>
|
|
@@ -22,15 +23,18 @@ export class NSAProductListModal extends Component<NSAProductListProps, NSAProdu
|
|
|
22
23
|
{
|
|
23
24
|
super(props);
|
|
24
25
|
this.toastRef = createRef();
|
|
25
|
-
this.state = { products: null };
|
|
26
|
+
this.state = { products: null, search: "" };
|
|
26
27
|
this.onClickOutside = this.onClickOutside.bind(this);
|
|
27
|
-
this.handleProducts = this.handleProducts.bind(this);
|
|
28
28
|
this.onSearchChange = this.onSearchChange.bind(this);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
override componentDidMount(): void
|
|
32
32
|
{
|
|
33
|
-
|
|
33
|
+
let server = new NamirasoftAPIProductServer(console.error);
|
|
34
|
+
server.product.List(null, null, null).then((res) =>
|
|
35
|
+
{
|
|
36
|
+
this.setState({ products: res.rows });
|
|
37
|
+
}).catch(() => { });
|
|
34
38
|
document.addEventListener('mousedown', this.onClickOutside);
|
|
35
39
|
}
|
|
36
40
|
|
|
@@ -39,24 +43,6 @@ export class NSAProductListModal extends Component<NSAProductListProps, NSAProdu
|
|
|
39
43
|
document.removeEventListener('mousedown', this.onClickOutside);
|
|
40
44
|
}
|
|
41
45
|
|
|
42
|
-
private handleProducts(search: string)
|
|
43
|
-
{
|
|
44
|
-
let tokens = search.split(' ').filter(x => x.trim()).map(x => x.toLowerCase());
|
|
45
|
-
let server = new NamirasoftAPIProductServer(console.error);
|
|
46
|
-
server.product.List(null, null, null).then((res) =>
|
|
47
|
-
{
|
|
48
|
-
let filteredProducts = res.rows.filter((product) =>
|
|
49
|
-
{
|
|
50
|
-
let name = product.name.toLowerCase();
|
|
51
|
-
for (let i = 0; i < tokens.length; i++)
|
|
52
|
-
if (name.toLowerCase().includes(tokens[i]))
|
|
53
|
-
return false;
|
|
54
|
-
return true;
|
|
55
|
-
});
|
|
56
|
-
this.setState({ products: filteredProducts });
|
|
57
|
-
}).catch(() => { });
|
|
58
|
-
}
|
|
59
|
-
|
|
60
46
|
private onClickOutside(event: MouseEvent)
|
|
61
47
|
{
|
|
62
48
|
if (this.toastRef.current && !this.toastRef.current.contains(event.target as Node))
|
|
@@ -67,7 +53,7 @@ export class NSAProductListModal extends Component<NSAProductListProps, NSAProdu
|
|
|
67
53
|
|
|
68
54
|
private onSearchChange(e: NSBoxSearch)
|
|
69
55
|
{
|
|
70
|
-
this.
|
|
56
|
+
this.setState({ search: e.getValue() });
|
|
71
57
|
}
|
|
72
58
|
|
|
73
59
|
override render()
|
|
@@ -78,13 +64,29 @@ export class NSAProductListModal extends Component<NSAProductListProps, NSAProdu
|
|
|
78
64
|
content = <NSLoading />;
|
|
79
65
|
} else
|
|
80
66
|
{
|
|
67
|
+
let tokens = this.state.search.split(' ').filter(x => x.trim()).map(x => x.toLowerCase());
|
|
68
|
+
|
|
69
|
+
let products = this.state.products;
|
|
70
|
+
if (this.state.search)
|
|
71
|
+
products = products.filter((product) =>
|
|
72
|
+
{
|
|
73
|
+
let name = product.name.toLowerCase();
|
|
74
|
+
for (let i = 0; i < tokens.length; i++)
|
|
75
|
+
if (!name.toLowerCase().includes(tokens[i]))
|
|
76
|
+
return false;
|
|
77
|
+
return true;
|
|
78
|
+
});
|
|
79
|
+
let getName = (name: string) =>
|
|
80
|
+
{
|
|
81
|
+
return name.replace("Namirasoft ", "").trim();
|
|
82
|
+
};
|
|
81
83
|
content = (
|
|
82
84
|
<div className={Styles.nsa_product_list_border}>
|
|
83
|
-
{
|
|
85
|
+
{products.map((product) => (
|
|
84
86
|
<div className={Styles.nsa_product_list} key={product.id}>
|
|
85
|
-
<img src={`${product.logo}`} alt={product.name} width={
|
|
87
|
+
<img src={`${product.logo}`} alt={product.name} width={64} height={64} className="rounded-circle" />
|
|
86
88
|
<div>
|
|
87
|
-
<span>{`${product.name}`}</span>
|
|
89
|
+
<span>{`${getName(product.name)}`}</span>
|
|
88
90
|
</div>
|
|
89
91
|
</div>
|
|
90
92
|
))}
|