mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 06:11:13 -05:00
Refactor: Add button feedback
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { Shield, ArrowLeft, Settings, RefreshCw, Menu } from 'lucide-react';
|
import { Shield, ArrowLeft, Settings, Menu } from 'lucide-react';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { RefreshButton } from '@/components/ui/refresh-button';
|
||||||
import { Link, useLocation } from 'react-router-dom';
|
import { Link, useLocation } from 'react-router-dom';
|
||||||
import { ThemeToggle } from '@/components/theme/ThemeToggle';
|
import { ThemeToggle } from '@/components/theme/ThemeToggle';
|
||||||
import { AuthButtons } from '@/components/auth/AuthButtons';
|
import { AuthButtons } from '@/components/auth/AuthButtons';
|
||||||
@@ -15,7 +16,7 @@ import {
|
|||||||
SheetTrigger,
|
SheetTrigger,
|
||||||
} from '@/components/ui/sheet';
|
} from '@/components/ui/sheet';
|
||||||
|
|
||||||
export function AdminHeader({ onRefresh }: { onRefresh?: () => void }) {
|
export function AdminHeader({ onRefresh, isRefreshing }: { onRefresh?: () => void; isRefreshing?: boolean }) {
|
||||||
const { permissions } = useUserRole();
|
const { permissions } = useUserRole();
|
||||||
const { user } = useAuth();
|
const { user } = useAuth();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
@@ -68,14 +69,12 @@ export function AdminHeader({ onRefresh }: { onRefresh?: () => void }) {
|
|||||||
<span className="text-sm font-medium">Theme</span>
|
<span className="text-sm font-medium">Theme</span>
|
||||||
<ThemeToggle />
|
<ThemeToggle />
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<RefreshButton
|
||||||
|
onRefresh={onRefresh!}
|
||||||
|
isLoading={isRefreshing}
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
onClick={onRefresh}
|
className="justify-start w-full"
|
||||||
className="justify-start"
|
/>
|
||||||
>
|
|
||||||
<RefreshCw className="w-4 h-4 mr-2" />
|
|
||||||
Refresh
|
|
||||||
</Button>
|
|
||||||
{permissions?.role_level === 'superuser' && !isSettingsPage && (
|
{permissions?.role_level === 'superuser' && !isSettingsPage && (
|
||||||
<Button variant="ghost" asChild className="justify-start">
|
<Button variant="ghost" asChild className="justify-start">
|
||||||
<Link to="/admin/settings">
|
<Link to="/admin/settings">
|
||||||
@@ -89,16 +88,15 @@ export function AdminHeader({ onRefresh }: { onRefresh?: () => void }) {
|
|||||||
</Sheet>
|
</Sheet>
|
||||||
|
|
||||||
{/* Desktop Actions */}
|
{/* Desktop Actions */}
|
||||||
<Button
|
{onRefresh && (
|
||||||
variant="ghost"
|
<RefreshButton
|
||||||
size="sm"
|
onRefresh={onRefresh}
|
||||||
onClick={onRefresh}
|
isLoading={isRefreshing}
|
||||||
title="Refresh admin data"
|
variant="ghost"
|
||||||
className="hidden md:flex"
|
size="sm"
|
||||||
>
|
className="hidden md:flex"
|
||||||
<RefreshCw className="w-4 h-4" />
|
/>
|
||||||
<span className="hidden sm:ml-2 sm:inline">Refresh</span>
|
)}
|
||||||
</Button>
|
|
||||||
{permissions?.role_level === 'superuser' && !isSettingsPage && (
|
{permissions?.role_level === 'superuser' && !isSettingsPage && (
|
||||||
<Button variant="ghost" size="sm" asChild className="hidden md:flex">
|
<Button variant="ghost" size="sm" asChild className="hidden md:flex">
|
||||||
<Link to="/admin/settings">
|
<Link to="/admin/settings">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { RefreshCw } from 'lucide-react';
|
import { RefreshCw } from 'lucide-react';
|
||||||
import { Button } from '@/components/ui/button';
|
import { RefreshButton } from '@/components/ui/refresh-button';
|
||||||
import { ThemeToggle } from '@/components/theme/ThemeToggle';
|
import { ThemeToggle } from '@/components/theme/ThemeToggle';
|
||||||
import { AuthButtons } from '@/components/auth/AuthButtons';
|
import { AuthButtons } from '@/components/auth/AuthButtons';
|
||||||
import { NotificationCenter } from '@/components/notifications/NotificationCenter';
|
import { NotificationCenter } from '@/components/notifications/NotificationCenter';
|
||||||
@@ -50,16 +50,12 @@ export function AdminTopBar({
|
|||||||
{/* Right Section */}
|
{/* Right Section */}
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
{onRefresh && (
|
{onRefresh && (
|
||||||
<Button
|
<RefreshButton
|
||||||
|
onRefresh={onRefresh}
|
||||||
|
isLoading={isRefreshing}
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={onRefresh}
|
/>
|
||||||
disabled={isRefreshing}
|
|
||||||
title="Refresh data"
|
|
||||||
>
|
|
||||||
<RefreshCw className={`w-4 h-4 ${isRefreshing ? 'animate-spin' : ''}`} />
|
|
||||||
<span className="hidden sm:ml-2 sm:inline">Refresh</span>
|
|
||||||
</Button>
|
|
||||||
)}
|
)}
|
||||||
<ThemeToggle />
|
<ThemeToggle />
|
||||||
{user && <NotificationCenter />}
|
{user && <NotificationCenter />}
|
||||||
|
|||||||
@@ -166,8 +166,15 @@ export default function AdminSettings() {
|
|||||||
setLocalValue(updated);
|
setLocalValue(updated);
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveBanDurations = () => {
|
const [savingBanDurations, setSavingBanDurations] = useState(false);
|
||||||
updateSetting(setting.setting_key, banDurations);
|
|
||||||
|
const saveBanDurations = async () => {
|
||||||
|
setSavingBanDurations(true);
|
||||||
|
try {
|
||||||
|
await updateSetting(setting.setting_key, banDurations);
|
||||||
|
} finally {
|
||||||
|
setSavingBanDurations(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -239,7 +246,13 @@ export default function AdminSettings() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Button onClick={saveBanDurations} disabled={isUpdating} className="w-full">
|
<Button
|
||||||
|
onClick={saveBanDurations}
|
||||||
|
loading={savingBanDurations}
|
||||||
|
loadingText="Saving..."
|
||||||
|
className="w-full"
|
||||||
|
trackingLabel="save-ban-duration-settings"
|
||||||
|
>
|
||||||
<Save className="w-4 h-4 mr-2" />
|
<Save className="w-4 h-4 mr-2" />
|
||||||
Save Ban Duration Settings
|
Save Ban Duration Settings
|
||||||
</Button>
|
</Button>
|
||||||
@@ -431,7 +444,13 @@ export default function AdminSettings() {
|
|||||||
className="w-24"
|
className="w-24"
|
||||||
min="0"
|
min="0"
|
||||||
/>
|
/>
|
||||||
<Button onClick={handleSubmit} disabled={isUpdating} size="sm">
|
<Button
|
||||||
|
onClick={handleSubmit}
|
||||||
|
loading={isUpdating}
|
||||||
|
loadingText=""
|
||||||
|
size="sm"
|
||||||
|
trackingLabel="save-threshold-setting"
|
||||||
|
>
|
||||||
<Save className="w-4 h-4" />
|
<Save className="w-4 h-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -458,7 +477,13 @@ export default function AdminSettings() {
|
|||||||
}}
|
}}
|
||||||
className="flex-1"
|
className="flex-1"
|
||||||
/>
|
/>
|
||||||
<Button onClick={handleSubmit} disabled={isUpdating} size="sm">
|
<Button
|
||||||
|
onClick={handleSubmit}
|
||||||
|
loading={isUpdating}
|
||||||
|
loadingText=""
|
||||||
|
size="sm"
|
||||||
|
trackingLabel="save-setting"
|
||||||
|
>
|
||||||
<Save className="w-4 h-4" />
|
<Save className="w-4 h-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -275,15 +275,14 @@ export default function AuthCallback() {
|
|||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Button type="submit" className="w-full" disabled={settingPassword}>
|
<Button
|
||||||
{settingPassword ? (
|
type="submit"
|
||||||
<>
|
className="w-full"
|
||||||
<Loader2 className="w-4 h-4 mr-2 animate-spin" />
|
loading={settingPassword}
|
||||||
Setting Password...
|
loadingText="Setting Password..."
|
||||||
</>
|
trackingLabel="set-password-recovery"
|
||||||
) : (
|
>
|
||||||
'Set Password'
|
Set Password
|
||||||
)}
|
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|||||||
@@ -525,6 +525,8 @@ export default function Profile() {
|
|||||||
setFormErrors({});
|
setFormErrors({});
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
|
|
||||||
const handleSaveProfile = async () => {
|
const handleSaveProfile = async () => {
|
||||||
if (!profile || !currentUser) return;
|
if (!profile || !currentUser) return;
|
||||||
if (!validateForm()) return;
|
if (!validateForm()) return;
|
||||||
@@ -533,6 +535,8 @@ export default function Profile() {
|
|||||||
setShowUsernameDialog(true);
|
setShowUsernameDialog(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setIsSaving(true);
|
||||||
try {
|
try {
|
||||||
const updateData: any = {
|
const updateData: any = {
|
||||||
display_name: editForm.display_name,
|
display_name: editForm.display_name,
|
||||||
@@ -572,6 +576,8 @@ export default function Profile() {
|
|||||||
title: "Error updating profile",
|
title: "Error updating profile",
|
||||||
description: getErrorMessage(error)
|
description: getErrorMessage(error)
|
||||||
});
|
});
|
||||||
|
} finally {
|
||||||
|
setIsSaving(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const confirmUsernameChange = () => {
|
const confirmUsernameChange = () => {
|
||||||
@@ -730,7 +736,14 @@ export default function Profile() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Button onClick={handleSaveProfile} size="sm" disabled={usernameValidation.isChecking || editForm.username !== profile?.username && !usernameValidation.isValid}>
|
<Button
|
||||||
|
onClick={handleSaveProfile}
|
||||||
|
size="sm"
|
||||||
|
loading={isSaving}
|
||||||
|
loadingText="Saving..."
|
||||||
|
disabled={usernameValidation.isChecking || editForm.username !== profile?.username && !usernameValidation.isValid}
|
||||||
|
trackingLabel="save-profile-changes"
|
||||||
|
>
|
||||||
<Save className="w-4 h-4 mr-2" />
|
<Save className="w-4 h-4 mr-2" />
|
||||||
Save Changes
|
Save Changes
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -83,7 +83,12 @@ export default function ErrorLookup() {
|
|||||||
onKeyDown={(e) => e.key === 'Enter' && handleSearch()}
|
onKeyDown={(e) => e.key === 'Enter' && handleSearch()}
|
||||||
className="font-mono"
|
className="font-mono"
|
||||||
/>
|
/>
|
||||||
<Button onClick={handleSearch} disabled={loading}>
|
<Button
|
||||||
|
onClick={handleSearch}
|
||||||
|
loading={loading}
|
||||||
|
loadingText="Searching..."
|
||||||
|
trackingLabel="error-lookup-search"
|
||||||
|
>
|
||||||
<Search className="w-4 h-4 mr-2" />
|
<Search className="w-4 h-4 mr-2" />
|
||||||
Search
|
Search
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import { AdminLayout } from '@/components/layout/AdminLayout';
|
|||||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||||
import { Button } from '@/components/ui/button';
|
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
import { AlertCircle, RefreshCw } from 'lucide-react';
|
import { AlertCircle } from 'lucide-react';
|
||||||
|
import { RefreshButton } from '@/components/ui/refresh-button';
|
||||||
import { ErrorDetailsModal } from '@/components/admin/ErrorDetailsModal';
|
import { ErrorDetailsModal } from '@/components/admin/ErrorDetailsModal';
|
||||||
import { ErrorAnalytics } from '@/components/admin/ErrorAnalytics';
|
import { ErrorAnalytics } from '@/components/admin/ErrorAnalytics';
|
||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
@@ -33,7 +33,7 @@ export default function ErrorMonitoring() {
|
|||||||
const [dateRange, setDateRange] = useState<'1h' | '24h' | '7d' | '30d'>('24h');
|
const [dateRange, setDateRange] = useState<'1h' | '24h' | '7d' | '30d'>('24h');
|
||||||
|
|
||||||
// Fetch recent errors
|
// Fetch recent errors
|
||||||
const { data: errors, isLoading, refetch } = useQuery({
|
const { data: errors, isLoading, refetch, isFetching } = useQuery({
|
||||||
queryKey: ['admin-errors', dateRange, errorTypeFilter, searchTerm],
|
queryKey: ['admin-errors', dateRange, errorTypeFilter, searchTerm],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
let query = supabase
|
let query = supabase
|
||||||
@@ -88,10 +88,12 @@ export default function ErrorMonitoring() {
|
|||||||
<h1 className="text-3xl font-bold tracking-tight">Error Monitoring</h1>
|
<h1 className="text-3xl font-bold tracking-tight">Error Monitoring</h1>
|
||||||
<p className="text-muted-foreground">Track and analyze application errors</p>
|
<p className="text-muted-foreground">Track and analyze application errors</p>
|
||||||
</div>
|
</div>
|
||||||
<Button onClick={() => refetch()} variant="outline" size="sm">
|
<RefreshButton
|
||||||
<RefreshCw className="w-4 h-4 mr-2" />
|
onRefresh={async () => { await refetch(); }}
|
||||||
Refresh
|
isLoading={isFetching}
|
||||||
</Button>
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Analytics Section */}
|
{/* Analytics Section */}
|
||||||
|
|||||||
Reference in New Issue
Block a user