|
@@ -197,6 +197,19 @@ export default function IntegrationsRedirect() {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// Fetch shop info for auto-registration feature
|
|
// Fetch shop info for auto-registration feature
|
|
|
|
|
+ // First check if we have cached shop info in sessionStorage
|
|
|
|
|
+ const cachedShopInfo = sessionStorage.getItem(`shop_info_${srInstall}`);
|
|
|
|
|
+ if (cachedShopInfo) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const parsed = JSON.parse(cachedShopInfo);
|
|
|
|
|
+ setShopInfo(parsed);
|
|
|
|
|
+ console.log('[ShopRenter] Shop info loaded from cache:', parsed);
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ console.warn('[ShopRenter] Failed to parse cached shop info');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Always try to fetch fresh data from server
|
|
|
setLoadingShopInfo(true);
|
|
setLoadingShopInfo(true);
|
|
|
try {
|
|
try {
|
|
|
const infoResponse = await fetch(`${API_URL}/get-pending-install-info`, {
|
|
const infoResponse = await fetch(`${API_URL}/get-pending-install-info`, {
|
|
@@ -210,18 +223,25 @@ export default function IntegrationsRedirect() {
|
|
|
if (infoResponse.ok) {
|
|
if (infoResponse.ok) {
|
|
|
const shopInfoData = await infoResponse.json();
|
|
const shopInfoData = await infoResponse.json();
|
|
|
if (shopInfoData.success) {
|
|
if (shopInfoData.success) {
|
|
|
- setShopInfo({
|
|
|
|
|
|
|
+ const info = {
|
|
|
shop_email: shopInfoData.shop_email,
|
|
shop_email: shopInfoData.shop_email,
|
|
|
shop_owner_name: shopInfoData.shop_owner_name,
|
|
shop_owner_name: shopInfoData.shop_owner_name,
|
|
|
email_exists: shopInfoData.email_exists
|
|
email_exists: shopInfoData.email_exists
|
|
|
- });
|
|
|
|
|
|
|
+ };
|
|
|
|
|
+ setShopInfo(info);
|
|
|
|
|
+ // Cache in sessionStorage for page refreshes
|
|
|
|
|
+ sessionStorage.setItem(`shop_info_${srInstall}`, JSON.stringify(info));
|
|
|
console.log('[ShopRenter] Shop info fetched:', shopInfoData);
|
|
console.log('[ShopRenter] Shop info fetched:', shopInfoData);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- console.warn('[ShopRenter] Failed to fetch shop info');
|
|
|
|
|
|
|
+ // If server returns error but we have cached data, keep using it
|
|
|
|
|
+ if (!cachedShopInfo) {
|
|
|
|
|
+ console.warn('[ShopRenter] Failed to fetch shop info and no cache available');
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
} catch (infoErr) {
|
|
} catch (infoErr) {
|
|
|
console.error('[ShopRenter] Error fetching shop info:', infoErr);
|
|
console.error('[ShopRenter] Error fetching shop info:', infoErr);
|
|
|
|
|
+ // Keep using cached data if available
|
|
|
} finally {
|
|
} finally {
|
|
|
setLoadingShopInfo(false);
|
|
setLoadingShopInfo(false);
|
|
|
}
|
|
}
|