larxius commited on
Commit
780c139
·
verified ·
1 Parent(s): 38075fc

Update frontend/src/pages/Settings.jsx

Browse files
Files changed (1) hide show
  1. frontend/src/pages/Settings.jsx +11 -10
frontend/src/pages/Settings.jsx CHANGED
@@ -638,10 +638,11 @@ export const AlertSettingsPage = () => {
638
  if (isBillingAllowed) tabItems.push({ id: 'billing', label: 'Billing', icon: 'credit_card' });
639
 
640
  useEffect(() => {
641
- if (tabItems.length > 0 && !tabItems.some(t => t.id === activeTab)) {
642
- setActiveTab(tabItems[0].id);
 
643
  }
644
- }, [user?.role, activeTab, tabItems.length]);
645
 
646
  return (
647
  <div className="flex flex-col gap-gutter text-left w-full">
@@ -680,7 +681,7 @@ export const AlertSettingsPage = () => {
680
 
681
  {/* Tab Switch Contents */}
682
 
683
- {activeTab === 'scheduler' && (
684
  <div className="max-w-3xl mx-auto w-full">
685
  <div className="bg-surface-container-lowest border border-outline-variant rounded-lg p-lg shadow-sm mb-lg">
686
  <h2 className="font-headline-md text-headline-md font-bold mb-md flex items-center gap-sm border-b pb-sm">
@@ -775,7 +776,7 @@ export const AlertSettingsPage = () => {
775
  </div>
776
  )}
777
 
778
- {activeTab === 'demoBookings' && (
779
  <div className="max-w-3xl mx-auto w-full">
780
  <div className="bg-surface-container-lowest border border-outline-variant rounded-lg p-lg shadow-sm mb-lg">
781
  <h2 className="font-headline-md text-headline-md font-bold mb-md flex items-center gap-sm border-b pb-sm">
@@ -872,7 +873,7 @@ export const AlertSettingsPage = () => {
872
  )}
873
 
874
  {/* 2. Notifications Tab (History) */}
875
- {activeTab === 'notifications' && (
876
  <div className="max-w-3xl mx-auto w-full">
877
  {/* Notification History Panel */}
878
  <div className="bg-surface-container-lowest border border-outline-variant rounded-lg p-lg shadow-sm flex flex-col max-h-[700px]">
@@ -912,7 +913,7 @@ export const AlertSettingsPage = () => {
912
  )}
913
 
914
  {/* 3. Billing Tab */}
915
- {activeTab === 'billing' && (
916
  <div className="max-w-3xl mx-auto w-full flex flex-col gap-gutter">
917
 
918
  {/* Subscription & Billing */}
@@ -1056,12 +1057,12 @@ export const AlertSettingsPage = () => {
1056
 
1057
 
1058
  {/* Profile Tab */}
1059
- {activeTab === 'profile' && (
1060
  <Profile />
1061
  )}
1062
 
1063
  {/* Team Tab */}
1064
- {activeTab === 'team' && (
1065
  <div className="w-full flex flex-col gap-lg">
1066
  <div className="bg-surface-container-lowest border border-outline-variant rounded-xl overflow-hidden shadow-sm">
1067
  <div className="p-6 border-b border-outline-variant flex justify-between items-center bg-surface-container/50">
@@ -1397,7 +1398,7 @@ export const AlertSettingsPage = () => {
1397
  )}
1398
 
1399
  {/* API Keys Tab (Placeholder) */}
1400
- {activeTab === 'apiKeys' && (
1401
  <div className="w-full">
1402
  <div className="bg-surface-container-lowest border border-outline-variant rounded-lg shadow-sm mb-lg overflow-hidden relative min-h-[400px] flex items-center justify-center">
1403
 
 
638
  if (isBillingAllowed) tabItems.push({ id: 'billing', label: 'Billing', icon: 'credit_card' });
639
 
640
  useEffect(() => {
641
+ const isAllowed = tabItems.some(t => t.id === activeTab);
642
+ if (!isAllowed) {
643
+ setActiveTab('profile');
644
  }
645
+ }, [user?.role, activeTab]);
646
 
647
  return (
648
  <div className="flex flex-col gap-gutter text-left w-full">
 
681
 
682
  {/* Tab Switch Contents */}
683
 
684
+ {activeTab === 'scheduler' && isSchedulerAllowed && (
685
  <div className="max-w-3xl mx-auto w-full">
686
  <div className="bg-surface-container-lowest border border-outline-variant rounded-lg p-lg shadow-sm mb-lg">
687
  <h2 className="font-headline-md text-headline-md font-bold mb-md flex items-center gap-sm border-b pb-sm">
 
776
  </div>
777
  )}
778
 
779
+ {activeTab === 'demoBookings' && isDemoBookingsAllowed && (
780
  <div className="max-w-3xl mx-auto w-full">
781
  <div className="bg-surface-container-lowest border border-outline-variant rounded-lg p-lg shadow-sm mb-lg">
782
  <h2 className="font-headline-md text-headline-md font-bold mb-md flex items-center gap-sm border-b pb-sm">
 
873
  )}
874
 
875
  {/* 2. Notifications Tab (History) */}
876
+ {activeTab === 'notifications' && isNotificationsAllowed && (
877
  <div className="max-w-3xl mx-auto w-full">
878
  {/* Notification History Panel */}
879
  <div className="bg-surface-container-lowest border border-outline-variant rounded-lg p-lg shadow-sm flex flex-col max-h-[700px]">
 
913
  )}
914
 
915
  {/* 3. Billing Tab */}
916
+ {activeTab === 'billing' && isBillingAllowed && (
917
  <div className="max-w-3xl mx-auto w-full flex flex-col gap-gutter">
918
 
919
  {/* Subscription & Billing */}
 
1057
 
1058
 
1059
  {/* Profile Tab */}
1060
+ {(activeTab === 'profile' || !tabItems.some(t => t.id === activeTab)) && (
1061
  <Profile />
1062
  )}
1063
 
1064
  {/* Team Tab */}
1065
+ {activeTab === 'team' && isTeamAllowed && (
1066
  <div className="w-full flex flex-col gap-lg">
1067
  <div className="bg-surface-container-lowest border border-outline-variant rounded-xl overflow-hidden shadow-sm">
1068
  <div className="p-6 border-b border-outline-variant flex justify-between items-center bg-surface-container/50">
 
1398
  )}
1399
 
1400
  {/* API Keys Tab (Placeholder) */}
1401
+ {activeTab === 'apiKeys' && isApiKeysAllowed && (
1402
  <div className="w-full">
1403
  <div className="bg-surface-container-lowest border border-outline-variant rounded-lg shadow-sm mb-lg overflow-hidden relative min-h-[400px] flex items-center justify-center">
1404