From 22e6f39b29c8a9dcda48155af31318b5ff5d6ca6 Mon Sep 17 00:00:00 2001 From: programVeins Date: Mon, 11 Oct 2021 10:30:54 +0530 Subject: [PATCH 01/10] Refine onboarding workflow --- web/pages/onboarding.js | 19 ++++++++++++++----- web/pages/profile.js | 17 +++++++++++++---- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/web/pages/onboarding.js b/web/pages/onboarding.js index cfb2b0d..ed41613 100644 --- a/web/pages/onboarding.js +++ b/web/pages/onboarding.js @@ -1,5 +1,5 @@ import { useRouter } from "next/dist/client/router"; -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { useAuth } from "../lib/auth"; import { updateUser } from "../lib/signupComplete"; @@ -11,11 +11,17 @@ export default function OnBoarding() { }); const router = useRouter(); - + const { currentUser } = useAuth(); const handleChange = (e) => { setUserObject({ ...userObject, [e.target.name]: e.target.value }); }; + useEffect(() => { + if (!currentUser) { + router.push("/"); + } + }, [router, currentUser]); + const handleSubmit = async (e) => { e.preventDefault(); let tagsToBeSent = []; @@ -35,11 +41,12 @@ export default function OnBoarding() { Full Name
@@ -62,11 +69,12 @@ export default function OnBoarding() { */}
@@ -74,11 +82,12 @@ export default function OnBoarding() { Username
diff --git a/web/pages/profile.js b/web/pages/profile.js index d3e8612..eeb8e1d 100644 --- a/web/pages/profile.js +++ b/web/pages/profile.js @@ -10,12 +10,21 @@ export default function Profile() { const router = useRouter(); useEffect(() => { - if (currentUser) - getCurrentUser(currentUser.email).then((user) => { - setThisUser(user); + if (currentUser) { + searchUsers(currentUser.email).then((res) => { + if (res == -1) { + router.push("/onboarding"); + } else { + getCurrentUser(currentUser.email).then((user) => { + setThisUser(user); + }); + } }); + } else { + router.push("/signup"); + } console.log(currentUser); - }, [currentUser]); + }, [currentUser, router]); return (
From 9ce77fe064e03e61b8c9fc99b7ef8b582a83d7b8 Mon Sep 17 00:00:00 2001 From: programVeins Date: Mon, 11 Oct 2021 10:44:25 +0530 Subject: [PATCH 02/10] Reorganize splash --- web/pages/posts/edit.js | 4 ++-- web/pages/profile.js | 2 +- web/pages/splash.js | 33 ++++++--------------------------- 3 files changed, 9 insertions(+), 30 deletions(-) diff --git a/web/pages/posts/edit.js b/web/pages/posts/edit.js index b79f1a7..d1d14c5 100644 --- a/web/pages/posts/edit.js +++ b/web/pages/posts/edit.js @@ -128,14 +128,14 @@ function PostDisplay() {
+ + + + + ) : null} +
+
+ ); +} diff --git a/web/pages/guild/[gid].js b/web/pages/guild/[gid].js index bc2e8db..bc82d73 100644 --- a/web/pages/guild/[gid].js +++ b/web/pages/guild/[gid].js @@ -13,6 +13,14 @@ export default function GuildDetail() { const handleChange = (e) => { setNewClientText(e.target.value); }; + useEffect(() => { + window.scrollTo(0, document.body.scrollHeight); + messages.sort((a, b) => { + return a.id - b.id; + }); + setmessages(messages); + console.log(messages); + }, [messages]); const fetchMessages = async () => { if (messages.length === 0) { diff --git a/web/pages/profile.js b/web/pages/profile.js index c6acdb2..20547a7 100644 --- a/web/pages/profile.js +++ b/web/pages/profile.js @@ -20,8 +20,6 @@ export default function Profile() { }); } }); - } else { - router.push("/signup"); } console.log(currentUser); }, [currentUser, router]); @@ -44,36 +42,47 @@ export default function Profile() { />
-

- {thisUser.fullName} -

- -
-
-

- @{thisUser.username} -

- +
+

+ {thisUser.fullName} +

+

+ @{thisUser.username} +

+

+ {thisUser.email} +

+
+ +
+ + + +
-

- {thisUser.email} -

{thisUser.tags.map((tag, i) => { if (i < 4) diff --git a/web/pages/splash.js b/web/pages/splash.js index 6c8f29f..e87c135 100644 --- a/web/pages/splash.js +++ b/web/pages/splash.js @@ -26,7 +26,7 @@ export default function Splash() {
-

+

Here in Develove, you can meet and hangout with developers from all around the world.

@@ -34,13 +34,13 @@ export default function Splash() {
Earth -

+

Search them up using the interactive map, or shoot them a DM. You might get lucky!

-

+

Meet people tailored to your interests, build hype, and new friends using Develove.

diff --git a/web/tailwind.config.js b/web/tailwind.config.js index 90a2fba..77d066d 100644 --- a/web/tailwind.config.js +++ b/web/tailwind.config.js @@ -15,6 +15,10 @@ module.exports = { end: "#282828", solid: "#2D2D2D", }, + danger: { + start: "#EE5B5B", + end: "#BB3A3A", + }, white: "#FFFFFF", black: "#000000", accentGray: "#1F1F1F", From c828777d70a07f0a93ed8675651e796e029379a7 Mon Sep 17 00:00:00 2001 From: programVeins Date: Mon, 11 Oct 2021 11:42:32 +0530 Subject: [PATCH 04/10] Add new post on home --- web/pages/home.js | 27 ++++++++++++++++++++++++--- web/pages/profile.js | 20 ++++++++++---------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/web/pages/home.js b/web/pages/home.js index 8755a40..843e5a5 100644 --- a/web/pages/home.js +++ b/web/pages/home.js @@ -3,10 +3,14 @@ import Image from "next/image"; import { supabase } from "../lib/supabase"; import { truncatePost } from "../lib/utils"; import Link from "next/link"; +import { useAuth } from "../lib/auth"; +import { useRouter } from "next/dist/client/router"; export default function Home() { const [posts, setPosts] = useState(null); const [loading, setLoading] = useState(true); + const { currentUser } = useAuth(); + const router = useRouter(); useEffect(() => { async function fetchPost() { @@ -24,6 +28,12 @@ export default function Home() { fetchPost(); }, [posts]); + useEffect(() => { + if (!currentUser) { + router.push("/splash"); + } + }, [currentUser, router]); + useEffect(() => { console.log(posts); }, [posts]); @@ -31,9 +41,20 @@ export default function Home() { return (
-

- Good Morning 🌥 ðŸ—ž -

+
+

+ Good Morning 🌥 ðŸ—ž +

+ +
+
{!loading ? posts.map((post, i) => { diff --git a/web/pages/profile.js b/web/pages/profile.js index 20547a7..110b7d3 100644 --- a/web/pages/profile.js +++ b/web/pages/profile.js @@ -55,16 +55,6 @@ export default function Profile() {
- +
From ad700dfc799336554cd2833b153b095f2ce98eea Mon Sep 17 00:00:00 2001 From: programVeins Date: Mon, 11 Oct 2021 11:47:10 +0530 Subject: [PATCH 05/10] Implement hit return to send message --- web/pages/guild/[gid].js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/web/pages/guild/[gid].js b/web/pages/guild/[gid].js index bc82d73..1235266 100644 --- a/web/pages/guild/[gid].js +++ b/web/pages/guild/[gid].js @@ -115,23 +115,14 @@ export default function GuildDetail() { { + if (e.key === "Enter") { + handleSubmit(); + } + }} + placeholder="Type a message and hit return" className="w-9/12 fixed bottom-10 bg-accentGray rounded-xl h-14 mt-10 text-white p-4 text-lg focus:outline-none" /> -
-
handleSubmit()} - className="fixed flex items-center pr-3 cursor-pointer hover:opacity-70 justify-center bottom-10 float-right rounded-r-xl bg-primary-solid h-14 w-20" - > - send -
-
); } From 8583d4ece68c4f8d4f514865b50e3f44fa7b254e Mon Sep 17 00:00:00 2001 From: programVeins Date: Mon, 11 Oct 2021 12:05:09 +0530 Subject: [PATCH 06/10] Fix edit user bugs --- web/lib/utils.js | 12 ++++++++ web/pages/edituser.js | 69 ++++++++++++++++++++++++++----------------- web/pages/home.js | 4 +-- 3 files changed, 56 insertions(+), 29 deletions(-) diff --git a/web/lib/utils.js b/web/lib/utils.js index 9a63a58..39bae14 100644 --- a/web/lib/utils.js +++ b/web/lib/utils.js @@ -4,3 +4,15 @@ export const truncatePost = (post) => { } return post; }; + +export const getTimeOfDay = (hour) => { + if (hour >= 5 && hour < 12) { + return "Good Morning 🌥"; + } else if (hour >= 12 && hour < 17) { + return "Good Afternoon 🌞"; + } else if (hour >= 17 && hour < 20) { + return "Good Evening 🌇"; + } else { + return "Good Night 🌘"; + } +}; diff --git a/web/pages/edituser.js b/web/pages/edituser.js index 66df0a8..cec4014 100644 --- a/web/pages/edituser.js +++ b/web/pages/edituser.js @@ -38,7 +38,7 @@ export default function EditUser() { if (thisUser) { setUserObject({ fullName: thisUser.fullName, - tags: thisUser.tags, + tags: thisUser.tags.join(","), username: thisUser.username, }); } @@ -51,18 +51,32 @@ export default function EditUser() { const handleSubmit = async (e) => { e.preventDefault(); let tagsToBeSent = []; + console.log(userObject); tagsToBeSent = userObject.tags.split(","); + try { + let res = await supabase + .from("users") + .update({ + fullName: userObject.fullName, + tags: tagsToBeSent, + username: userObject.username, + }) + .match({ email: currentUser.email }); + console.log(res); - await supabase - .from("users") - .update({ - fullName: userObject.fullName, - tags: tagsToBeSent, - username: userObject.username, - }) - .match({ email: currentUser.email }); - toast.success("User Updated"); - router.push("/profile"); + if (res.error) { + throw res.error; + } + toast.success("User Updated"); + router.push("/profile"); + } catch (error) { + console.log(error); + if (error.code == 23505) { + toast.error("Username already taken"); + } else { + toast.error("Something went wrong, check your details"); + } + } }; return ( @@ -81,10 +95,13 @@ export default function EditUser() { height="120" width="120" /> -
-
+ +
-
+
-
+
- - diff --git a/web/pages/home.js b/web/pages/home.js index 843e5a5..1941dbf 100644 --- a/web/pages/home.js +++ b/web/pages/home.js @@ -1,7 +1,7 @@ import React, { useState, useEffect } from "react"; import Image from "next/image"; import { supabase } from "../lib/supabase"; -import { truncatePost } from "../lib/utils"; +import { getTimeOfDay, truncatePost } from "../lib/utils"; import Link from "next/link"; import { useAuth } from "../lib/auth"; import { useRouter } from "next/dist/client/router"; @@ -43,7 +43,7 @@ export default function Home() {

- Good Morning 🌥 ðŸ—ž + {getTimeOfDay(new Date().getHours())} 🗞

diff --git a/web/pages/profile.js b/web/pages/profile.js index 110b7d3..3bded46 100644 --- a/web/pages/profile.js +++ b/web/pages/profile.js @@ -26,7 +26,7 @@ export default function Profile() { return (
-
+
{thisUser ? ( <>