From 53e87a5db70823dd5dfa4676fb240d6591a9d46d Mon Sep 17 00:00:00 2001 From: Harsh31105 Date: Fri, 5 Dec 2025 18:15:25 -0500 Subject: [PATCH 1/2] feat: Still debugging. --- backend/internal/auth/delete_account.go | 2 + frontend/src/app/profile/page.tsx | 10 +- frontend/src/app/therapistProfile/page.tsx | 160 --------------------- 3 files changed, 10 insertions(+), 162 deletions(-) delete mode 100644 frontend/src/app/therapistProfile/page.tsx diff --git a/backend/internal/auth/delete_account.go b/backend/internal/auth/delete_account.go index 7ce70075..e4d3c476 100644 --- a/backend/internal/auth/delete_account.go +++ b/backend/internal/auth/delete_account.go @@ -12,6 +12,8 @@ func SupabaseDeleteAccount(cfg *config.Supabase, userID string) error { supabaseURL := cfg.URL serviceRoleKey := cfg.ServiceRoleKey + fmt.Println(cfg.ServiceRoleKey) + req, err := http.NewRequest("DELETE", fmt.Sprintf("%s/auth/v1/admin/users/%s", supabaseURL, userID), nil) if err != nil { return errs.BadRequest(fmt.Sprintf("Failed to create request: %v", err)) diff --git a/frontend/src/app/profile/page.tsx b/frontend/src/app/profile/page.tsx index a3a48bba..50a319a4 100644 --- a/frontend/src/app/profile/page.tsx +++ b/frontend/src/app/profile/page.tsx @@ -10,13 +10,15 @@ import { validatePassword } from "@/lib/validatePassword"; import { Edit2, ExternalLink, Settings, X } from "lucide-react"; import { useRouter } from "next/navigation"; import React, { useState } from "react"; -import Image from "next/image"; +import Image from "next/image"; +import {useStudents} from "@/hooks/useStudents"; const AdminProfile: React.FC = () => { const { userId: therapistId } = useAuthContext(); const { therapist, error, refetch } = useTherapist(therapistId); const { updateTherapist } = useTherapists({ fetchOnMount: false }); const { updatePassword, deleteAccount } = useAuth(); + const { students, deleteStudent } = useStudents() const router = useRouter(); const [isModalOpen, setIsModalOpen] = useState(false); @@ -85,6 +87,10 @@ const AdminProfile: React.FC = () => { const handleFinalDelete = async () => { try { + students.forEach(student => { + deleteStudent(student.id) + }) + const userId = localStorage.getItem("userId"); if (!userId) { @@ -333,7 +339,7 @@ const AdminProfile: React.FC = () => { onClose={() => setOpenDeleteConfirm(false)} onConfirm={handleFinalDelete} title="Delete Account" - description="This action is permanent and cannot be undone." + description="Please note that deleting your account will also delete all your students. This action is permanent and cannot be undone. Are you sure you'd like to continue?" confirmText="Delete" cancelText="Cancel" variant="danger" diff --git a/frontend/src/app/therapistProfile/page.tsx b/frontend/src/app/therapistProfile/page.tsx deleted file mode 100644 index cd9cbf5d..00000000 --- a/frontend/src/app/therapistProfile/page.tsx +++ /dev/null @@ -1,160 +0,0 @@ -"use client"; - -import AppLayout from "@/components/AppLayout"; -import { Button } from "@/components/ui/button"; -import { ConfirmDialog } from "@/components/ui/confirm-dialog"; -import { - Dialog, - DialogContent, - DialogFooter, - DialogHeader, - DialogTitle, -} from "@/components/ui/dialog"; -import { useAuth } from "@/hooks/useAuth"; -import { validatePassword } from "@/lib/validatePassword"; -import { useRouter } from "next/navigation"; -import { useState } from "react"; - -export default function TherapistProfile() { - const { updatePassword, deleteAccount } = useAuth(); - - const [openPassword, setOpenPassword] = useState(false); - const [currentPassword, setCurrentPassword] = useState(""); - const [newPassword, setNewPassword] = useState(""); - const [confirmPassword, setConfirmPassword] = useState(""); - const [passwordError, setPasswordError] = useState(""); - - const [openDeleteConfirm, setOpenDeleteConfirm] = useState(false); - - const router = useRouter(); - - const handlePasswordSave = () => { - setPasswordError(""); - - if (!currentPassword || !newPassword || !confirmPassword) { - setPasswordError("All fields are required"); - return; - } - if (newPassword !== confirmPassword) { - setPasswordError("New passwords do not match."); - return; - } - if (validatePassword(newPassword)) { - setPasswordError( - "Password must include at least one special character (!@#$%^&*()_+-=[]{};:'\",.<>?/~`|)" - ); - } - - try { - updatePassword({ password: newPassword }); - - setOpenPassword(false); - setCurrentPassword(""); - setNewPassword(""); - setConfirmPassword(""); - } catch { - setPasswordError("Failed to update password"); - } - }; - - const handleFinalDelete = async () => { - try { - const userId = localStorage.getItem("userId"); - - if (!userId) { - console.error("User ID Missing"); - return; - } - - await deleteAccount(userId); - - setOpenDeleteConfirm(false); - setOpenDeleteConfirm(false); - - router.push("/login"); - } catch { - const message = "Failed to delete account"; - console.error(message); - } - }; - - return ( - -
-

Therapist Profile

-
- -
- -
- - - - - Update Password - - -
-
- - setCurrentPassword(e.target.value)} - /> -
- -
- - setNewPassword(e.target.value)} - /> -
- -
- - setConfirmPassword(e.target.value)} - /> -
- - {passwordError && ( -

{passwordError}

- )} -
- - - - - -
-
- -
- -
- - setOpenDeleteConfirm(false)} - onConfirm={handleFinalDelete} - title="Delete Account" - description="This action is permanent and cannot be undone." - confirmText="Delete" - cancelText="Cancel" - variant="danger" - /> -
- ); -} From 616e5dfaf9eb6d5bb7e98d23de0007f6fe28ca96 Mon Sep 17 00:00:00 2001 From: Harsh31105 Date: Sat, 6 Dec 2025 05:10:13 -0500 Subject: [PATCH 2/2] feat: Cleaning Print Statement? --- backend/internal/auth/delete_account.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/backend/internal/auth/delete_account.go b/backend/internal/auth/delete_account.go index e4d3c476..7ce70075 100644 --- a/backend/internal/auth/delete_account.go +++ b/backend/internal/auth/delete_account.go @@ -12,8 +12,6 @@ func SupabaseDeleteAccount(cfg *config.Supabase, userID string) error { supabaseURL := cfg.URL serviceRoleKey := cfg.ServiceRoleKey - fmt.Println(cfg.ServiceRoleKey) - req, err := http.NewRequest("DELETE", fmt.Sprintf("%s/auth/v1/admin/users/%s", supabaseURL, userID), nil) if err != nil { return errs.BadRequest(fmt.Sprintf("Failed to create request: %v", err))