astra-sdk-web 1.1.20 → 1.1.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astra-sdk-web",
3
- "version": "1.1.20",
3
+ "version": "1.1.21",
4
4
  "description": "Official Astra SDK for JavaScript/TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/astra-sdk.cjs.js",
@@ -1,6 +1,7 @@
1
1
  import { useState, useEffect } from 'react';
2
2
  import { QRCodeSVG } from 'qrcode.react';
3
3
  import { KycApiService } from '../services/kycApiService';
4
+ import { ToastContainer } from '../components/Toast';
4
5
  import '../index.css';
5
6
 
6
7
  interface QRCodePageProps {
@@ -15,6 +16,16 @@ interface QRCodePageProps {
15
16
  function QRCodePage({ onClose, mobileBaseUrl = 'https://kyc-sdk-stage.astraprotocol.com', sessionId, apiBaseUrl, serverKey }: QRCodePageProps = {}) {
16
17
  const [qrUrl, setQrUrl] = useState<string>('');
17
18
  const [copied, setCopied] = useState<boolean>(false);
19
+ const [toasts, setToasts] = useState<Array<{ id: string; message: string; type?: 'success' | 'error' | 'info' | 'warning' }>>([]);
20
+
21
+ const addToast = (message: string, type: 'success' | 'error' | 'info' | 'warning' = 'info') => {
22
+ const id = `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
23
+ setToasts((prev) => [...prev, { id, message, type }]);
24
+ };
25
+
26
+ const removeToast = (id: string) => {
27
+ setToasts((prev) => prev.filter((t) => t.id !== id));
28
+ };
18
29
 
19
30
  useEffect(() => {
20
31
  // Get search params from current URL
@@ -58,7 +69,7 @@ function QRCodePage({ onClose, mobileBaseUrl = 'https://kyc-sdk-stage.astraproto
58
69
 
59
70
  const handleCheckResult = async () => {
60
71
  if (!apiBaseUrl || !sessionId || !serverKey) {
61
- alert('Missing configuration to check KYC result.');
72
+ addToast('Missing configuration to check KYC result.', 'error');
62
73
  return;
63
74
  }
64
75
 
@@ -68,21 +79,22 @@ function QRCodePage({ onClose, mobileBaseUrl = 'https://kyc-sdk-stage.astraproto
68
79
 
69
80
  const first = Array.isArray(payload?.data) && payload.data.length > 0 ? payload.data[0] : null;
70
81
 
71
- if (first && first.kyc_status === 'verified' && first.redirectUrl) {
82
+ if (first && first.kyc_status === 'verified') {
72
83
  window.location.href = "https://astra-pro-business.astraprotocol.com/pricing-plans";
73
84
  return;
74
85
  }
75
86
 
76
- alert('Please complete your KYC first.');
87
+ addToast('Please complete your KYC first.', 'warning');
77
88
  } catch (error: any) {
78
89
  const msg = error?.message || 'Result fetch failed';
79
90
  console.error('getResult:error', msg);
80
- alert(`Result fetch failed: ${msg}`);
91
+ addToast(`Result fetch failed: ${msg}`, 'error');
81
92
  }
82
93
  };
83
94
 
84
95
  return (
85
96
  <div className="fixed inset-0 flex items-center justify-center bg-gradient-to-br from-gray-900 via-gray-800 to-black p-4 sm:p-6 md:p-8 z-[1000]">
97
+ <ToastContainer toasts={toasts} onRemove={removeToast} />
86
98
  {/* Background pattern overlay */}
87
99
  <div className="absolute inset-0 opacity-10" style={{
88
100
  backgroundImage: `radial-gradient(circle at 2px 2px, rgba(255,255,255,0.15) 1px, transparent 0)`,