@bytexbyte/nxtlinq-ai-agent-sdk 1.2.1 â 1.2.2
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/README.md +14 -0
- package/dist/components/ChatBot.d.ts.map +1 -1
- package/dist/components/ChatBot.js +150 -52
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ A powerful SDK for building intelligent conversation applications with Nxtlinq A
|
|
|
17
17
|
- đ Permission-based access control
|
|
18
18
|
- đ Enhanced error handling and debugging
|
|
19
19
|
- ⥠Improved async operation handling
|
|
20
|
+
- đ Unified notification system with Modal prompts
|
|
20
21
|
|
|
21
22
|
## Installation
|
|
22
23
|
|
|
@@ -70,6 +71,8 @@ function App() {
|
|
|
70
71
|
}
|
|
71
72
|
```
|
|
72
73
|
|
|
74
|
+
> **Note**: The SDK now includes a unified notification system. All success, error, warning, and info messages are displayed as Modal prompts in the top-right corner, providing a consistent and non-intrusive user experience.
|
|
75
|
+
|
|
73
76
|
## Berify.me Integration
|
|
74
77
|
|
|
75
78
|
The SDK supports Berify.me wallet verification for enhanced security:
|
|
@@ -130,6 +133,17 @@ function App() {
|
|
|
130
133
|
| retryDelay | number | No | Delay between retries in milliseconds (default: 1000) |
|
|
131
134
|
| permissionGroup | string | No | Permission group name for filtering permissions |
|
|
132
135
|
|
|
136
|
+
### Notification System
|
|
137
|
+
|
|
138
|
+
The SDK includes a unified notification system that displays Modal prompts for various operations:
|
|
139
|
+
|
|
140
|
+
- **Success Notifications**: Green modal for successful operations (auto-hide after 3 seconds)
|
|
141
|
+
- **Error Notifications**: Red modal for error messages (auto-hide after 5 seconds)
|
|
142
|
+
- **Warning Notifications**: Orange modal for warnings (auto-hide after 4 seconds)
|
|
143
|
+
- **Info Notifications**: Blue modal for informational messages (auto-hide after 3 seconds)
|
|
144
|
+
|
|
145
|
+
All notifications appear in the top-right corner and can be manually dismissed by clicking the à button.
|
|
146
|
+
|
|
133
147
|
##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,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAC1D,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC;QAC7B,KAAK,EAAE,MAAM,CAAC;KACf,GAAG,SAAS,CAAC,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AA8hBD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAmjC1C,CAAC"}
|
|
@@ -5,6 +5,61 @@ import { createNxtlinqApi } from '../api/nxtlinq-api';
|
|
|
5
5
|
import stringify from 'fast-json-stable-stringify';
|
|
6
6
|
import metakeepClient from '../core/metakeepClient';
|
|
7
7
|
import useLocalStorage from '../core/lib/useLocalStorage';
|
|
8
|
+
const NotificationModal = ({ notification, onClose }) => {
|
|
9
|
+
const getStyles = () => {
|
|
10
|
+
const baseStyles = {
|
|
11
|
+
position: 'fixed',
|
|
12
|
+
bottom: 20,
|
|
13
|
+
right: 20,
|
|
14
|
+
padding: '12px 24px',
|
|
15
|
+
borderRadius: 8,
|
|
16
|
+
zIndex: 2000,
|
|
17
|
+
fontWeight: 600,
|
|
18
|
+
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',
|
|
19
|
+
transition: 'all 0.3s ease',
|
|
20
|
+
display: 'flex',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
gap: '12px',
|
|
23
|
+
minWidth: '300px',
|
|
24
|
+
maxWidth: '500px'
|
|
25
|
+
};
|
|
26
|
+
switch (notification.type) {
|
|
27
|
+
case 'success':
|
|
28
|
+
return { ...baseStyles, background: '#4caf50', color: 'white' };
|
|
29
|
+
case 'error':
|
|
30
|
+
return { ...baseStyles, background: '#f44336', color: 'white' };
|
|
31
|
+
case 'warning':
|
|
32
|
+
return { ...baseStyles, background: '#ff9800', color: 'white' };
|
|
33
|
+
default:
|
|
34
|
+
return { ...baseStyles, background: '#2196f3', color: 'white' };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const getIcon = () => {
|
|
38
|
+
switch (notification.type) {
|
|
39
|
+
case 'success':
|
|
40
|
+
return 'â
';
|
|
41
|
+
case 'error':
|
|
42
|
+
return 'â';
|
|
43
|
+
case 'warning':
|
|
44
|
+
return 'â ī¸';
|
|
45
|
+
default:
|
|
46
|
+
return 'âšī¸';
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
return (notification.show && (_jsxs("div", { style: getStyles(), children: [_jsx("span", { style: { fontSize: '18px' }, children: getIcon() }), _jsx("span", { style: { flex: 1 }, children: notification.message }), _jsx("button", { onClick: onClose, style: {
|
|
50
|
+
background: 'none',
|
|
51
|
+
border: 'none',
|
|
52
|
+
color: 'white',
|
|
53
|
+
fontSize: '18px',
|
|
54
|
+
cursor: 'pointer',
|
|
55
|
+
padding: '4px',
|
|
56
|
+
display: 'flex',
|
|
57
|
+
alignItems: 'center',
|
|
58
|
+
justifyContent: 'center',
|
|
59
|
+
borderRadius: '4px',
|
|
60
|
+
transition: 'background-color 0.2s'
|
|
61
|
+
}, onMouseOver: (e) => e.currentTarget.style.backgroundColor = 'rgba(255, 255, 255, 0.2)', onMouseOut: (e) => e.currentTarget.style.backgroundColor = 'transparent', children: "\u00D7" })] })));
|
|
62
|
+
};
|
|
8
63
|
const PermissionForm = ({ hitAddress, permissions, setPermissions, setIsDisabled, onClose, onSave, onConnectWallet, onSignIn, isNeedSignInWithWallet, walletInfo, onVerifyWallet, serviceId, nxtlinqApi, permissionGroup, isAITLoading, isWalletLoading = false }) => {
|
|
9
64
|
const [availablePermissions, setAvailablePermissions] = React.useState([]);
|
|
10
65
|
const [isSaving, setIsSaving] = React.useState(false);
|
|
@@ -310,7 +365,6 @@ export const ChatBot = ({ onMessage, onError, onToolUse, presetMessages = [], pl
|
|
|
310
365
|
const [permissions, setPermissions] = React.useState([]);
|
|
311
366
|
const [availablePermissions, setAvailablePermissions] = React.useState([]);
|
|
312
367
|
const [showPermissionForm, setShowPermissionForm] = React.useState(false);
|
|
313
|
-
const [success, setSuccess] = React.useState(false);
|
|
314
368
|
const [isPermissionFormOpen, setIsPermissionFormOpen] = React.useState(false);
|
|
315
369
|
const [isAITLoading, setIsAITLoading] = React.useState(false);
|
|
316
370
|
const messagesEndRef = React.useRef(null);
|
|
@@ -320,7 +374,34 @@ export const ChatBot = ({ onMessage, onError, onToolUse, presetMessages = [], pl
|
|
|
320
374
|
const verifyWalletBtnRef = React.useRef(null);
|
|
321
375
|
const [nxtlinqAITServiceAccessToken, setNxtlinqAITServiceAccessToken] = useLocalStorage('nxtlinqAITServiceAccessToken', '');
|
|
322
376
|
const [isWalletLoading, setIsWalletLoading] = React.useState(false);
|
|
377
|
+
const [notification, setNotification] = React.useState({
|
|
378
|
+
show: false,
|
|
379
|
+
type: 'info',
|
|
380
|
+
message: '',
|
|
381
|
+
autoHide: true,
|
|
382
|
+
duration: 5000
|
|
383
|
+
});
|
|
323
384
|
const nxtlinqApi = React.useMemo(() => createNxtlinqApi(apiKey, apiSecret), [apiKey, apiSecret]);
|
|
385
|
+
// Unified notification functions
|
|
386
|
+
const showNotification = (type, message, duration = 5000) => {
|
|
387
|
+
setNotification({
|
|
388
|
+
show: true,
|
|
389
|
+
type,
|
|
390
|
+
message,
|
|
391
|
+
autoHide: true,
|
|
392
|
+
duration
|
|
393
|
+
});
|
|
394
|
+
// Auto-hide
|
|
395
|
+
if (duration > 0) {
|
|
396
|
+
setTimeout(() => {
|
|
397
|
+
setNotification(prev => ({ ...prev, show: false }));
|
|
398
|
+
}, duration);
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
const showSuccess = (message) => showNotification('success', message, 3000);
|
|
402
|
+
const showError = (message) => showNotification('error', message, 5000);
|
|
403
|
+
const showWarning = (message) => showNotification('warning', message, 4000);
|
|
404
|
+
const showInfo = (message) => showNotification('info', message, 3000);
|
|
324
405
|
const fetchAvailablePermissions = async () => {
|
|
325
406
|
if (!serviceId)
|
|
326
407
|
return;
|
|
@@ -484,7 +565,7 @@ export const ChatBot = ({ onMessage, onError, onToolUse, presetMessages = [], pl
|
|
|
484
565
|
signer: !!signer
|
|
485
566
|
});
|
|
486
567
|
if (!hitAddress) {
|
|
487
|
-
|
|
568
|
+
showError('Please connect your wallet first.');
|
|
488
569
|
return;
|
|
489
570
|
}
|
|
490
571
|
try {
|
|
@@ -540,11 +621,13 @@ export const ChatBot = ({ onMessage, onError, onToolUse, presetMessages = [], pl
|
|
|
540
621
|
}
|
|
541
622
|
}
|
|
542
623
|
setIsLoading(false);
|
|
624
|
+
// Use Modal notification instead of ChatBot message
|
|
625
|
+
showSuccess('Wallet verification completed successfully! Your wallet is now verified and ready to use.');
|
|
543
626
|
// Refresh AIT after wallet verification
|
|
544
627
|
refreshAIT();
|
|
545
628
|
return { token, hitAddress: address };
|
|
546
629
|
}
|
|
547
|
-
|
|
630
|
+
showError(verifyWalletResponse.error);
|
|
548
631
|
setIsLoading(false);
|
|
549
632
|
return;
|
|
550
633
|
}
|
|
@@ -579,6 +662,8 @@ export const ChatBot = ({ onMessage, onError, onToolUse, presetMessages = [], pl
|
|
|
579
662
|
}
|
|
580
663
|
}
|
|
581
664
|
setIsLoading(false);
|
|
665
|
+
// Use Modal notification instead of ChatBot message
|
|
666
|
+
showSuccess('Wallet verification completed successfully! Your wallet is now verified and ready to use.');
|
|
582
667
|
// Refresh AIT after wallet verification
|
|
583
668
|
refreshAIT();
|
|
584
669
|
return { token, hitAddress: address };
|
|
@@ -593,7 +678,7 @@ export const ChatBot = ({ onMessage, onError, onToolUse, presetMessages = [], pl
|
|
|
593
678
|
msg = error.message;
|
|
594
679
|
}
|
|
595
680
|
console.error('Wallet verification failed:', error);
|
|
596
|
-
|
|
681
|
+
showError(msg);
|
|
597
682
|
setIsLoading(false);
|
|
598
683
|
throw error;
|
|
599
684
|
}
|
|
@@ -605,7 +690,7 @@ export const ChatBot = ({ onMessage, onError, onToolUse, presetMessages = [], pl
|
|
|
605
690
|
catch (error) {
|
|
606
691
|
console.error('Failed to verify wallet:', error);
|
|
607
692
|
setIsLoading(false);
|
|
608
|
-
|
|
693
|
+
showError('Failed to verify wallet. Please try again.');
|
|
609
694
|
throw error;
|
|
610
695
|
}
|
|
611
696
|
};
|
|
@@ -686,12 +771,7 @@ export const ChatBot = ({ onMessage, onError, onToolUse, presetMessages = [], pl
|
|
|
686
771
|
}
|
|
687
772
|
else {
|
|
688
773
|
// User is already signed in
|
|
689
|
-
|
|
690
|
-
id: Date.now().toString(),
|
|
691
|
-
content: 'Successfully connected your HIT wallet. You are already signed in and can use the AI agent.',
|
|
692
|
-
role: 'assistant',
|
|
693
|
-
timestamp: new Date().toISOString()
|
|
694
|
-
}]);
|
|
774
|
+
showSuccess('Successfully connected your HIT wallet. You are already signed in and can use the AI agent.');
|
|
695
775
|
}
|
|
696
776
|
}
|
|
697
777
|
return userAddress;
|
|
@@ -706,17 +786,17 @@ export const ChatBot = ({ onMessage, onError, onToolUse, presetMessages = [], pl
|
|
|
706
786
|
}, [nxtlinqAITServiceAccessToken, refreshAIT, isNeedSignInWithWallet]);
|
|
707
787
|
const signInWallet = async (autoShowSuccessMessage = true) => {
|
|
708
788
|
if (!hitAddress) {
|
|
709
|
-
|
|
789
|
+
showError('Please connect your wallet first.');
|
|
710
790
|
return;
|
|
711
791
|
}
|
|
712
792
|
if (!signer) {
|
|
713
|
-
|
|
793
|
+
showError('Please connect your wallet first.');
|
|
714
794
|
return;
|
|
715
795
|
}
|
|
716
796
|
try {
|
|
717
797
|
const nonceResponse = await nxtlinqApi.auth.getNonce({ address: hitAddress });
|
|
718
798
|
if ('error' in nonceResponse) {
|
|
719
|
-
|
|
799
|
+
showError(nonceResponse.error);
|
|
720
800
|
return;
|
|
721
801
|
}
|
|
722
802
|
const payload = {
|
|
@@ -731,26 +811,21 @@ export const ChatBot = ({ onMessage, onError, onToolUse, presetMessages = [], pl
|
|
|
731
811
|
signature
|
|
732
812
|
});
|
|
733
813
|
if ('error' in response) {
|
|
734
|
-
|
|
814
|
+
showError(response.error);
|
|
735
815
|
return;
|
|
736
816
|
}
|
|
737
817
|
const { accessToken } = response;
|
|
738
818
|
setNxtlinqAITServiceAccessToken(accessToken);
|
|
739
819
|
// Auto-show connected message after signing in
|
|
740
820
|
if (autoShowSuccessMessage) {
|
|
741
|
-
|
|
742
|
-
id: Date.now().toString(),
|
|
743
|
-
content: 'Successfully signed in with your HIT wallet. You can now use the AI agent.',
|
|
744
|
-
role: 'assistant',
|
|
745
|
-
timestamp: new Date().toISOString()
|
|
746
|
-
}]);
|
|
821
|
+
showSuccess('Successfully signed in with your HIT wallet. You can now use the AI agent.');
|
|
747
822
|
}
|
|
748
823
|
// Refresh AIT after signing in
|
|
749
824
|
refreshAIT();
|
|
750
825
|
}
|
|
751
826
|
catch (error) {
|
|
752
827
|
console.error('Failed to sign in:', error);
|
|
753
|
-
|
|
828
|
+
showError('Failed to sign in. Please try again.');
|
|
754
829
|
}
|
|
755
830
|
};
|
|
756
831
|
const hasPermission = async (toolName) => {
|
|
@@ -764,7 +839,7 @@ export const ChatBot = ({ onMessage, onError, onToolUse, presetMessages = [], pl
|
|
|
764
839
|
}]);
|
|
765
840
|
return false;
|
|
766
841
|
}
|
|
767
|
-
// Check if user has signed in with wallet
|
|
842
|
+
// Check if user has signed in with wallet and token is valid
|
|
768
843
|
if (!nxtlinqAITServiceAccessToken) {
|
|
769
844
|
setMessages(prev => [...prev, {
|
|
770
845
|
id: Date.now().toString(),
|
|
@@ -775,6 +850,51 @@ export const ChatBot = ({ onMessage, onError, onToolUse, presetMessages = [], pl
|
|
|
775
850
|
}]);
|
|
776
851
|
return false;
|
|
777
852
|
}
|
|
853
|
+
// Validate token - check if it's expired or for different address
|
|
854
|
+
try {
|
|
855
|
+
const payload = JSON.parse(atob(nxtlinqAITServiceAccessToken.split('.')[1]));
|
|
856
|
+
const exp = payload.exp * 1000; // Convert to milliseconds
|
|
857
|
+
const now = Date.now();
|
|
858
|
+
if (exp < now) {
|
|
859
|
+
// Clear invalid token
|
|
860
|
+
setNxtlinqAITServiceAccessToken('');
|
|
861
|
+
setMessages(prev => [...prev, {
|
|
862
|
+
id: Date.now().toString(),
|
|
863
|
+
content: 'Your wallet session has expired. Please sign in again.',
|
|
864
|
+
role: 'assistant',
|
|
865
|
+
timestamp: new Date().toISOString(),
|
|
866
|
+
button: 'signIn'
|
|
867
|
+
}]);
|
|
868
|
+
return false;
|
|
869
|
+
}
|
|
870
|
+
// Check if the token's payload has the same address as the wallet address
|
|
871
|
+
const address = payload.address;
|
|
872
|
+
if (address !== hitAddress) {
|
|
873
|
+
// Clear mismatched token
|
|
874
|
+
setNxtlinqAITServiceAccessToken('');
|
|
875
|
+
setMessages(prev => [...prev, {
|
|
876
|
+
id: Date.now().toString(),
|
|
877
|
+
content: 'Wallet address mismatch. Please sign in with the correct wallet.',
|
|
878
|
+
role: 'assistant',
|
|
879
|
+
timestamp: new Date().toISOString(),
|
|
880
|
+
button: 'signIn'
|
|
881
|
+
}]);
|
|
882
|
+
return false;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
catch (error) {
|
|
886
|
+
console.error('Error parsing token:', error);
|
|
887
|
+
// Clear invalid token
|
|
888
|
+
setNxtlinqAITServiceAccessToken('');
|
|
889
|
+
setMessages(prev => [...prev, {
|
|
890
|
+
id: Date.now().toString(),
|
|
891
|
+
content: 'Invalid wallet session. Please sign in again.',
|
|
892
|
+
role: 'assistant',
|
|
893
|
+
timestamp: new Date().toISOString(),
|
|
894
|
+
button: 'signIn'
|
|
895
|
+
}]);
|
|
896
|
+
return false;
|
|
897
|
+
}
|
|
778
898
|
if (!ait) {
|
|
779
899
|
setMessages(prev => [...prev, {
|
|
780
900
|
id: Date.now().toString(),
|
|
@@ -943,7 +1063,8 @@ export const ChatBot = ({ onMessage, onError, onToolUse, presetMessages = [], pl
|
|
|
943
1063
|
setIsDisabled(true);
|
|
944
1064
|
try {
|
|
945
1065
|
await generateAndRegisterAIT();
|
|
946
|
-
|
|
1066
|
+
// Use Modal notification instead of ChatBot message
|
|
1067
|
+
showSuccess('AIT permissions saved successfully! You can now use the AI agent with your configured permissions.');
|
|
947
1068
|
setShowPermissionForm(false);
|
|
948
1069
|
setIsPermissionFormOpen(false);
|
|
949
1070
|
}
|
|
@@ -951,7 +1072,10 @@ export const ChatBot = ({ onMessage, onError, onToolUse, presetMessages = [], pl
|
|
|
951
1072
|
console.error('Failed to generate AIT:', error);
|
|
952
1073
|
setIsDisabled(false);
|
|
953
1074
|
if (error instanceof Error) {
|
|
954
|
-
|
|
1075
|
+
showError(error.message);
|
|
1076
|
+
}
|
|
1077
|
+
else {
|
|
1078
|
+
showError('Failed to save permissions. Please try again.');
|
|
955
1079
|
}
|
|
956
1080
|
}
|
|
957
1081
|
};
|
|
@@ -971,15 +1095,6 @@ export const ChatBot = ({ onMessage, onError, onToolUse, presetMessages = [], pl
|
|
|
971
1095
|
onMessage?.(lastMessage);
|
|
972
1096
|
}
|
|
973
1097
|
}, [messages, onMessage]);
|
|
974
|
-
// Auto hide success message after 3 seconds
|
|
975
|
-
React.useEffect(() => {
|
|
976
|
-
if (success) {
|
|
977
|
-
const timer = setTimeout(() => {
|
|
978
|
-
setSuccess(false);
|
|
979
|
-
}, 3000);
|
|
980
|
-
return () => clearTimeout(timer);
|
|
981
|
-
}
|
|
982
|
-
}, [success]);
|
|
983
1098
|
return (_jsxs("div", { style: {
|
|
984
1099
|
position: 'fixed',
|
|
985
1100
|
bottom: '20px',
|
|
@@ -1123,22 +1238,5 @@ export const ChatBot = ({ onMessage, onError, onToolUse, presetMessages = [], pl
|
|
|
1123
1238
|
}, children: _jsx(PermissionForm, { hitAddress: hitAddress, permissions: permissions, setPermissions: setPermissions, setIsDisabled: setIsDisabled, onClose: () => {
|
|
1124
1239
|
setShowPermissionForm(false);
|
|
1125
1240
|
setIsPermissionFormOpen(false);
|
|
1126
|
-
}, onConnectWallet: () => connectWallet(false), onSignIn: () => signInWallet(false), onSave: savePermissions, isNeedSignInWithWallet: isNeedSignInWithWallet, walletInfo: walletInfo, onVerifyWallet: handleVerifyWalletClick, serviceId: serviceId, nxtlinqApi: nxtlinqApi, permissionGroup: permissionGroup, isAITLoading: isAITLoading, isWalletLoading: isWalletLoading }) })),
|
|
1127
|
-
position: 'fixed',
|
|
1128
|
-
bottom: 100,
|
|
1129
|
-
right: 40,
|
|
1130
|
-
background: '#4caf50',
|
|
1131
|
-
color: 'white',
|
|
1132
|
-
padding: '12px 24px',
|
|
1133
|
-
borderRadius: 8,
|
|
1134
|
-
zIndex: 2000,
|
|
1135
|
-
fontWeight: 600,
|
|
1136
|
-
}, children: ["Saved successfully!", _jsx("button", { style: {
|
|
1137
|
-
background: 'none',
|
|
1138
|
-
border: 'none',
|
|
1139
|
-
color: 'white',
|
|
1140
|
-
marginLeft: 16,
|
|
1141
|
-
fontSize: 18,
|
|
1142
|
-
cursor: 'pointer'
|
|
1143
|
-
}, onClick: () => setSuccess(false), children: "\u00D7" })] }))] }));
|
|
1241
|
+
}, onConnectWallet: () => connectWallet(false), onSignIn: () => signInWallet(false), onSave: savePermissions, isNeedSignInWithWallet: isNeedSignInWithWallet, walletInfo: walletInfo, onVerifyWallet: handleVerifyWalletClick, serviceId: serviceId, nxtlinqApi: nxtlinqApi, permissionGroup: permissionGroup, isAITLoading: isAITLoading, isWalletLoading: isWalletLoading }) })), notification.show && (_jsx(NotificationModal, { notification: notification, onClose: () => setNotification({ ...notification, show: false }) }))] }));
|
|
1144
1242
|
};
|
package/package.json
CHANGED