diff --git a/client/src/components/User/SettingsWidgets/UpdateUserInfo.tsx b/client/src/components/User/SettingsWidgets/UpdateUserInfo.tsx
new file mode 100644
index 0000000..96ef235
--- /dev/null
+++ b/client/src/components/User/SettingsWidgets/UpdateUserInfo.tsx
@@ -0,0 +1,34 @@
+import { useState } from "react";
+import Button from "../../_ui/Button/Button";
+import Card from "../../_ui/Card/Card"
+
+const UpdateUserInfo = () => {
+ const [input, setInput] = useState({first: "", last: ""});
+
+ const handleUpdate = () => {
+ if (!input.first || !input.last) return;
+
+ }
+
+ return (
+
+ Update User Information
+
+
+
+
+
+ )
+}
+
+export default UpdateUserInfo;
\ No newline at end of file
diff --git a/client/src/components/User/UserProfile.tsx b/client/src/components/User/UserProfile.tsx
index e24b73f..1407eaa 100644
--- a/client/src/components/User/UserProfile.tsx
+++ b/client/src/components/User/UserProfile.tsx
@@ -16,7 +16,7 @@ export default function UserProfile() {
-
+
)
diff --git a/client/src/components/User/UserSettings.tsx b/client/src/components/User/UserSettings.tsx
index 45a0234..c5fef0a 100644
--- a/client/src/components/User/UserSettings.tsx
+++ b/client/src/components/User/UserSettings.tsx
@@ -1,3 +1,18 @@
+import { useEffect, useState } from "react";
+import { useSupabase } from "../../supabase/SupabaseContext"
+import Page from "../_ui/Page/Page";
+import UpdateUserInfo from "./SettingsWidgets/UpdateUserInfo";
+
export default function UserSettings() {
- return User Settings!
+ const supabase = useSupabase();
+ const [activeSections, setActiveSections] = useState({
+ userInfo: false
+ });
+
+ return (
+
+ User Settings!
+ { activeSections.userInfo && }
+
+ )
}
\ No newline at end of file
diff --git a/client/src/util/apiUtils.ts b/client/src/util/apiUtils.ts
index fb578c0..8ea2abd 100644
--- a/client/src/util/apiUtils.ts
+++ b/client/src/util/apiUtils.ts
@@ -9,6 +9,17 @@ export const getByProductId = async (id: string) => {
return response;
}
+export const updateUser = async (id: string, body: object) => {
+ const response = await fetch(`https://mikayla-spice-market-api.herokuapp.com/users/${id}`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json"
+ },
+ body: JSON.stringify(body)
+ });
+ return response;
+}
+
// order functions
export const getOrder = async () => {
return;
diff --git a/client/src/util/authHelpers.ts b/client/src/util/authHelpers.ts
index 281f083..e688571 100644
--- a/client/src/util/authHelpers.ts
+++ b/client/src/util/authHelpers.ts
@@ -1,4 +1,5 @@
import { SupabaseClient } from "@supabase/supabase-js";
+import { updateUser } from "./apiUtils";
export interface FormInput {
email: string
@@ -22,7 +23,6 @@ export const handleRegister = async (supabase: SupabaseClient | undefined, input
if (email && password) {
const { user, session, error} = await supabase.auth.signUp({ email, password });
if (error) throw error;
- console.log(user, session);
}
}
diff --git a/db/Seed.js b/db/Seed.js
index 21cdec3..7182b8d 100644
--- a/db/Seed.js
+++ b/db/Seed.js
@@ -14,7 +14,7 @@ async function main() {
CREATE TABLE IF NOT EXISTS users (
id INT PRIMARY KEY GENERATED ALWAYS AS IDENTITY NOT NULL,
email VARCHAR NOT NULL,
- password VARCHAR NOT NULL,
+ supabaseUser JSON NOT NULL,
firstname VARCHAR,
lastname VARCHAR,
isadmin BOOLEAN DEFAULT FALSE
diff --git a/models/UserModel.js b/models/UserModel.js
index 003156b..3ade8de 100644
--- a/models/UserModel.js
+++ b/models/UserModel.js
@@ -62,4 +62,19 @@ module.exports = class UserModel {
throw new Error(e);
}
}
+
+ async createFromSupabase(data) {
+ try {
+ const statement = '';
+ const result = await db.query(statement);
+
+ if (result.rows.length) {
+ return result.rows[0];
+ }
+
+ return null;
+ } catch(e) {
+ throw new Error(e);
+ }
+ }
}
\ No newline at end of file
diff --git a/routes/user.js b/routes/user.js
index 5d08d4a..b04b272 100644
--- a/routes/user.js
+++ b/routes/user.js
@@ -26,4 +26,13 @@ module.exports = (app) => {
next(e);
}
})
+
+ router.post('/', async (req, res, next) => {
+ try {
+ const data = req.body;
+
+ } catch(e) {
+ next(e);
+ }
+ })
}
\ No newline at end of file
diff --git a/services/UserService.js b/services/UserService.js
index 89880bb..194dc70 100644
--- a/services/UserService.js
+++ b/services/UserService.js
@@ -23,4 +23,12 @@ module.exports = class UserService {
throw new Error(e);
}
}
+
+ async insert(data) {
+ try {
+ const user = await UserInstance.create(data);
+ } catch(e) {
+ next(e);
+ }
+ }
}
\ No newline at end of file