ソースを参照

fix: sidebar menu text wrapping and 401 on hard refresh

- Shorten billingMenu translations (remove "& Plans/Csomagok/Tarife")
- Use Supabase SDK for session in ShopContext instead of localStorage
  - Fixes 401 errors on hard refresh when token needs refresh

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fszontagh 4 ヶ月 前
コミット
339a65c137

+ 6 - 4
shopcall.ai-main/src/components/context/ShopContext.tsx

@@ -1,5 +1,6 @@
 import React, { createContext, useContext, useState, useEffect, useCallback, ReactNode } from 'react';
 import { API_URL } from '@/lib/config';
+import { supabase } from '@/lib/supabase';
 
 interface StoreData {
   id: string;
@@ -38,17 +39,18 @@ export const ShopProvider: React.FC<{ children: ReactNode }> = ({ children }) =>
   // Fetch stores function - can be called from context or externally
   const fetchStores = async () => {
     try {
-      const sessionData = localStorage.getItem('session_data');
-      if (!sessionData) {
+      // Use Supabase SDK to get valid session (handles token refresh automatically)
+      const { data: { session }, error: sessionError } = await supabase.auth.getSession();
+
+      if (sessionError || !session) {
         // No session - mark as loaded with empty stores
         setStores([]);
         return;
       }
 
-      const session = JSON.parse(sessionData);
       const response = await fetch(`${API_URL}/api/stores`, {
         headers: {
-          'Authorization': `Bearer ${session.session.access_token}`,
+          'Authorization': `Bearer ${session.access_token}`,
         }
       });
 

+ 1 - 1
shopcall.ai-main/src/i18n/locales/de.json

@@ -240,7 +240,7 @@
     "min": "Min",
     "daysLeft": "Tage übrig",
     "billingSection": "Abrechnung",
-    "billingMenu": "Abrechnung & Tarife",
+    "billingMenu": "Abrechnung",
     "monthlyPlans": "Monatliche Tarife",
     "topups": "Aufladungen"
   },

+ 1 - 1
shopcall.ai-main/src/i18n/locales/en.json

@@ -240,7 +240,7 @@
     "min": "min",
     "daysLeft": "days left",
     "billingSection": "Billing",
-    "billingMenu": "Billing & Plans",
+    "billingMenu": "Billing",
     "monthlyPlans": "Monthly Plans",
     "topups": "Top-ups"
   },

+ 1 - 1
shopcall.ai-main/src/i18n/locales/hu.json

@@ -240,7 +240,7 @@
     "min": "perc",
     "daysLeft": "nap van hátra",
     "billingSection": "Számlázás",
-    "billingMenu": "Számlázás & Csomagok",
+    "billingMenu": "Számlázás",
     "monthlyPlans": "Havi Csomagok",
     "topups": "Feltöltések"
   },