Skip to content

Commit d548d89

Browse files
committed
Added a functionalty to automatically chnage registered user to Architect when he register as architect
1 parent 1c103f2 commit d548d89

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/pages/categories/Architects.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const ArchitectsPage = () => {
7878
const fileExt = file.name.split(".").pop();
7979
const fileName = `${user.id}_${Date.now()}.${fileExt}`;
8080

81-
const { data, error: uploadError } = await supabase.storage
81+
const { error: uploadError } = await supabase.storage
8282
.from("Architects")
8383
.upload(fileName, file, {
8484
cacheControl: "3600",
@@ -106,7 +106,7 @@ const ArchitectsPage = () => {
106106
}
107107
};
108108

109-
// ✅ Handle form submit with duplicate prevention
109+
// ✅ Handle form submit with duplicate prevention + update role
110110
const handleRegister = async (e: React.FormEvent) => {
111111
e.preventDefault();
112112

@@ -154,6 +154,14 @@ const ArchitectsPage = () => {
154154

155155
if (error) throw error;
156156

157+
// ✅ Step 3: Update user_role to 'architect' in profiles table
158+
const { error: roleError } = await supabase
159+
.from("profiles")
160+
.update({ user_role: "architect" })
161+
.eq("id", user.id);
162+
163+
if (roleError) throw roleError;
164+
157165
setMessage("Successfully registered as architect!");
158166
setFormData({
159167
name: "",
@@ -408,4 +416,3 @@ const ArchitectsPage = () => {
408416
};
409417

410418
export default ArchitectsPage;
411-

0 commit comments

Comments
 (0)