veza/apps/web/src/components/admin/modals/BanUserModal.tsx
senke 8e9ee2f3a5 fix: stabilize builds, tests, and lint across all stacks
Complete stabilization pass bringing all 3 stacks to green:

Frontend (apps/web/):
- Fix TypeScript nullability in useSeason.ts, useTimeOfDay.ts hooks
- Disable no-undef in ESLint config (TypeScript handles it; JSX misidentified)
- Rename 306 story imports from @storybook/react to @storybook/react-vite
- Fix conditional hook call in useMediaQuery.ts useIsTablet
- Move useQuery to top of LoginPage.tsx component
- Remove useless try/catch in GearFormModal.tsx
- Fix stale closure in ResetPasswordPage.tsx handleChange
- Make Storybook decorators (withRouter, withQueryClient, withToast, withAudio)
  no-ops since global StorybookDecorator already provides these — prevents
  nested Router / duplicate provider crashes in vitest-browser
- Fix nested MemoryRouter in 3 page stories (TrackDetail, PlaylistDetail, UserProfile)
- Update i18n initialization in test setup (await init before changeLanguage)
- Update ~30 test assertions from English to French to match i18n translations
- Update test assertions to match SUMI V3 design changes (shadow vs border)
- Fix remaining story type errors (PlayerError, PlaylistBatchActions,
  TrackFilters, VirtualizedChatMessages)

Backend (veza-backend-api/):
- Fix response_test.go RespondWithAppError signature (2 args, not 3)
- Fix TestErrorContractAuthEndpoints expected error codes
  (ErrCodeUnauthorized vs ErrCodeInvalidCredentials)
- Fix TestTrackHandler_GetTrackLikes_Success missing auth middleware setup
- Fix TestPlaybackAnalyticsService_GetTrackStats k-anonymity threshold
  (needs 5 unique users, not 1)
- Replace NOW() PostgreSQL function with time.Now() parameter in marketplace
  service for SQLite test compatibility
- Add missing AutoMigrate entries in marketplace_test.go
  (ProductImage, ProductPreview, ProductLicense, ProductReview)

Results:
- Frontend TypeCheck: 617 errors -> 0 errors
- Frontend ESLint: 349 errors -> 0 errors
- Frontend Vitest: 196 failing tests -> 1 skipped (3396/3397 passing)
- Backend go vet: 1 error -> 0 errors
- Backend tests: 5 failing -> all 13 packages passing
- Rust: 150/150 tests passing (unchanged)
- Storybook audit: 0 errors across 1244 stories

Triage report: docs/TRIAGE_REPORT.md

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 16:48:07 +02:00

143 lines
5.6 KiB
TypeScript

import React, { useState } from 'react';
import { Button } from '../../ui/button';
import { X, Calendar, ShieldBan } from 'lucide-react';
interface BanUserModalProps {
username: string;
onClose: () => void;
onConfirm: (reason: string, details: string, duration: string) => void;
}
export const BanUserModal: React.FC<BanUserModalProps> = ({
username,
onClose,
onConfirm,
}) => {
const [reason, setReason] = useState('Terms of Service Violation');
const [details, setDetails] = useState('');
const [isPermanent, setIsPermanent] = useState(false);
const [duration, setDuration] = useState('7'); // days
return (
<div className="fixed inset-0 z-[var(--sumi-z-modal)] flex items-center justify-center p-4">
<div
className="absolute inset-0 bg-background/90 backdrop-blur-sm"
onClick={onClose}
></div>
<div className="relative w-full max-w-md bg-muted rounded-xl shadow-2xl animate-scaleIn overflow-hidden">
<div className="p-4 border-b border-destructive/30 bg-destructive/10 flex justify-between items-center">
<h3 className="font-bold text-destructive flex items-center gap-2">
<ShieldBan className="w-5 h-5 fill-current" /> Suspend User
</h3>
<button onClick={onClose}>
<X className="w-5 h-5 text-muted-foreground hover:text-foreground" />
</button>
</div>
<div className="p-6 space-y-4">
<p className="text-foreground text-sm">
You are about to suspend{' '}
<span className="font-bold text-foreground">{username}</span>. This will
restrict their access to the platform.
</p>
<div>
<label className="block text-xs font-bold text-muted-foreground uppercase mb-2">
Reason
</label>
<select
className="w-full bg-background border border-border rounded p-2 text-foreground focus:border-destructive outline-none focus-visible:ring-2 focus-visible:ring-ring text-sm"
value={reason}
onChange={(e) => setReason(e.target.value)}
>
<option>Terms of Service Violation</option>
<option>Spam or Bot Activity</option>
<option>Harassment / Hate Speech</option>
<option>Copyright Infringement</option>
<option>Fraudulent Activity</option>
<option>Other</option>
</select>
</div>
<div>
<label className="block text-xs font-bold text-muted-foreground uppercase mb-2">
Details (Internal Note)
</label>
<textarea
className="w-full bg-background border border-border rounded p-2 text-foreground focus:border-destructive outline-none focus-visible:ring-2 focus-visible:ring-ring text-sm resize-none h-24"
placeholder="Provide context for this ban..."
value={details}
onChange={(e) => setDetails(e.target.value)}
/>
</div>
<div className="flex items-center justify-between p-4 bg-card rounded shadow-[0_0_8px_rgba(26,26,30,0.05)]">
<div className="flex items-center gap-4">
<Calendar className="w-5 h-5 text-muted-foreground" />
<div>
<div className="text-sm font-bold text-foreground">Ban Duration</div>
<div className="text-xs text-muted-foreground">
{isPermanent ? 'Permanent Ban' : `${duration} Days`}
</div>
</div>
</div>
<div className="flex items-center gap-2">
<span
className={`text-xs ${!isPermanent ? 'text-foreground' : 'text-muted-foreground'}`}
>
Temp
</span>
<div
onClick={() => setIsPermanent(!isPermanent)}
className={`w-10 h-5 rounded-full relative cursor-pointer transition-colors ${isPermanent ? 'bg-destructive' : 'bg-muted'}`}
>
<div
className={`absolute top-1 w-3 h-3 bg-white rounded-full transition-all ${isPermanent ? 'left-6' : 'left-1'}`}
></div>
</div>
<span
className={`text-xs ${isPermanent ? 'text-destructive font-bold' : 'text-muted-foreground'}`}
>
Perm
</span>
</div>
</div>
{!isPermanent && (
<div>
<label className="block text-xs font-bold text-muted-foreground uppercase mb-2">
Days
</label>
<input
type="number"
min="1"
className="w-full bg-background border border-border rounded p-2 text-foreground focus:border-destructive outline-none focus-visible:ring-2 focus-visible:ring-ring text-sm"
value={duration}
onChange={(e) => setDuration(e.target.value)}
/>
</div>
)}
</div>
<div className="p-4 border-t border-border bg-card flex justify-end gap-4">
<Button variant="ghost" onClick={onClose}>
Cancel
</Button>
<Button
variant="primary"
className="bg-destructive hover:bg-destructive border-destructive text-foreground"
onClick={() =>
onConfirm(
reason,
details,
isPermanent ? 'Permanent' : `${duration} days`,
)
}
>
Suspend User
</Button>
</div>
</div>
</div>
);
};