|
@@ -2,15 +2,36 @@ import { useState, useEffect } from "react";
|
|
|
import { Button } from "@/components/ui/button";
|
|
import { Button } from "@/components/ui/button";
|
|
|
import { Input } from "@/components/ui/input";
|
|
import { Input } from "@/components/ui/input";
|
|
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
|
|
-import { Mail, Lock, Loader2, AlertCircle, CheckCircle, User, Building } from "lucide-react";
|
|
|
|
|
|
|
+import { Mail, Lock, Loader2, AlertCircle, CheckCircle, User as UserIcon, Building } from "lucide-react";
|
|
|
import { supabase } from "@/lib/supabase";
|
|
import { supabase } from "@/lib/supabase";
|
|
|
import { useTranslation } from "react-i18next";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
|
+interface User {
|
|
|
|
|
+ id: string;
|
|
|
|
|
+ email?: string;
|
|
|
|
|
+ user_metadata?: {
|
|
|
|
|
+ full_name?: string;
|
|
|
|
|
+ company_name?: string;
|
|
|
|
|
+ [key: string]: unknown;
|
|
|
|
|
+ };
|
|
|
|
|
+ [key: string]: unknown;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+interface Profile {
|
|
|
|
|
+ id: string;
|
|
|
|
|
+ full_name: string | null;
|
|
|
|
|
+ username: string | null;
|
|
|
|
|
+ email: string | null;
|
|
|
|
|
+ company_name: string | null;
|
|
|
|
|
+ is_verified: boolean | null;
|
|
|
|
|
+ created_at: string;
|
|
|
|
|
+ updated_at: string;
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
const Settings = () => {
|
|
const Settings = () => {
|
|
|
const { t } = useTranslation();
|
|
const { t } = useTranslation();
|
|
|
const [isLoading, setIsLoading] = useState(false);
|
|
const [isLoading, setIsLoading] = useState(false);
|
|
|
- const [user, setUser] = useState<any>(null);
|
|
|
|
|
- const [profile, setProfile] = useState<any>(null);
|
|
|
|
|
|
|
+ const [user, setUser] = useState<User | null>(null);
|
|
|
|
|
+ const [profile, setProfile] = useState<Profile | null>(null);
|
|
|
|
|
|
|
|
// Form states
|
|
// Form states
|
|
|
const [fullName, setFullName] = useState("");
|
|
const [fullName, setFullName] = useState("");
|
|
@@ -93,9 +114,9 @@ const Settings = () => {
|
|
|
|
|
|
|
|
setSuccessMessage(t('settings.profileUpdated') || "Profile updated successfully!");
|
|
setSuccessMessage(t('settings.profileUpdated') || "Profile updated successfully!");
|
|
|
await loadUserData();
|
|
await loadUserData();
|
|
|
- } catch (error: any) {
|
|
|
|
|
|
|
+ } catch (error: unknown) {
|
|
|
console.error("Error updating profile:", error);
|
|
console.error("Error updating profile:", error);
|
|
|
- setErrorMessage(error.message || "Failed to update profile");
|
|
|
|
|
|
|
+ setErrorMessage((error as Error)?.message || "Failed to update profile");
|
|
|
} finally {
|
|
} finally {
|
|
|
setIsLoading(false);
|
|
setIsLoading(false);
|
|
|
}
|
|
}
|
|
@@ -123,9 +144,9 @@ const Settings = () => {
|
|
|
"Confirmation email sent! Please check both your old and new email addresses to confirm the change."
|
|
"Confirmation email sent! Please check both your old and new email addresses to confirm the change."
|
|
|
);
|
|
);
|
|
|
setNewEmail("");
|
|
setNewEmail("");
|
|
|
- } catch (error: any) {
|
|
|
|
|
|
|
+ } catch (error: unknown) {
|
|
|
console.error("Error updating email:", error);
|
|
console.error("Error updating email:", error);
|
|
|
- setErrorMessage(error.message || "Failed to update email");
|
|
|
|
|
|
|
+ setErrorMessage((error as Error)?.message || "Failed to update email");
|
|
|
} finally {
|
|
} finally {
|
|
|
setIsLoading(false);
|
|
setIsLoading(false);
|
|
|
}
|
|
}
|
|
@@ -157,9 +178,9 @@ const Settings = () => {
|
|
|
setCurrentPassword("");
|
|
setCurrentPassword("");
|
|
|
setNewPassword("");
|
|
setNewPassword("");
|
|
|
setConfirmPassword("");
|
|
setConfirmPassword("");
|
|
|
- } catch (error: any) {
|
|
|
|
|
|
|
+ } catch (error: unknown) {
|
|
|
console.error("Error updating password:", error);
|
|
console.error("Error updating password:", error);
|
|
|
- setErrorMessage(error.message || "Failed to update password");
|
|
|
|
|
|
|
+ setErrorMessage((error as Error)?.message || "Failed to update password");
|
|
|
} finally {
|
|
} finally {
|
|
|
setIsLoading(false);
|
|
setIsLoading(false);
|
|
|
}
|
|
}
|
|
@@ -200,7 +221,7 @@ const Settings = () => {
|
|
|
{t('settings.fullName') || 'Full Name'}
|
|
{t('settings.fullName') || 'Full Name'}
|
|
|
</label>
|
|
</label>
|
|
|
<div className="relative">
|
|
<div className="relative">
|
|
|
- <User className="absolute left-3 top-1/2 transform -translate-y-1/2 text-slate-400 w-4 h-4" />
|
|
|
|
|
|
|
+ <UserIcon className="absolute left-3 top-1/2 transform -translate-y-1/2 text-slate-400 w-4 h-4" />
|
|
|
<Input
|
|
<Input
|
|
|
type="text"
|
|
type="text"
|
|
|
placeholder="John Doe"
|
|
placeholder="John Doe"
|