Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix chart UI for Safari browser #115

Merged
merged 2 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/downmerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Downmerge Changes
on:
push:
branches:
- main

jobs:
Sync:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Downmerge main -> renovate-updates
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git checkout renovate-updates
git merge -m 'Merge branch 'main' into renovate-updates' main
git push origin renovate-updates
9 changes: 8 additions & 1 deletion src/app/contexts/user-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ import {
type IUserContext = {
user: User | undefined;
setUser: Dispatch<SetStateAction<User | undefined>>;
isAuthLoading: boolean;
};

const UserContext = createContext<IUserContext>({
user: undefined,
setUser: () => {},
isAuthLoading: true,
});

export const UserContextProvider = ({
Expand All @@ -28,14 +30,19 @@ export const UserContextProvider = ({
children: React.ReactNode;
}) => {
const [user, setUser] = useState<User>();
const [isAuthLoading, setIsAuthLoading] = useState(true);

useEffect(() => {
onAuthStateChange((user) => {
setUser(user ?? undefined);
setIsAuthLoading(false);
});
}, []);

const ctx = useMemo(() => ({ user, setUser }), [user, setUser]);
const ctx = useMemo(
() => ({ user, setUser, isAuthLoading }),
[user, isAuthLoading]
);

return <UserContext.Provider value={ctx}>{children}</UserContext.Provider>;
};
Expand Down
18 changes: 7 additions & 11 deletions src/app/dahsboard-graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ import {
CardHeader,
CardTitle,
} from '@/components/ui/card';
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
import SelectYear from '@/components/common/select-year';

const chartConfig: ChartConfig = {
Expand All @@ -38,7 +31,7 @@ const currentYear = now.getFullYear();
const DashboardGraph = () => {
const [selectedYear, setSelectedYear] = useState(currentYear);

const { data: annualSummary = [], isInitialLoading } =
const { data: annualSummary = [] } =
trpc.transaction.getAnnualSummary.useQuery({ year: selectedYear });

return (
Expand All @@ -53,15 +46,18 @@ const DashboardGraph = () => {
<SelectYear
selectedYear={selectedYear}
setSelectedYear={setSelectedYear}
isDisabled={isInitialLoading}
/>
</CardHeader>
<CardContent className="px-2 pt-4 sm:px-6 sm:pt-6">
<ChartContainer
config={chartConfig}
className="min-h-[460px] max-h-[460px] w-full"
className="aspect-auto h-[460px] w-full"
>
<BarChart accessibilityLayer data={annualSummary}>
<BarChart
accessibilityLayer
data={annualSummary}
margin={{ top: 24 }}
>
<CartesianGrid vertical={false} />
<XAxis
dataKey="month"
Expand Down
2 changes: 0 additions & 2 deletions src/app/dashboard-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ const DahsboardTable = () => {
<Select
value={selectedMonth.toString()}
onValueChange={(newMonth) => setSelectedMonth(Number(newMonth))}
disabled={isInitialLoading}
>
<SelectTrigger className="w-[160px]">
<SelectValue />
Expand All @@ -108,7 +107,6 @@ const DahsboardTable = () => {
<SelectYear
selectedYear={selectedYear}
setSelectedYear={setSelectedYear}
isDisabled={isInitialLoading}
/>
</div>
<div className="rounded-md border mt-4">
Expand Down
14 changes: 10 additions & 4 deletions src/components/common/auth-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@ type Props = Readonly<{
}>;

const AuthLayout = ({ children }: Props) => {
const { user } = useUser();
const { user, isAuthLoading } = useUser();

if (isAuthLoading) {
return (
<div className="pt-20">
<Loader2 className="animate-spin mx-auto h-12 w-12" />
</div>
);
}

return user ? (
children
) : (
<div className="pt-20">
<Loader2 className="animate-spin mx-auto h-12 w-12" />
</div>
<p className="mt-20 text-center">Sign in to continue</p>
);
};

Expand Down
4 changes: 1 addition & 3 deletions src/components/common/select-year.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
interface Props {
selectedYear: number;
setSelectedYear: (year: number) => void;
isDisabled: boolean;
}

const currentYear = new Date().getFullYear();
Expand All @@ -19,12 +18,11 @@ export const YEARS = Array.from(
(_, i) => currentYear - i
);

const SelectYear = ({ selectedYear, setSelectedYear, isDisabled }: Props) => {
const SelectYear = ({ selectedYear, setSelectedYear }: Props) => {
return (
<Select
value={selectedYear.toString()}
onValueChange={(newYear) => setSelectedYear(Number(newYear))}
disabled={isDisabled}
>
<SelectTrigger className="w-[140px]">
<SelectValue />
Expand Down
Loading