Throttling configuration from the backoffice added

This commit is contained in:
Stephanos A
2026-06-26 12:17:01 +03:00
parent 84a14b7312
commit eefbe6e8ed
8 changed files with 152 additions and 21 deletions

View File

@@ -10,6 +10,9 @@ export default function SettingsPage() {
const [activeTab, setActiveTab] = useState<Tab>('general');
const [seatHoldMinutes, setSeatHoldMinutes] = useState('5');
const [holdCutoffHours, setHoldCutoffHours] = useState('2');
const [throttleAuthLimit, setThrottleAuthLimit] = useState('5');
const [throttleStrictLimit, setThrottleStrictLimit] = useState('20');
const [throttleDefaultLimit, setThrottleDefaultLimit] = useState('100');
const [configLoading, setConfigLoading] = useState(false);
const [configSaving, setConfigSaving] = useState(false);
const [configMessage, setConfigMessage] = useState('');
@@ -21,6 +24,9 @@ export default function SettingsPage() {
.then((data) => {
if (data?.seat_hold_duration_minutes) setSeatHoldMinutes(data.seat_hold_duration_minutes);
if (data?.hold_cutoff_hours_before_departure) setHoldCutoffHours(data.hold_cutoff_hours_before_departure);
if (data?.throttle_auth_limit) setThrottleAuthLimit(data.throttle_auth_limit);
if (data?.throttle_strict_limit) setThrottleStrictLimit(data.throttle_strict_limit);
if (data?.throttle_default_limit) setThrottleDefaultLimit(data.throttle_default_limit);
})
.catch(() => {})
.finally(() => setConfigLoading(false));
@@ -33,6 +39,9 @@ export default function SettingsPage() {
await systemConfigApi.update({
seat_hold_duration_minutes: seatHoldMinutes,
hold_cutoff_hours_before_departure: holdCutoffHours,
throttle_auth_limit: throttleAuthLimit,
throttle_strict_limit: throttleStrictLimit,
throttle_default_limit: throttleDefaultLimit,
});
setConfigMessage('Saved successfully.');
} catch {
@@ -177,6 +186,41 @@ export default function SettingsPage() {
{activeTab === 'configurations' && (
<div className="card space-y-6">
<h3 className="text-lg font-semibold text-foreground">Rate Limiting (requests / minute / IP)</h3>
{!configLoading && (
<div className="max-w-sm space-y-4">
<div className="space-y-2">
<label className="label" htmlFor="throttle-auth">Auth endpoints limit</label>
<input
id="throttle-auth"
type="number" min="1" className="input"
value={throttleAuthLimit}
onChange={(e) => setThrottleAuthLimit(e.target.value)}
/>
<p className="text-xs text-muted-foreground">Login, register, OTP. Default: 5.</p>
</div>
<div className="space-y-2">
<label className="label" htmlFor="throttle-strict">Strict endpoints limit</label>
<input
id="throttle-strict"
type="number" min="1" className="input"
value={throttleStrictLimit}
onChange={(e) => setThrottleStrictLimit(e.target.value)}
/>
<p className="text-xs text-muted-foreground">Sensitive operations. Default: 20.</p>
</div>
<div className="space-y-2">
<label className="label" htmlFor="throttle-default">Default endpoints limit</label>
<input
id="throttle-default"
type="number" min="1" className="input"
value={throttleDefaultLimit}
onChange={(e) => setThrottleDefaultLimit(e.target.value)}
/>
<p className="text-xs text-muted-foreground">All other endpoints including search. Default: 100.</p>
</div>
</div>
)}
<h3 className="text-lg font-semibold text-foreground">Seat Booking</h3>
{configLoading ? (
<p className="text-sm text-muted-foreground">Loading...</p>