-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathSettingsLoader.tsx
More file actions
110 lines (105 loc) · 4.55 KB
/
Copy pathSettingsLoader.tsx
File metadata and controls
110 lines (105 loc) · 4.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import { useParams } from 'react-router-dom';
import { StandingsSettings } from './sections/StandingsSettings';
import { RelativeSettings } from './sections/RelativeSettings';
import { WeatherSettings } from './sections/WeatherSettings';
import { WindSettings } from './sections/WindSettings';
import { TrackMapSettings } from './sections/TrackMapSettings';
import { FlatTrackMapSettings } from './sections/FlatTrackMapSettings';
import { AdvancedSettings } from './sections/AdvancedSettings';
import { InputSettings } from './sections/InputSettings';
import { TachometerSettings } from './sections/TachometerSettings';
import { AboutSettings } from './sections/AboutSettings';
import { FasterCarsFromBehindSettings } from './sections/FasterCarsFromBehindSettings';
import { FuelSettings } from './sections/FuelSettings';
import { RejoinIndicatorSettings } from './sections/RejoinIndicatorSettings';
import { PitlaneHelperSettings } from './sections/PitlaneHelperSettings';
import { GeneralSettings } from './sections/GeneralSettings';
import { BlindSpotMonitorSettings } from './sections/BlindSpotMonitorSettings';
import { GarageCoverSettings } from './sections/GarageCoverSettings';
import { ProfileSettings } from './sections/ProfileSettings';
import { FlagSettings } from './sections/FlagSettings';
import { CarSetupSettings } from './sections/CarSetupSettings';
import { TwitchChatSettings } from './sections/TwitchChatSettings';
import { DriverTagsSettings } from './sections/DriverTagsSettings';
import { KeybindingsSettings } from './sections/KeybindingsSettings';
import { LapTimeLogSettings } from './sections/LapTimeLogSettings';
import { InformationBarSettings } from './sections/InformationBarSettings';
import { useDashboard } from '@irdashies/context';
import { SlowCarAheadSettings } from './sections/SlowCarAheadSettings';
import { SectorDeltaSettings } from './sections/SectorDeltaSettings';
import { HeartRateSettings } from './sections/HeartRateSettings';
import { CornerNameSettings } from './sections/CornerNameSettings';
import { BattleSettings } from './sections/BattleSettings';
interface SettingsLoaderProps {
previewMode?: boolean;
}
export const SettingsLoader = ({ previewMode }: SettingsLoaderProps = {}) => {
const { widgetId } = useParams<{ widgetId: string }>();
const { currentDashboard } = useDashboard();
// 1. Handle non-widget pages
if (widgetId === 'general')
return <GeneralSettings previewMode={previewMode} />;
if (widgetId === 'profiles') return <ProfileSettings />;
if (widgetId === 'advanced') return <AdvancedSettings />;
if (widgetId === 'car-setup') return <CarSetupSettings />;
if (widgetId === 'about') return <AboutSettings />;
if (widgetId === 'driver-tags') return <DriverTagsSettings />;
if (widgetId === 'keybindings') return <KeybindingsSettings />;
// 2. Find specific widget instance (may be undefined if widgetId is a type name)
const widget = currentDashboard?.widgets.find((w) => w.id === widgetId);
const type = widget ? widget.type || widget.id : widgetId;
switch (type) {
case 'standings':
return <StandingsSettings />;
case 'relative':
return <RelativeSettings />;
case 'weather':
return <WeatherSettings />;
case 'wind':
return <WindSettings />;
case 'fuel':
return <FuelSettings widgetId={widget?.id} />;
case 'map':
return <TrackMapSettings />;
case 'flatmap':
return <FlatTrackMapSettings />;
case 'input':
return <InputSettings />;
case 'tachometer':
return <TachometerSettings />;
case 'pitlanehelper':
return <PitlaneHelperSettings />;
case 'rejoin':
return <RejoinIndicatorSettings />;
case 'fastercarsfrombehind':
return <FasterCarsFromBehindSettings />;
case 'blindspotmonitor':
return <BlindSpotMonitorSettings />;
case 'garagecover':
return <GarageCoverSettings />;
case 'flag':
return <FlagSettings />;
case 'twitchchat':
return <TwitchChatSettings />;
case 'laptimelog':
return <LapTimeLogSettings />;
case 'infobar':
return <InformationBarSettings />;
case 'slowcarahead':
return <SlowCarAheadSettings />;
case 'sectordelta':
return <SectorDeltaSettings />;
case 'heartrate':
return <HeartRateSettings />;
case 'cornername':
return <CornerNameSettings />;
case 'battle':
return <BattleSettings />;
default:
return widget ? (
<div className="text-red-400">No settings available for {type}</div>
) : (
<div className="text-slate-400">Select a widget to edit</div>
);
}
};