This commit is contained in:
gpt-engineer-app[bot]
2026-01-27 23:16:57 +00:00
parent 4afd8e2ef8
commit a3287359a7
+7 -17
View File
@@ -12,18 +12,15 @@ import Header from "@/components/Header";
import { LogOut, Save } from "lucide-react"; import { LogOut, Save } from "lucide-react";
const profileSchema = z.object({ const profileSchema = z.object({
company_name: z.string().trim().max(100, { message: "Företagsnamn får max vara 100 tecken" }).optional(),
address: z.string().trim().max(500, { message: "Adress får max vara 500 tecken" }).optional(), address: z.string().trim().max(500, { message: "Adress får max vara 500 tecken" }).optional(),
}); });
interface ProfileData { interface ProfileData {
company_name: string;
address: string; address: string;
} }
const Account = () => { const Account = () => {
const [profile, setProfile] = useState<ProfileData>({ const [profile, setProfile] = useState<ProfileData>({
company_name: "",
address: "", address: "",
}); });
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
@@ -47,7 +44,7 @@ const Account = () => {
try { try {
const { data, error } = await supabase const { data, error } = await supabase
.from("profiles") .from("profiles")
.select("company_name, address") .select("address")
.eq("user_id", user!.id) .eq("user_id", user!.id)
.maybeSingle(); .maybeSingle();
@@ -60,7 +57,6 @@ const Account = () => {
}); });
} else if (data) { } else if (data) {
setProfile({ setProfile({
company_name: data.company_name || "",
address: data.address || "", address: data.address || "",
}); });
} }
@@ -88,7 +84,6 @@ const Account = () => {
const { error } = await supabase const { error } = await supabase
.from("profiles") .from("profiles")
.update({ .update({
company_name: profile.company_name || null,
address: profile.address || null, address: profile.address || null,
}) })
.eq("user_id", user!.id); .eq("user_id", user!.id);
@@ -143,19 +138,14 @@ const Account = () => {
<form onSubmit={handleSubmit} className="space-y-5"> <form onSubmit={handleSubmit} className="space-y-5">
<div className="space-y-2"> <div className="space-y-2">
<Label htmlFor="company_name">Företagsnamn / E-post</Label> <Label htmlFor="email">E-post</Label>
<Input <Input
id="company_name" id="email"
type="text" type="email"
value={profile.company_name} value={user?.email || ""}
onChange={(e) => disabled
setProfile({ ...profile, company_name: e.target.value }) className="bg-muted"
}
placeholder="Ditt företag eller e-postadress"
/> />
<p className="text-xs text-muted-foreground">
Inloggad som: {user?.email}
</p>
</div> </div>
<div className="space-y-2"> <div className="space-y-2">