mirror of
https://github.com/FranP-code/inbox-negotiator.git
synced 2025-10-13 00:42:26 +00:00
feat: enhance Navbar with user profile and configuration links
- Updated Navbar component to include a link to the configuration page. - Added a new Settings icon and link for user configuration. - Improved user session handling and UI updates based on authentication state. feat: implement OnboardingDialog for user setup - Created OnboardingDialog component to guide users through initial setup. - Added functionality to collect additional email addresses during onboarding. - Integrated toast notifications for error handling during email addition. feat: extend Supabase admin functions for user management - Added functions to retrieve user IDs and full user information by email. - Implemented error handling and logging for database operations. feat: update Supabase schema with new user features - Created new tables: user_profiles, additional_emails, and email_processing_usage. - Enabled Row Level Security (RLS) on new tables with appropriate policies. - Added triggers and functions for automatic user profile creation and email usage tracking. feat: create public users table for simplified access - Established a public.users table to mirror relevant auth.users data. - Implemented triggers to automatically populate public.users upon user creation. - Set up RLS policies to restrict access to user data. chore: add configuration files for Supabase local development - Included .gitignore and config.toml for local Supabase setup. - Configured email testing server and other development settings. feat: add configuration page for user settings - Created configuration.astro page to manage user settings. - Integrated AuthGuard to protect the configuration route.
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { supabase, type Debt } from "../lib/supabase";
|
||||
import { supabase, type Debt, type UserProfile } from "../lib/supabase";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DebtCard } from "./DebtCard";
|
||||
import { DebtTimeline } from "./DebtTimeline";
|
||||
import { OnboardingDialog } from "./OnboardingDialog";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
@@ -22,11 +23,14 @@ import {
|
||||
RefreshCw,
|
||||
BarChart3,
|
||||
LogOut,
|
||||
Settings,
|
||||
} from "lucide-react";
|
||||
|
||||
export function Dashboard() {
|
||||
const [debts, setDebts] = useState<Debt[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [userProfile, setUserProfile] = useState<UserProfile | null>(null);
|
||||
const [showOnboarding, setShowOnboarding] = useState(false);
|
||||
const [stats, setStats] = useState({
|
||||
totalDebts: 0,
|
||||
totalAmount: 0,
|
||||
@@ -35,6 +39,7 @@ export function Dashboard() {
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
fetchUserProfile();
|
||||
fetchDebts();
|
||||
setupRealtimeSubscription();
|
||||
}, []);
|
||||
@@ -43,11 +48,41 @@ export function Dashboard() {
|
||||
calculateStats();
|
||||
}, [debts]);
|
||||
|
||||
const fetchUserProfile = async () => {
|
||||
try {
|
||||
const {
|
||||
data: { user },
|
||||
} = await supabase.auth.getUser();
|
||||
if (!user) return;
|
||||
|
||||
const { data: profile } = await supabase
|
||||
.from("user_profiles")
|
||||
.select("*")
|
||||
.eq("user_id", user.id)
|
||||
.single();
|
||||
|
||||
setUserProfile(profile);
|
||||
|
||||
// Show onboarding if user hasn't completed it
|
||||
if (profile && !profile.onboarding_completed) {
|
||||
setShowOnboarding(true);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error fetching user profile:", error);
|
||||
}
|
||||
};
|
||||
|
||||
const fetchDebts = async () => {
|
||||
try {
|
||||
const {
|
||||
data: { user },
|
||||
} = await supabase.auth.getUser();
|
||||
if (!user) return;
|
||||
|
||||
const { data, error } = await supabase
|
||||
.from("debts")
|
||||
.select("*")
|
||||
.eq("user_id", user.id)
|
||||
.order("created_at", { ascending: false });
|
||||
|
||||
if (error) throw error;
|
||||
@@ -111,6 +146,12 @@ export function Dashboard() {
|
||||
});
|
||||
};
|
||||
|
||||
const handleOnboardingComplete = () => {
|
||||
setShowOnboarding(false);
|
||||
// Refresh user profile to reflect onboarding completion
|
||||
fetchUserProfile();
|
||||
};
|
||||
|
||||
const handleSignOut = async () => {
|
||||
await supabase.auth.signOut();
|
||||
window.location.href = "/";
|
||||
@@ -152,13 +193,18 @@ export function Dashboard() {
|
||||
<div className="mb-8 flex justify-between items-start">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold text-gray-900 dark:text-foreground flex items-center gap-3">
|
||||
<BarChart3 className="h-8 w-8 text-primary" />
|
||||
InboxNegotiator Dashboard
|
||||
Dashboard
|
||||
</h1>
|
||||
<p className="text-gray-600 dark:text-gray-300 mt-2">
|
||||
AI-powered debt resolution platform with real-time updates
|
||||
</p>
|
||||
</div>
|
||||
<Button asChild>
|
||||
<a href="/configuration" className="flex items-center gap-2">
|
||||
<Settings className="h-4 w-4" />
|
||||
Configuration
|
||||
</a>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* Stats Cards */}
|
||||
@@ -290,6 +336,12 @@ export function Dashboard() {
|
||||
<p className="mt-1">Real-time updates powered by Supabase</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Onboarding Dialog */}
|
||||
<OnboardingDialog
|
||||
open={showOnboarding}
|
||||
onComplete={handleOnboardingComplete}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user