Normalize to double quotes across all files with Prettier
This commit is contained in:
1 parent
73bff72cec
commit
a5659cf4c8
190 files changed
+9523
-8859
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { useMemo } from 'react';
|
||||
import { useMemo } from "react";
|
||||
import {
|
||||
BarChart,
|
||||
Bar,
|
||||
@@ -8,30 +8,37 @@ import {
|
||||
Tooltip,
|
||||
Cell,
|
||||
ResponsiveContainer,
|
||||
} from 'recharts';
|
||||
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/components/ui/card';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { useWatchdayDistribution } from '@/hooks/useStatistics';
|
||||
import type { WatchdayItem } from '@/api/statistics';
|
||||
} from "recharts";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
CardDescription,
|
||||
} from "@/components/ui/card";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { useWatchdayDistribution } from "@/hooks/useStatistics";
|
||||
import type { WatchdayItem } from "@/api/statistics";
|
||||
|
||||
// DAYOFWEEK: MySQL returns 1=Sun, 2=Mon, 3=Tue, 4=Wed, 5=Thu, 6=Fri, 7=Sat
|
||||
// We display Mon–Sun
|
||||
const DAY_ORDER = [2, 3, 4, 5, 6, 7, 1];
|
||||
const DAY_LABELS: Record<number, string> = {
|
||||
1: 'Sun',
|
||||
2: 'Mon',
|
||||
3: 'Tue',
|
||||
4: 'Wed',
|
||||
5: 'Thu',
|
||||
6: 'Fri',
|
||||
7: 'Sat',
|
||||
1: "Sun",
|
||||
2: "Mon",
|
||||
3: "Tue",
|
||||
4: "Wed",
|
||||
5: "Thu",
|
||||
6: "Fri",
|
||||
7: "Sat",
|
||||
};
|
||||
|
||||
function buildChartData(episodes: WatchdayItem[], movies: WatchdayItem[]) {
|
||||
return DAY_ORDER.map((dayNum) => {
|
||||
const ep = episodes.find((x) => Number(x.day) === dayNum);
|
||||
const mv = movies.find((x) => Number(x.day) === dayNum);
|
||||
const total = (ep ? parseInt(ep.count, 10) : 0) + (mv ? parseInt(mv.count, 10) : 0);
|
||||
const total =
|
||||
(ep ? parseInt(ep.count, 10) : 0) + (mv ? parseInt(mv.count, 10) : 0);
|
||||
return { day: DAY_LABELS[dayNum], total, dayNum };
|
||||
});
|
||||
}
|
||||
@@ -47,16 +54,18 @@ function CustomTooltip({ active, payload }: CustomTooltipProps) {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: 'var(--color-card)',
|
||||
border: '1px solid var(--color-border)',
|
||||
borderRadius: '8px',
|
||||
padding: '8px 12px',
|
||||
fontSize: '13px',
|
||||
color: 'var(--color-card-foreground)',
|
||||
backgroundColor: "var(--color-card)",
|
||||
border: "1px solid var(--color-border)",
|
||||
borderRadius: "8px",
|
||||
padding: "8px 12px",
|
||||
fontSize: "13px",
|
||||
color: "var(--color-card-foreground)",
|
||||
}}
|
||||
>
|
||||
<p style={{ fontWeight: 600 }}>{day}</p>
|
||||
<p style={{ color: 'var(--color-muted-foreground)' }}>{total} {total === 1 ? 'watch' : 'watches'}</p>
|
||||
<p style={{ color: "var(--color-muted-foreground)" }}>
|
||||
{total} {total === 1 ? "watch" : "watches"}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -71,7 +80,10 @@ export function CouchDayChart() {
|
||||
|
||||
const peakDay = useMemo(() => {
|
||||
if (!chartData.length) return null;
|
||||
return chartData.reduce((max, d) => (d.total > max.total ? d : max), chartData[0]);
|
||||
return chartData.reduce(
|
||||
(max, d) => (d.total > max.total ? d : max),
|
||||
chartData[0],
|
||||
);
|
||||
}, [chartData]);
|
||||
|
||||
const maxTotal = Math.max(...chartData.map((d) => d.total), 1);
|
||||
@@ -96,29 +108,39 @@ export function CouchDayChart() {
|
||||
<Skeleton className="h-52 w-full" />
|
||||
) : (
|
||||
<ResponsiveContainer width="100%" height={210}>
|
||||
<BarChart data={chartData} margin={{ top: 4, right: 8, left: -20, bottom: 0 }}>
|
||||
<CartesianGrid strokeDasharray="3 3" stroke="var(--color-border)" vertical={false} />
|
||||
<BarChart
|
||||
data={chartData}
|
||||
margin={{ top: 4, right: 8, left: -20, bottom: 0 }}
|
||||
>
|
||||
<CartesianGrid
|
||||
strokeDasharray="3 3"
|
||||
stroke="var(--color-border)"
|
||||
vertical={false}
|
||||
/>
|
||||
<XAxis
|
||||
dataKey="day"
|
||||
tick={{ fontSize: 12, fill: 'var(--color-muted-foreground)' }}
|
||||
tick={{ fontSize: 12, fill: "var(--color-muted-foreground)" }}
|
||||
axisLine={false}
|
||||
tickLine={false}
|
||||
/>
|
||||
<YAxis
|
||||
allowDecimals={false}
|
||||
tick={{ fontSize: 12, fill: 'var(--color-muted-foreground)' }}
|
||||
tick={{ fontSize: 12, fill: "var(--color-muted-foreground)" }}
|
||||
axisLine={false}
|
||||
tickLine={false}
|
||||
/>
|
||||
<Tooltip content={<CustomTooltip />} cursor={{ fill: 'var(--color-accent)' }} />
|
||||
<Tooltip
|
||||
content={<CustomTooltip />}
|
||||
cursor={{ fill: "var(--color-accent)" }}
|
||||
/>
|
||||
<Bar dataKey="total" radius={[4, 4, 0, 0]}>
|
||||
{chartData.map((entry) => (
|
||||
<Cell
|
||||
key={entry.day}
|
||||
fill={
|
||||
entry.total === maxTotal && entry.total > 0
|
||||
? 'var(--color-chart-4)'
|
||||
: 'var(--color-chart-1)'
|
||||
? "var(--color-chart-4)"
|
||||
: "var(--color-chart-1)"
|
||||
}
|
||||
opacity={entry.total === 0 ? 0.3 : 1}
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user