Files
3x-ui/frontend/src/components/sponsor/SponsorSlot.tsx
T
MHSanaei 6f1dd0d757 feat(sponsors): drop the sidebar slot and simplify the Sponsors page
The sidebar no longer carries a sponsor card. The backend stops serving
the "sidebar" slot, so a sponsors.json entry that still lists it keeps
only its other slots and one listing nothing else is dropped. Its
rotation, three-sponsor cap and collapsed-rail logo rendering go with it.

The Sponsors page now lists only real sponsors: the "Your brand here"
card shows only as the empty state instead of sitting in the grid and
repeating the header's Become a sponsor button, and the Available
placements section and its slot-occupancy helper are removed. Cards are
larger, two per row on wide screens. Unused i18n keys are dropped from
every locale.
2026-10-13 23:32:56 +02:00

43 lines
1.1 KiB
TypeScript

import { useState } from 'react';
import { useSponsorsQuery } from '@/api/queries/useSponsorsQuery';
import {
dismissSponsor,
isSponsorDismissed,
sponsorsForSlot,
type SponsorSlot as Slot,
} from '@/lib/sponsors';
import SponsorCard, { type SponsorCardVariant } from './SponsorCard';
interface SponsorSlotProps {
slot: Slot;
variant?: SponsorCardVariant;
className?: string;
}
export default function SponsorSlot({ slot, variant = 'banner', className }: SponsorSlotProps) {
const { data } = useSponsorsQuery();
const [, setDismissTick] = useState(0);
// Re-filtered each render so a close (dismissTick bump) re-reads localStorage.
const visible = sponsorsForSlot(data.sponsors, slot).filter(
(s) => !isSponsorDismissed(s.id, slot),
);
if (visible.length === 0) return null;
const sponsor = visible[0];
return (
<div className={className}>
<SponsorCard
sponsor={sponsor}
variant={variant}
onClose={() => {
dismissSponsor(sponsor.id, slot);
setDismissTick((n) => n + 1);
}}
/>
</div>
);
}