Minor tweaks to sign up on frontend and database structure

This commit is contained in:
Thastertyn committed 2025-03-17 19:27:09 +01:00
1 parent d0690f2f06
commit 260bef98cd
10 files changed
+56 -1037

No files matched your search

+1
View File
@@ -0,0 +1 @@
VITE_API_URL=
-984
View File
File diff suppressed because it is too large. Load diff
View File
Whitespace-only changes.
@@ -14,10 +14,9 @@ import {
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { PasswordInput } from "@/components/password-input";
import { registerUser } from "@/lib/api";
import { ApiError } from "@/errors/api-error";
import useAuth from "@/hooks/useAuth";
import { PhoneInput } from "@/components/ui/phone-number-input";
import { toast } from "@/hooks/useToast";
type SignUpFormProps = HTMLAttributes<HTMLDivElement>;
@@ -68,8 +67,6 @@ const formSchema = z
export function SignUpForm({ className, ...props }: SignUpFormProps) {
const { signUpMutation } = useAuth();
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const [successMessage, setSuccessMessage] = useState<string | null>(null);
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
@@ -84,17 +81,11 @@ export function SignUpForm({ className, ...props }: SignUpFormProps) {
async function onSubmit(data: z.infer<typeof formSchema>) {
setIsLoading(true);
setError(null);
setSuccessMessage(null);
try {
signUpMutation.mutate(data);
setSuccessMessage("Account created successfully!");
} catch (error: unknown) {
setError(error instanceof ApiError ? error.response : "Something went wrong.");
} finally {
setIsLoading(false);
}
signUpMutation.mutate(data);
toast({
title: "Successfully registered"
});
setIsLoading(false);
}
return (
@@ -167,10 +158,6 @@ export function SignUpForm({ className, ...props }: SignUpFormProps) {
</FormItem>
)}
/>
{error && <p className="text-red-500">{error}</p>}
{successMessage && (
<p className="text-green-500">{successMessage}</p>
)}
<Button className="mt-2" type="submit" disabled={isLoading}>
{isLoading ? "Creating Account..." : "Create Account"}
</Button>
-6
View File
@@ -12,11 +12,5 @@ export default defineConfig({
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
server: {
port: 31713
},
preview: {
port: 37173
}
})