Skip to content

Commit 27199cb

Browse files
committed
feat: clean up code
1 parent e473394 commit 27199cb

33 files changed

+1779
-310
lines changed

.cursorrules

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Code Style and Structure:
22
- Write concise, technical TypeScript code with accurate examples
33
- Use functional and declarative programming patterns; avoid classes
44
- Prefer iteration and modularization over code duplication
5-
- Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError)
5+
- Use descriptive variable names with auxiliary verbs (e.g., isPending, hasError)
66
- Structure files: exported component, subcomponents, helpers, static content, types
77

88
Naming Conventions:

apps/mobile/env.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export const SERVER_URL = "https://dorf-api-staging.abdelilah4dev.workers.dev";
2+
// export const SERVER_URL = import.meta.env.VITE_SERVER_URL;

apps/mobile/src/components/auth/AUTH_CODES.ts

-124
This file was deleted.

apps/mobile/src/components/auth/sign-in-form.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ import { useNavigate } from "@tanstack/react-router";
1515
import type React from "react";
1616
import { useForm } from "react-hook-form";
1717
import * as z from "zod";
18-
import { useSystemTray } from "../../context";
19-
import { authClient } from "../../lib/auth-client";
20-
import { type AuthError, AuthErrorCodes } from "./AUTH_CODES";
18+
import { useTauriApis } from "../../context";
19+
import {
20+
type AuthError,
21+
AuthErrorCodes,
22+
authClient,
23+
} from "../../lib/auth-client";
2124

2225
const signInSchema = z.object({
2326
email: z.string().email({ message: "Invalid email address" }),
@@ -30,7 +33,7 @@ type SignInSchema = z.infer<typeof signInSchema>;
3033

3134
const SignInForm: React.FC = () => {
3235
const { toast } = useToast();
33-
const { store } = useSystemTray();
36+
const { store } = useTauriApis();
3437

3538
const navigate = useNavigate({ from: "/auth/signin" });
3639

@@ -79,7 +82,6 @@ const SignInForm: React.FC = () => {
7982
return (
8083
<Form {...form}>
8184
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
82-
<h2 className="mb-6 font-semibold text-2xl">Sign In</h2>
8385
<FormField
8486
control={form.control}
8587
name="email"

apps/mobile/src/components/auth/sign-up-form.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ import { useNavigate } from "@tanstack/react-router";
1515
import type React from "react";
1616
import { useForm } from "react-hook-form";
1717
import * as z from "zod";
18-
import { useSystemTray } from "../../context";
19-
import { authClient } from "../../lib/auth-client";
20-
import { type AuthError, AuthErrorCodes } from "./AUTH_CODES";
18+
import { useTauriApis } from "../../context";
19+
import {
20+
type AuthError,
21+
AuthErrorCodes,
22+
authClient,
23+
} from "../../lib/auth-client";
2124

2225
const signUpSchema = z.object({
2326
name: z
@@ -33,7 +36,7 @@ type SignUpSchema = z.infer<typeof signUpSchema>;
3336

3437
const SignUpForm: React.FC = () => {
3538
const { toast } = useToast();
36-
const { store } = useSystemTray();
39+
const { store } = useTauriApis();
3740

3841
const form = useForm<SignUpSchema>({
3942
resolver: zodResolver(signUpSchema),
@@ -84,7 +87,6 @@ const SignUpForm: React.FC = () => {
8487
return (
8588
<Form {...form}>
8689
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
87-
<h2 className="mb-6 font-semibold text-2xl">Sign Up</h2>
8890
<FormField
8991
control={form.control}
9092
name="name"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { buttonVariants } from "@dorf/ui/button";
2+
import { Icons } from "@dorf/ui/icons";
3+
import { Link } from "@tanstack/react-router";
4+
5+
function BottomNavigation() {
6+
return (
7+
<div className="flex min-h-10 items-center justify-between px-8 py-1">
8+
<Link
9+
className={buttonVariants({
10+
size: "icon",
11+
variant: "ghost",
12+
})}
13+
to="/"
14+
>
15+
<Icons.Home />
16+
</Link>
17+
<Link
18+
className={buttonVariants({
19+
size: "icon",
20+
variant: "ghost",
21+
})}
22+
to="/homes" // Assuming your homes page route is "/homes"
23+
>
24+
<Icons.Homes />
25+
</Link>
26+
<Link
27+
className={buttonVariants({
28+
size: "icon",
29+
variant: "ghost",
30+
})}
31+
to="/readings"
32+
>
33+
<Icons.MeterReadings />
34+
</Link>
35+
<Link
36+
className={buttonVariants({
37+
size: "icon",
38+
variant: "ghost",
39+
})}
40+
to="/"
41+
>
42+
<Icons.Profile />
43+
</Link>
44+
<Link
45+
className={buttonVariants({
46+
size: "icon",
47+
variant: "ghost",
48+
})}
49+
to="/"
50+
>
51+
<Icons.Settings />
52+
</Link>
53+
</div>
54+
);
55+
}
56+
57+
export default BottomNavigation;

apps/mobile/src/components/error.tsx

+28-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
1+
import { buttonVariants } from "@dorf/ui/button";
12
import { Link } from "@tanstack/react-router";
23

34
export function DefaultErrorComponent({ error }: { error: Error }) {
45
return (
5-
<div className="flex w-full flex-col space-y-2">
6-
<div>{error.message}</div>
7-
<Link to="/">Go back home</Link>
6+
<div className="flex h-screen flex-col items-center justify-center">
7+
<div className="rounded-lg p-8 text-center">
8+
<h2 className="mb-4 font-bold text-3xl text-red-600">
9+
Oops! Something went wrong.
10+
</h2>
11+
<p className="mb-6 text-gray-700">
12+
We've encountered an unexpected issue. Please try again or contact
13+
support if the problem persists.
14+
</p>
15+
16+
{/* Optional: Show a more detailed message if available, but avoid revealing sensitive info */}
17+
{error.message && (
18+
<div className="mb-4 rounded border border-red-200 bg-red-100 p-2 text-red-500 ">
19+
<p className="font-medium">Error Details:</p>
20+
<p className="text-sm">{error.message}</p>
21+
</div>
22+
)}
23+
24+
<Link
25+
to="/"
26+
className={buttonVariants({
27+
variant: "link",
28+
})}
29+
>
30+
Go back home
31+
</Link>
32+
</div>
833
</div>
934
);
1035
}

0 commit comments

Comments
 (0)