From a7b7be491eaf93782c0ddd65efd46713c998950b Mon Sep 17 00:00:00 2001 From: =bhagwanSingh <=bhagwan.r@hicglobalsolutions.com> Date: Thu, 9 Oct 2025 16:30:58 +0530 Subject: [PATCH] Redirect Solved 09-10 --- .../process/processStepOne/ProcessStepOne.tsx | 4 +- src/components/signature/ClientSignCon.tsx | 66 ++++++++++--------- src/config/api.tsx | 28 ++++++-- src/config/axiosInstance.tsx | 59 +++++++++-------- 4 files changed, 88 insertions(+), 69 deletions(-) diff --git a/src/components/process/processStepOne/ProcessStepOne.tsx b/src/components/process/processStepOne/ProcessStepOne.tsx index 2678c25..05ee84c 100644 --- a/src/components/process/processStepOne/ProcessStepOne.tsx +++ b/src/components/process/processStepOne/ProcessStepOne.tsx @@ -488,7 +488,7 @@ const ProcessStepOne = () => { transactionTemplateToggle !== TRANSACTION_TEMPLATE_TOGGLE.TEMPLATES &&

Signers

-
+ {/*
handleSelfSignCb(e)} @@ -496,7 +496,7 @@ const ProcessStepOne = () => { /> -
+
*/}
} diff --git a/src/components/signature/ClientSignCon.tsx b/src/components/signature/ClientSignCon.tsx index 6f5b823..79451a2 100644 --- a/src/components/signature/ClientSignCon.tsx +++ b/src/components/signature/ClientSignCon.tsx @@ -164,18 +164,21 @@ const ClientSignCon: React.FC = ({ if (res.data.length) { const defaultVal = res.data.filter((obj, indx) => "default" in obj && obj.default); - const { id, initialsBlob, signatureBlob } = defaultVal[0]; + if (defaultVal.length > 0) { + const { id, initialsBlob, signatureBlob } = defaultVal[0]; - if (initialsBlob && signatureBlob) { - setSaved({ - signatureId: id, - saveType: SaveTypeEnum.DRAW, - save: true, - signature: signatureBlob, - initial: initialsBlob, - isDefaultAndClicked: true - }); + if (initialsBlob && signatureBlob) { + setSaved({ + signatureId: id, + saveType: SaveTypeEnum.DRAW, + save: true, + signature: signatureBlob, + initial: initialsBlob, + isDefaultAndClicked: true + }); + } } + } setPreSaveSignatures(preSavedSignatures) } @@ -705,28 +708,31 @@ const ClientSignCon: React.FC = ({ return (
{/* Header */} -
-

Saved Signatures

+
+

Saved Signatures

Select from your pre-saved signatures

- {/* Signatures List */} -
-
+ {/* Horizontal Scrollable List */} +
+
{preSaveSignatures.map((signature) => (
setSelectedSignature(signature?.id)} + className={`cursor-pointer bg-white rounded-xl border p-4 w-full flex justify-between items-start transition-shadow duration-200 gap-3 + ${selectedSignature === signature?.id ? 'border-blue-500 shadow-lg' : 'border-gray-200'} + `} + style={{ minWidth: '220px' }} // each card width > - {/* Full Signature */} -
- Signed by: - -
+ {/* Signature */} +
+ Signed by: +
{signature?.signatureType !== 'SELECT' && signature?.signatureBlob ? ( {`${signature?.firstName ) : ( @@ -739,19 +745,17 @@ const ClientSignCon: React.FC = ({ ) )}
- - {signature?.signatureHash ?? ' '} + {/* {signature?.signatureHash ?? ' '} */}
{/* Initials */} -
- Initials - -
+
+ Initials +
{signature?.signatureType !== 'SELECT' && signature?.initialsBlob ? ( {`${signature?.firstName ) : ( @@ -764,8 +768,7 @@ const ClientSignCon: React.FC = ({ ) )}
- - {signature?.initialsHash ?? ' '} + {/* {signature?.initialsHash ?? ' '} */}
))} @@ -775,6 +778,7 @@ const ClientSignCon: React.FC = ({ ); + default: return null; } diff --git a/src/config/api.tsx b/src/config/api.tsx index 7532c7a..ef4c4b9 100644 --- a/src/config/api.tsx +++ b/src/config/api.tsx @@ -3,7 +3,7 @@ import axios from "axios"; const api = axios.create({ baseURL: import.meta.env.VITE_BASE_URI, - maxRedirects: 5, + maxRedirects: 10, withCredentials: true, headers: { "Content-Type": "application/json", @@ -49,6 +49,19 @@ api.interceptors.response.use( if (window.location.pathname === "/login" || window.location.pathname === "/register") { window.location.href = "/"; } + + if (typeof response.data === 'string' && response.data.toLowerCase().includes('')) { + // Likely a full HTML page, handle accordinglys + window.location.href = response.request.responseURL; + } + + if (response && (response.status === 301 || response.status === 302)) { + const redirectUrl = response.headers["location"]; + if (redirectUrl) { + window.location.href = redirectUrl; + } + } + return response; }, async error => { @@ -58,12 +71,13 @@ api.interceptors.response.use( // const res = error.response; // 🔹 Handle 301/302 manually - // if (res && (res.status === 301 || res.status === 302)) { - // const redirectUrl = res.headers["location"]; - // if (redirectUrl) { - // window.location.href = redirectUrl; - // } - // } + + if (error && (error.status === 301 || error.status === 302)) { + const redirectUrl = error.headers["location"]; + if (redirectUrl) { + window.location.href = redirectUrl; + } + } // Prevent multiple refresh attempts // if (error.response?.status === 401 || error.response?.status === 500) { diff --git a/src/config/axiosInstance.tsx b/src/config/axiosInstance.tsx index fa32d9c..091f83e 100644 --- a/src/config/axiosInstance.tsx +++ b/src/config/axiosInstance.tsx @@ -2,45 +2,46 @@ import axios, { AxiosInstance } from "axios"; const defaultHeaders = { - "Content-Type": "application/json", - "ngrok-skip-browser-warning": "69420", + "Content-Type": "application/json", + "ngrok-skip-browser-warning": "69420", }; const axiosInstance: AxiosInstance = axios.create({ - baseURL: import.meta.env.VITE_BASE_URI, - withCredentials: true, - headers: defaultHeaders, - validateStatus: (status) => status >= 200 && status < 400, + baseURL: import.meta.env.VITE_BASE_URI, + withCredentials: true, + headers: defaultHeaders, + validateStatus: (status) => status >= 200 && status < 400, }); axiosInstance.interceptors.response.use( - (response) => { - // ✅ Handle backend "soft redirects" - if (response?.data?.redirect) { - const redirectUrl = response.data.redirect; + (response) => { - // Use location.replace to avoid back button returning to invalid page - window.location.replace(redirectUrl); - // OR window.location.href = redirectUrl; if you want history entry + if (typeof response.data === 'string' && response.data.toLowerCase().includes('')) { + // Likely a full HTML page, handle accordingly + window.location.href = response.request.responseURL; + } - // Optionally return a rejected promise to stop normal handling - return Promise.reject({ redirected: true }); + if (response && (response.status === 301 || response.status === 302)) { + const redirectUrl = response.headers["location"]; + if (redirectUrl) { + window.location.href = redirectUrl; + } + } + + // Otherwise just continue as normal + return response; + }, + (error) => { + // Optionally handle backend 302 or 3xx here (if returned as error) + if (error.response?.status === 302 && error.response?.headers?.location) { + window.location.replace(error.response.headers.location); + return Promise.reject({ redirected: true }); + } + + // Pass through all other errors + return Promise.reject(error); } - - // Otherwise just continue as normal - return response; - }, - (error) => { - // Optionally handle backend 302 or 3xx here (if returned as error) - if (error.response?.status === 302 && error.response?.headers?.location) { - window.location.replace(error.response.headers.location); - return Promise.reject({ redirected: true }); - } - - // Pass through all other errors - return Promise.reject(error); - } ); export default axiosInstance;