From 739842f9326a0feb85d844dca440fa91548bbe4a Mon Sep 17 00:00:00 2001 From: Bekiboo Date: Thu, 22 Jan 2026 15:11:54 +0300 Subject: [PATCH] ix: correct 401 redirect for eCurrency and eReputation --- .../eCurrency/client/src/lib/apiClient.ts | 2 +- .../modals/other-calculation-modal.tsx | 2 +- .../src/components/modals/reference-modal.tsx | 311 +++++++++--------- .../modals/self-calculation-modal.tsx | 20 +- .../eReputation/client/src/lib/apiClient.ts | 2 +- .../client/src/pages/dashboard.tsx | 2 +- .../eReputation/client/src/pages/landing.tsx | 14 +- .../client/src/pages/references.tsx | 216 ++++++------ 8 files changed, 282 insertions(+), 287 deletions(-) diff --git a/platforms/eCurrency/client/src/lib/apiClient.ts b/platforms/eCurrency/client/src/lib/apiClient.ts index 8a8c1327c..ed0420d15 100644 --- a/platforms/eCurrency/client/src/lib/apiClient.ts +++ b/platforms/eCurrency/client/src/lib/apiClient.ts @@ -30,7 +30,7 @@ apiClient.interceptors.response.use( if (error.response?.status === 401) { localStorage.removeItem("ecurrency_token"); localStorage.removeItem("ecurrency_user"); - window.location.href = "/auth"; + window.location.href = "/"; } return Promise.reject(error); } diff --git a/platforms/eReputation/client/src/components/modals/other-calculation-modal.tsx b/platforms/eReputation/client/src/components/modals/other-calculation-modal.tsx index 0a7d27946..fdf61d8f6 100644 --- a/platforms/eReputation/client/src/components/modals/other-calculation-modal.tsx +++ b/platforms/eReputation/client/src/components/modals/other-calculation-modal.tsx @@ -185,7 +185,7 @@ export default function OtherCalculationModal({ open, onOpenChange }: OtherCalcu variant: "destructive", }); setTimeout(() => { - window.location.href = "/api/login"; + window.location.href = "/"; }, 500); return; } diff --git a/platforms/eReputation/client/src/components/modals/reference-modal.tsx b/platforms/eReputation/client/src/components/modals/reference-modal.tsx index d26c628c0..011a4d5aa 100644 --- a/platforms/eReputation/client/src/components/modals/reference-modal.tsx +++ b/platforms/eReputation/client/src/components/modals/reference-modal.tsx @@ -21,27 +21,27 @@ interface ReferenceModalProps { } const TARGET_TYPES = [ - { - value: "user", - label: "User", + { + value: "user", + label: "User", icon: ( ) }, - { - value: "group", - label: "Group", + { + value: "group", + label: "Group", icon: ( ) }, - { - value: "platform", - label: "Platform", + { + value: "platform", + label: "Platform", icon: ( @@ -76,7 +76,7 @@ export default function ReferenceModal({ open, onOpenChange }: ReferenceModalPro queryKey: ['search', targetType, searchQuery], queryFn: async () => { if (!targetType || searchQuery.length < 2) return []; - + if (targetType === 'platform') { // Search platforms using the new platform endpoint const response = await apiClient.get(`/api/platforms/search?q=${encodeURIComponent(searchQuery)}`); @@ -127,7 +127,7 @@ export default function ReferenceModal({ open, onOpenChange }: ReferenceModalPro variant: "destructive", }); setTimeout(() => { - window.location.href = "/api/login"; + window.location.href = "/"; }, 500); return; } @@ -144,33 +144,33 @@ export default function ReferenceModal({ open, onOpenChange }: ReferenceModalPro if (eventSource) { eventSource.close(); } - + // Connect to the backend SSE endpoint for signing status const baseURL = import.meta.env.VITE_EREPUTATION_BASE_URL || "http://localhost:8765"; const sseUrl = `${baseURL}/api/references/signing/session/${sessionId}/status`; - + const newEventSource = new EventSource(sseUrl); - + newEventSource.onopen = () => { console.log("SSE connection established for reference signing"); }; - + newEventSource.onmessage = (e) => { try { const data = JSON.parse(e.data); - + if (data.type === "signed" && data.status === "completed") { setSigningStatus("signed"); newEventSource.close(); - + toast({ title: "Reference Signed!", description: "Your eReference has been successfully signed and submitted.", }); - + queryClient.invalidateQueries({ queryKey: ["/api/dashboard/stats"] }); queryClient.invalidateQueries({ queryKey: ["/api/dashboard/activities"] }); - + // Close modal and reset after a short delay setTimeout(() => { onOpenChange(false); @@ -349,7 +349,7 @@ export default function ReferenceModal({ open, onOpenChange }: ReferenceModalPro - +
{signingSession ? ( // Signing Interface @@ -397,7 +397,7 @@ export default function ReferenceModal({ open, onOpenChange }: ReferenceModalPro Session expires in {formatTime(timeRemaining)}
- + {signingStatus === "signed" && (
@@ -446,160 +446,159 @@ export default function ReferenceModal({ open, onOpenChange }: ReferenceModalPro ) : ( // Reference Form
- {/* Target Selection */} -
-

Select eReference Target

- -
- {TARGET_TYPES.map((type) => ( - - ))} -
-
-
- - {/* Search Target */} -
- -
- handleSearchChange(e.target.value)} - className="pl-10 border-2 border-fig/20 focus:border-fig/40 focus:ring-fig/20 rounded-2xl" - disabled={!targetType} - /> - - - - - {/* Search Results Dropdown - Absolute positioned overlay */} - {searchQuery.length >= 2 && !selectedTarget && ( -
- {isSearching ? ( -
-
- Searching... -
- ) : searchResults.length > 0 ? ( - searchResults.map((result: any, index: number) => ( -
- - )) - ) : ( -
- No {targetType}s found for "{searchQuery}" + + )) + ) : ( +
+ No {targetType}s found for "{searchQuery}" +
+ )} +
+ )} +
+ + {/* Selected Target Display */} + {selectedTarget && ( +
+
+
+ + + + + {selectedTarget.name || selectedTarget.ename || selectedTarget.handle || 'Unknown'} +
- )} + +
)}
- - {/* Selected Target Display */} - {selectedTarget && ( -
-
-
- - - - - {selectedTarget.name || selectedTarget.ename || selectedTarget.handle || 'Unknown'} - -
- -
+ + {/* Reference Text */} +
+ +