From 0285fffe1034d1e1837fac27d0c81b5788f6b6b5 Mon Sep 17 00:00:00 2001 From: kobia77 Date: Sat, 3 Aug 2024 12:25:16 +0300 Subject: [PATCH 01/14] update fetch links --- src/app/about/page.js | 3 +-- src/app/login/page.js | 2 +- src/app/toBeContinued/page.js | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/app/about/page.js b/src/app/about/page.js index 2a318db..1126198 100644 --- a/src/app/about/page.js +++ b/src/app/about/page.js @@ -7,7 +7,7 @@ export default function About() { useEffect(() => { const fetchData = async () => { // const res = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/about`) - const res = await fetch('http://localhost:3001/api/about') + const res = await fetch('https://gamegrid-server.onrender.com//api/about') const json = await res.json() setData(json) } @@ -28,4 +28,3 @@ export default function About() { ) } - diff --git a/src/app/login/page.js b/src/app/login/page.js index cf0c7da..ada27c8 100644 --- a/src/app/login/page.js +++ b/src/app/login/page.js @@ -13,7 +13,7 @@ export default function Login() { e.preventDefault() // שליחת בקשת POST לשרת - const response = await fetch('http://localhost:3001/api/login', { + const response = await fetch('https://gamegrid-server.onrender.com/api/login', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/src/app/toBeContinued/page.js b/src/app/toBeContinued/page.js index 7337e19..28e23ab 100644 --- a/src/app/toBeContinued/page.js +++ b/src/app/toBeContinued/page.js @@ -7,7 +7,7 @@ export default function toBeContinued() { // useEffect(() => { // const fetchData = async () => { // // const res = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/about`) - // const res = await fetch('http://localhost:3001/api/about') + // const res = await fetch('https://gamegrid-server.onrender.com//api/about') // const json = await res.json() // setData(json) // } From c508d3107db1652ee8d9fcd56963672de6abefe2 Mon Sep 17 00:00:00 2001 From: kobia77 Date: Sat, 3 Aug 2024 12:34:18 +0300 Subject: [PATCH 02/14] link change --- src/app/about/page.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/about/page.js b/src/app/about/page.js index 1126198..c92177d 100644 --- a/src/app/about/page.js +++ b/src/app/about/page.js @@ -7,7 +7,7 @@ export default function About() { useEffect(() => { const fetchData = async () => { // const res = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/about`) - const res = await fetch('https://gamegrid-server.onrender.com//api/about') + const res = await fetch('https://gamegrid-server.onrender.com/api/about') const json = await res.json() setData(json) } From 3851412e712e7dbbc27618e8bd14d5f669ea2ef6 Mon Sep 17 00:00:00 2001 From: kobia77 Date: Sat, 3 Aug 2024 13:21:09 +0300 Subject: [PATCH 03/14] updated deploy app --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index b83875d..0e710e5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -51,6 +51,9 @@ jobs: command: | set -o pipefail npm run lint + - run: + name: deploy app + command: curl "https://api.render.com/deploy/srv-cqehv6pu0jms739cc6ug?key=WMz-rSxnwhk" workflows: version: 2 From f2c06548dec73246c86e5f2d1d2610e461bb0926 Mon Sep 17 00:00:00 2001 From: kobia77 Date: Sun, 4 Aug 2024 00:01:15 +0300 Subject: [PATCH 04/14] render --- src/app/HomePage/Profile/[id]/Like/page.js | 7 +-- src/app/HomePage/Profile/[id]/Save/page.js | 7 +-- src/app/HomePage/Profile/[id]/edit/page.js | 11 ++-- src/app/HomePage/Profile/[id]/page.js | 2 +- src/app/about/page.js | 2 +- src/app/components/newPost.js | 2 +- src/app/components/posts.js | 68 +++++++++------------- src/app/login/page.js | 2 +- src/app/register/page.js | 2 +- 9 files changed, 41 insertions(+), 62 deletions(-) diff --git a/src/app/HomePage/Profile/[id]/Like/page.js b/src/app/HomePage/Profile/[id]/Like/page.js index 7793e3e..bac82af 100644 --- a/src/app/HomePage/Profile/[id]/Like/page.js +++ b/src/app/HomePage/Profile/[id]/Like/page.js @@ -10,7 +10,7 @@ export default function ProfileLike({ params }) { useEffect(() => { const fetchUserData = async () => { try { - const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_HOST}/api/users/${params.id}/data`, { + const response = await fetch(`http://localhost:3001/api/users/${params.id}/data`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }) @@ -19,10 +19,7 @@ export default function ProfileLike({ params }) { if (response.ok) { setUserData(data) } - } - - - catch (error) { + } catch (error) { console.error('Error fetching user data:', error) } } diff --git a/src/app/HomePage/Profile/[id]/Save/page.js b/src/app/HomePage/Profile/[id]/Save/page.js index 31dfc2c..a3681df 100644 --- a/src/app/HomePage/Profile/[id]/Save/page.js +++ b/src/app/HomePage/Profile/[id]/Save/page.js @@ -11,7 +11,7 @@ export default function ProfileSave({ params }) { useEffect(() => { const fetchUserData = async () => { try { - const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_HOST}/api/users/${params.id}/data`, { + const response = await fetch(`http://localhost:3001/api/users/${params.id}/data`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }) @@ -20,10 +20,7 @@ export default function ProfileSave({ params }) { if (response.ok) { setUserData(data) } - } - - - catch (error) { + } catch (error) { console.error('Error fetching user data:', error) } } diff --git a/src/app/HomePage/Profile/[id]/edit/page.js b/src/app/HomePage/Profile/[id]/edit/page.js index b2a0ec6..91b4620 100644 --- a/src/app/HomePage/Profile/[id]/edit/page.js +++ b/src/app/HomePage/Profile/[id]/edit/page.js @@ -28,13 +28,10 @@ export default function ProfilePage({ params }) { useEffect(() => { const fetchUserData = async () => { try { - const userResponse = await fetch( - `${process.env.NEXT_PUBLIC_SERVER_HOST}/api/users/${params.id}/data`, - { - method: 'GET', - headers: { 'Content-Type': 'application/json' }, - } - ) + const userResponse = await fetch(`http://localhost:3001/api/users/${params.id}/data`, { + method: 'GET', + headers: { 'Content-Type': 'application/json' }, + }) const userData = await userResponse.json() if (userResponse.ok) { diff --git a/src/app/HomePage/Profile/[id]/page.js b/src/app/HomePage/Profile/[id]/page.js index 7c45a38..ac9316f 100644 --- a/src/app/HomePage/Profile/[id]/page.js +++ b/src/app/HomePage/Profile/[id]/page.js @@ -10,7 +10,7 @@ export default function ProfilePage({ params }) { useEffect(() => { const fetchUserData = async () => { try { - const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_HOST}/api/users/${params.id}/data`, { + const response = await fetch(`http://localhost:3001/api/users/${params.id}/data`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }) diff --git a/src/app/about/page.js b/src/app/about/page.js index 77e5edd..5f6313f 100644 --- a/src/app/about/page.js +++ b/src/app/about/page.js @@ -7,7 +7,7 @@ export default function About() { useEffect(() => { const fetchData = async () => { // const res = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/about`) - const res = await fetch('${process.env.NEXT_PUBLIC_SERVER_HOST}/api/about') + const res = await fetch('http://localhost:3001/api/about') const json = await res.json() setData(json) } diff --git a/src/app/components/newPost.js b/src/app/components/newPost.js index 705da4f..964fbf1 100644 --- a/src/app/components/newPost.js +++ b/src/app/components/newPost.js @@ -40,7 +40,7 @@ export default function NewPost() { return } - const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_HOST}/api/posts/${userId}/post/insert`, { + const response = await fetch(`http://localhost:3001/api/posts/${userId}/post/insert`, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/src/app/components/posts.js b/src/app/components/posts.js index e1001f9..2eccb37 100644 --- a/src/app/components/posts.js +++ b/src/app/components/posts.js @@ -28,15 +28,12 @@ export default function Posts({ keyPost }) { const fetchPosts = async () => { try { if (keyPost === 'following') { - const response = await fetch( - `${process.env.NEXT_PUBLIC_SERVER_HOST}/api/posts/${userId}/${keyPost}/posts`, - { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - }, - } - ) + const response = await fetch(`http://localhost:3001/api/posts/${userId}/${keyPost}/posts`, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + }) const data = await response.json() if (response.ok) { setPosts(data.posts_list) @@ -46,7 +43,7 @@ export default function Posts({ keyPost }) { } if (keyPost === 'all') { - const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_HOST}/api/posts/${keyPost}posts`, { + const response = await fetch(`http://localhost:3001/api/posts/${keyPost}posts`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -64,7 +61,7 @@ export default function Posts({ keyPost }) { if (keyPost === 'MyPost') { console.log(userId) - const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_HOST}/api/posts/${userId}/posts`, { + const response = await fetch(`http://localhost:3001/api/posts/${userId}/posts`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -83,7 +80,7 @@ export default function Posts({ keyPost }) { } if (keyPost === 'MySaved') { - const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_HOST}/api/posts/${userId}/saved`, { + const response = await fetch(`http://localhost:3001/api/posts/${userId}/saved`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -99,7 +96,7 @@ export default function Posts({ keyPost }) { } if (keyPost === 'MyLiked') { - const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_HOST}/api/posts/${userId}/liked`, { + const response = await fetch(`http://localhost:3001/api/posts/${userId}/liked`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -114,7 +111,6 @@ export default function Posts({ keyPost }) { console.log('Failed to fetch posts:', data.error) } } - } catch (error) { console.error('Error fetching posts:', error) } @@ -159,26 +155,20 @@ export default function Posts({ keyPost }) { if (isSaved) { // User already saved the post, remove the save - response = await fetch( - `${process.env.NEXT_PUBLIC_SERVER_HOST}/api/posts/${post._id}/${userId}/unsave`, - { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - } - ) + response = await fetch(`http://localhost:3001/api/posts/${post._id}/${userId}/unsave`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + }) } else { // User has not saved the post yet, add the save - response = await fetch( - `${process.env.NEXT_PUBLIC_SERVER_HOST}/api/posts/${post._id}/${userId}/save`, - { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - } - ) + response = await fetch(`http://localhost:3001/api/posts/${post._id}/${userId}/save`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + }) } const data = await response.json() @@ -227,7 +217,7 @@ export default function Posts({ keyPost }) { } } - const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_HOST}/api/posts/${userId}/post/share`, { + const response = await fetch(`http://localhost:3001/api/posts/${userId}/post/share`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -272,7 +262,7 @@ export default function Posts({ keyPost }) { // User already liked the post, remove the like try { const response = await fetch( - `${process.env.NEXT_PUBLIC_SERVER_HOST}/api/posts/${posts[postIndex]._id}/${userId}/unlike`, + `http://localhost:3001/api/posts/${posts[postIndex]._id}/${userId}/unlike`, { method: 'GET', headers: { @@ -295,7 +285,7 @@ export default function Posts({ keyPost }) { // Send the updated like status to the server try { const response = await fetch( - `${process.env.NEXT_PUBLIC_SERVER_HOST}/api/posts/${posts[postIndex]._id}/${userId}/like`, + `http://localhost:3001/api/posts/${posts[postIndex]._id}/${userId}/like`, { method: 'GET', headers: { @@ -328,7 +318,7 @@ export default function Posts({ keyPost }) { if (post.shared) { try { const response = await fetch( - `${process.env.NEXT_PUBLIC_SERVER_HOST}/api/posts/${post.shared_post.original_post}/post`, + `http://localhost:3001/api/posts/${post.shared_post.original_post}/post`, { method: 'GET', headers: { @@ -353,7 +343,7 @@ export default function Posts({ keyPost }) { try { const og_userResponse = await fetch( - `${process.env.NEXT_PUBLIC_SERVER_HOST}/api/users/${post.shared_post.original_owner}/data` + `http://localhost:3001/api/users/${post.shared_post.original_owner}/data` ) const original_data = await og_userResponse.json() @@ -366,9 +356,7 @@ export default function Posts({ keyPost }) { } try { - const userResponse = await fetch( - `${process.env.NEXT_PUBLIC_SERVER_HOST}/api/users/${post.user_id}/data` - ) + const userResponse = await fetch(`http://localhost:3001/api/users/${post.user_id}/data`) const userData = await userResponse.json() if (userResponse.ok) { diff --git a/src/app/login/page.js b/src/app/login/page.js index b79ffac..e210334 100644 --- a/src/app/login/page.js +++ b/src/app/login/page.js @@ -20,7 +20,7 @@ export default function Login() { //delay for loading components await new Promise((resolve) => setTimeout(resolve, 2000)) - const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_HOST}/api/login/${input}`, { + const response = await fetch(`http://localhost:3001/api/login/${input}`, { method: 'GET', headers: { 'Content-Type': 'application/json', diff --git a/src/app/register/page.js b/src/app/register/page.js index 1378a1f..c9bc2c3 100644 --- a/src/app/register/page.js +++ b/src/app/register/page.js @@ -49,7 +49,7 @@ export default function Register() { } // שליחת בקשת POST לשרת - const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_HOST}/api/users/insert`, { + const response = await fetch(`http://localhost:3001/api/users/insert`, { method: 'POST', headers: { 'Content-Type': 'application/json', From d9a1f6921f212b2f97de94aca464d4fb2a71aa85 Mon Sep 17 00:00:00 2001 From: kobia77 Date: Sun, 4 Aug 2024 00:02:27 +0300 Subject: [PATCH 05/14] render --- src/app/HomePage/Profile/[id]/Like/page.js | 2 +- src/app/HomePage/Profile/[id]/Save/page.js | 2 +- src/app/HomePage/Profile/[id]/edit/page.js | 2 +- src/app/HomePage/Profile/[id]/page.js | 2 +- src/app/about/page.js | 2 +- src/app/components/newPost.js | 2 +- src/app/components/posts.js | 54 +++++++++++++--------- src/app/login/page.js | 2 +- src/app/register/page.js | 2 +- 9 files changed, 39 insertions(+), 31 deletions(-) diff --git a/src/app/HomePage/Profile/[id]/Like/page.js b/src/app/HomePage/Profile/[id]/Like/page.js index bac82af..4b6fe92 100644 --- a/src/app/HomePage/Profile/[id]/Like/page.js +++ b/src/app/HomePage/Profile/[id]/Like/page.js @@ -10,7 +10,7 @@ export default function ProfileLike({ params }) { useEffect(() => { const fetchUserData = async () => { try { - const response = await fetch(`http://localhost:3001/api/users/${params.id}/data`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/users/${params.id}/data`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }) diff --git a/src/app/HomePage/Profile/[id]/Save/page.js b/src/app/HomePage/Profile/[id]/Save/page.js index a3681df..0700e21 100644 --- a/src/app/HomePage/Profile/[id]/Save/page.js +++ b/src/app/HomePage/Profile/[id]/Save/page.js @@ -11,7 +11,7 @@ export default function ProfileSave({ params }) { useEffect(() => { const fetchUserData = async () => { try { - const response = await fetch(`http://localhost:3001/api/users/${params.id}/data`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/users/${params.id}/data`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }) diff --git a/src/app/HomePage/Profile/[id]/edit/page.js b/src/app/HomePage/Profile/[id]/edit/page.js index 91b4620..0a654a3 100644 --- a/src/app/HomePage/Profile/[id]/edit/page.js +++ b/src/app/HomePage/Profile/[id]/edit/page.js @@ -28,7 +28,7 @@ export default function ProfilePage({ params }) { useEffect(() => { const fetchUserData = async () => { try { - const userResponse = await fetch(`http://localhost:3001/api/users/${params.id}/data`, { + const userResponse = await fetch(`https://gamegrid-server.onrender.com/api/users/${params.id}/data`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }) diff --git a/src/app/HomePage/Profile/[id]/page.js b/src/app/HomePage/Profile/[id]/page.js index ac9316f..3f94985 100644 --- a/src/app/HomePage/Profile/[id]/page.js +++ b/src/app/HomePage/Profile/[id]/page.js @@ -10,7 +10,7 @@ export default function ProfilePage({ params }) { useEffect(() => { const fetchUserData = async () => { try { - const response = await fetch(`http://localhost:3001/api/users/${params.id}/data`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/users/${params.id}/data`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }) diff --git a/src/app/about/page.js b/src/app/about/page.js index 5f6313f..5b98697 100644 --- a/src/app/about/page.js +++ b/src/app/about/page.js @@ -7,7 +7,7 @@ export default function About() { useEffect(() => { const fetchData = async () => { // const res = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/about`) - const res = await fetch('http://localhost:3001/api/about') + const res = await fetch('https://gamegrid-server.onrender.com/api/about') const json = await res.json() setData(json) } diff --git a/src/app/components/newPost.js b/src/app/components/newPost.js index 964fbf1..b76b8e0 100644 --- a/src/app/components/newPost.js +++ b/src/app/components/newPost.js @@ -40,7 +40,7 @@ export default function NewPost() { return } - const response = await fetch(`http://localhost:3001/api/posts/${userId}/post/insert`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/posts/${userId}/post/insert`, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/src/app/components/posts.js b/src/app/components/posts.js index 2eccb37..d651a16 100644 --- a/src/app/components/posts.js +++ b/src/app/components/posts.js @@ -28,12 +28,15 @@ export default function Posts({ keyPost }) { const fetchPosts = async () => { try { if (keyPost === 'following') { - const response = await fetch(`http://localhost:3001/api/posts/${userId}/${keyPost}/posts`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - }, - }) + const response = await fetch( + `https://gamegrid-server.onrender.com/api/posts/${userId}/${keyPost}/posts`, + { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + } + ) const data = await response.json() if (response.ok) { setPosts(data.posts_list) @@ -43,7 +46,7 @@ export default function Posts({ keyPost }) { } if (keyPost === 'all') { - const response = await fetch(`http://localhost:3001/api/posts/${keyPost}posts`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/posts/${keyPost}posts`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -61,7 +64,7 @@ export default function Posts({ keyPost }) { if (keyPost === 'MyPost') { console.log(userId) - const response = await fetch(`http://localhost:3001/api/posts/${userId}/posts`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/posts/${userId}/posts`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -80,7 +83,7 @@ export default function Posts({ keyPost }) { } if (keyPost === 'MySaved') { - const response = await fetch(`http://localhost:3001/api/posts/${userId}/saved`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/posts/${userId}/saved`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -96,7 +99,7 @@ export default function Posts({ keyPost }) { } if (keyPost === 'MyLiked') { - const response = await fetch(`http://localhost:3001/api/posts/${userId}/liked`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/posts/${userId}/liked`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -155,15 +158,18 @@ export default function Posts({ keyPost }) { if (isSaved) { // User already saved the post, remove the save - response = await fetch(`http://localhost:3001/api/posts/${post._id}/${userId}/unsave`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - }) + response = await fetch( + `https://gamegrid-server.onrender.com/api/posts/${post._id}/${userId}/unsave`, + { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + } + ) } else { // User has not saved the post yet, add the save - response = await fetch(`http://localhost:3001/api/posts/${post._id}/${userId}/save`, { + response = await fetch(`https://gamegrid-server.onrender.com/api/posts/${post._id}/${userId}/save`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -217,7 +223,7 @@ export default function Posts({ keyPost }) { } } - const response = await fetch(`http://localhost:3001/api/posts/${userId}/post/share`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/posts/${userId}/post/share`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -262,7 +268,7 @@ export default function Posts({ keyPost }) { // User already liked the post, remove the like try { const response = await fetch( - `http://localhost:3001/api/posts/${posts[postIndex]._id}/${userId}/unlike`, + `https://gamegrid-server.onrender.com/api/posts/${posts[postIndex]._id}/${userId}/unlike`, { method: 'GET', headers: { @@ -285,7 +291,7 @@ export default function Posts({ keyPost }) { // Send the updated like status to the server try { const response = await fetch( - `http://localhost:3001/api/posts/${posts[postIndex]._id}/${userId}/like`, + `https://gamegrid-server.onrender.com/api/posts/${posts[postIndex]._id}/${userId}/like`, { method: 'GET', headers: { @@ -318,7 +324,7 @@ export default function Posts({ keyPost }) { if (post.shared) { try { const response = await fetch( - `http://localhost:3001/api/posts/${post.shared_post.original_post}/post`, + `https://gamegrid-server.onrender.com/api/posts/${post.shared_post.original_post}/post`, { method: 'GET', headers: { @@ -343,7 +349,7 @@ export default function Posts({ keyPost }) { try { const og_userResponse = await fetch( - `http://localhost:3001/api/users/${post.shared_post.original_owner}/data` + `https://gamegrid-server.onrender.com/api/users/${post.shared_post.original_owner}/data` ) const original_data = await og_userResponse.json() @@ -356,7 +362,9 @@ export default function Posts({ keyPost }) { } try { - const userResponse = await fetch(`http://localhost:3001/api/users/${post.user_id}/data`) + const userResponse = await fetch( + `https://gamegrid-server.onrender.com/api/users/${post.user_id}/data` + ) const userData = await userResponse.json() if (userResponse.ok) { diff --git a/src/app/login/page.js b/src/app/login/page.js index e210334..599c1e8 100644 --- a/src/app/login/page.js +++ b/src/app/login/page.js @@ -20,7 +20,7 @@ export default function Login() { //delay for loading components await new Promise((resolve) => setTimeout(resolve, 2000)) - const response = await fetch(`http://localhost:3001/api/login/${input}`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/login/${input}`, { method: 'GET', headers: { 'Content-Type': 'application/json', diff --git a/src/app/register/page.js b/src/app/register/page.js index c9bc2c3..126ab7d 100644 --- a/src/app/register/page.js +++ b/src/app/register/page.js @@ -49,7 +49,7 @@ export default function Register() { } // שליחת בקשת POST לשרת - const response = await fetch(`http://localhost:3001/api/users/insert`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/users/insert`, { method: 'POST', headers: { 'Content-Type': 'application/json', From ba538e40de7b17a67dc2e4a94ae15f88c22131ee Mon Sep 17 00:00:00 2001 From: woozai Date: Sat, 17 Aug 2024 16:33:06 +0300 Subject: [PATCH 06/14] change --- src/app/HomePage/LeaderBoard/page.js | 2 +- src/app/HomePage/Profile/[id]/stats/page.js | 13 ++++++++----- src/app/components/HomeNav.js | 4 ++-- src/app/components/followButton.js | 18 ++++++++++++------ 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/app/HomePage/LeaderBoard/page.js b/src/app/HomePage/LeaderBoard/page.js index f0c1b3a..6148ef9 100644 --- a/src/app/HomePage/LeaderBoard/page.js +++ b/src/app/HomePage/LeaderBoard/page.js @@ -11,7 +11,7 @@ export default function LeaderBoard() { useEffect(() => { const fetchData = async () => { - const response = await fetch(`http://localhost:3001/api/users/leaderboard`) // Adjust the endpoint to your setup + const response = await fetch(`http://gamegrid-server.onrender.com/api/users/leaderboard`) // Adjust the endpoint to your setup const data = await response.json() setUsers(data.users) } diff --git a/src/app/HomePage/Profile/[id]/stats/page.js b/src/app/HomePage/Profile/[id]/stats/page.js index 031226d..e2e2536 100644 --- a/src/app/HomePage/Profile/[id]/stats/page.js +++ b/src/app/HomePage/Profile/[id]/stats/page.js @@ -11,16 +11,19 @@ export default function ProfileStats({ params }) { useEffect(() => { const fetchUserData = async () => { try { - const userResponse = await fetch(`http://localhost:3001/api/users/${params.id}/data`, { + const userResponse = await fetch(`http://gamegrid-server.onrender.com/api/users/${params.id}/data`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }) const user = await userResponse.json() - const postsResponse = await fetch(`http://localhost:3001/api/posts/${params.id}/posts`, { - method: 'GET', - headers: { 'Content-Type': 'application/json' }, - }) + const postsResponse = await fetch( + `http://gamegrid-server.onrender.com/api/posts/${params.id}/posts`, + { + method: 'GET', + headers: { 'Content-Type': 'application/json' }, + } + ) const posts = await postsResponse.json() if (userResponse.ok && postsResponse.ok) { diff --git a/src/app/components/HomeNav.js b/src/app/components/HomeNav.js index c1cdeba..98ce824 100644 --- a/src/app/components/HomeNav.js +++ b/src/app/components/HomeNav.js @@ -17,7 +17,7 @@ export const HomeNav = ({ userId }) => { const userResponse = async () => { try { if (userId) { - const response = await fetch(`http://localhost:3001/api/users/${userId}/data`) + const response = await fetch(`http://gamegrid-server.onrender.com/api/users/${userId}/data`) const userData = await response.json() if (response.ok) { @@ -35,7 +35,7 @@ export const HomeNav = ({ userId }) => { const handleSearch = async () => { try { const response = await fetch( - `http://localhost:3001/api/users/search?text=${encodeURIComponent(searchText)}` + `http://gamegrid-server.onrender.com/api/users/search?text=${encodeURIComponent(searchText)}` ) const searchData = await response.json() diff --git a/src/app/components/followButton.js b/src/app/components/followButton.js index ac55dd6..1df25b5 100644 --- a/src/app/components/followButton.js +++ b/src/app/components/followButton.js @@ -7,9 +7,12 @@ export default function FollowButton({ userId, followId, initialIsFollowing }) { const handleClick = async (followId) => { if (isFollowing) { try { - const response = await fetch(`http://localhost:3001/api/users/${userId}/${followId}/unfollow`, { - method: 'POST', - }) + const response = await fetch( + `http://gamegrid-server.onrender.com/api/users/${userId}/${followId}/unfollow`, + { + method: 'POST', + } + ) const data = await response.json() setIsFollowing(false) // Update the state } catch (error) { @@ -17,9 +20,12 @@ export default function FollowButton({ userId, followId, initialIsFollowing }) { } } else { try { - const response = await fetch(`http://localhost:3001/api/users/${userId}/${followId}/follow`, { - method: 'POST', - }) + const response = await fetch( + `http://gamegrid-server.onrender.com/api/users/${userId}/${followId}/follow`, + { + method: 'POST', + } + ) const data = await response.json() setIsFollowing(true) // Update the state } catch (error) { From 40aa4d993f26bb3ae9f6bdf5334406bc47c7ab33 Mon Sep 17 00:00:00 2001 From: woozai Date: Sat, 17 Aug 2024 16:48:35 +0300 Subject: [PATCH 07/14] changed to secure https --- src/app/HomePage/LeaderBoard/page.js | 2 +- src/app/HomePage/Profile/[id]/Like/page.js | 2 +- src/app/HomePage/Profile/[id]/Save/page.js | 2 +- src/app/HomePage/Profile/[id]/edit/page.js | 28 ++++++++----- src/app/HomePage/Profile/[id]/page.js | 4 +- src/app/HomePage/Profile/[id]/stats/page.js | 4 +- src/app/components/HomeNav.js | 4 +- src/app/components/followButton.js | 4 +- src/app/components/newPost.js | 4 +- src/app/components/posts.js | 45 +++++++++++---------- src/app/login/page.js | 2 +- src/app/register/page.js | 2 +- 12 files changed, 56 insertions(+), 47 deletions(-) diff --git a/src/app/HomePage/LeaderBoard/page.js b/src/app/HomePage/LeaderBoard/page.js index 6148ef9..9e93e83 100644 --- a/src/app/HomePage/LeaderBoard/page.js +++ b/src/app/HomePage/LeaderBoard/page.js @@ -11,7 +11,7 @@ export default function LeaderBoard() { useEffect(() => { const fetchData = async () => { - const response = await fetch(`http://gamegrid-server.onrender.com/api/users/leaderboard`) // Adjust the endpoint to your setup + const response = await fetch(`https://gamegrid-server.onrender.com/api/users/leaderboard`) // Adjust the endpoint to your setup const data = await response.json() setUsers(data.users) } diff --git a/src/app/HomePage/Profile/[id]/Like/page.js b/src/app/HomePage/Profile/[id]/Like/page.js index 283c7b8..56c9ec9 100644 --- a/src/app/HomePage/Profile/[id]/Like/page.js +++ b/src/app/HomePage/Profile/[id]/Like/page.js @@ -10,7 +10,7 @@ export default function ProfileLike({ params }) { useEffect(() => { const fetchUserData = async () => { try { - const response = await fetch(`http://gamegrid-server.onrender.com/api/users/${params.id}/data`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/users/${params.id}/data`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }) diff --git a/src/app/HomePage/Profile/[id]/Save/page.js b/src/app/HomePage/Profile/[id]/Save/page.js index 43eb23e..0b7f860 100644 --- a/src/app/HomePage/Profile/[id]/Save/page.js +++ b/src/app/HomePage/Profile/[id]/Save/page.js @@ -11,7 +11,7 @@ export default function ProfileSave({ params }) { useEffect(() => { const fetchUserData = async () => { try { - const response = await fetch(`http://gamegrid-server.onrender.com/api/users/${params.id}/data`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/users/${params.id}/data`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }) diff --git a/src/app/HomePage/Profile/[id]/edit/page.js b/src/app/HomePage/Profile/[id]/edit/page.js index f265a2b..544f864 100644 --- a/src/app/HomePage/Profile/[id]/edit/page.js +++ b/src/app/HomePage/Profile/[id]/edit/page.js @@ -34,7 +34,7 @@ export default function ProfilePage({ params }) { useEffect(() => { const fetchUserData = async () => { try { - const userResponse = await fetch(`http://gamegrid-server.onrender.com/api/users/${params.id}/data`, { + const userResponse = await fetch(`https://gamegrid-server.onrender.com/api/users/${params.id}/data`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }) @@ -89,7 +89,7 @@ export default function ProfilePage({ params }) { const inputPassword = document.getElementById('passwordInput') let userPassword = '' try { - const response = await fetch(`http://gamegrid-server.onrender.com/api/users/${params.id}/data`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/users/${params.id}/data`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }) @@ -103,7 +103,7 @@ export default function ProfilePage({ params }) { } if (inputPassword.value === userPassword) { try { - const response = await fetch(`http://gamegrid-server.onrender.com/api/users/${params.id}/delete`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/users/${params.id}/delete`, { method: 'DELETE', headers: { 'Content-Type': 'application/json' }, }) @@ -138,9 +138,12 @@ export default function ProfilePage({ params }) { reader.readAsDataURL(file) } const deleteAvatar = async () => { - const response = await fetch(`http://gamegrid-server.onrender.com/api/users/${params.id}/avatar/remove`, { - method: 'DELETE', - }) + const response = await fetch( + `https://gamegrid-server.onrender.com/api/users/${params.id}/avatar/remove`, + { + method: 'DELETE', + } + ) if (response.ok) { uploadAvatar() } @@ -149,10 +152,13 @@ export default function ProfilePage({ params }) { const formData = new FormData() formData.append('image', userData.avatar) - const response = await fetch(`http://gamegrid-server.onrender.com/api/users/${params.id}/avatar/upload`, { - method: 'POST', - body: formData, - }) + const response = await fetch( + `https://gamegrid-server.onrender.com/api/users/${params.id}/avatar/upload`, + { + method: 'POST', + body: formData, + } + ) const data = await response.json() @@ -247,7 +253,7 @@ export default function ProfilePage({ params }) { window.location.href = '/HomePage/Profile/' + params.id } - const response = await fetch(`http://gamegrid-server.onrender.com/api/users/${params.id}/update`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/users/${params.id}/update`, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/src/app/HomePage/Profile/[id]/page.js b/src/app/HomePage/Profile/[id]/page.js index 4a868c0..4999c90 100644 --- a/src/app/HomePage/Profile/[id]/page.js +++ b/src/app/HomePage/Profile/[id]/page.js @@ -18,11 +18,11 @@ export default function ProfilePage({ params }) { setUserId(id) try { const [userResponse, followingResponse] = await Promise.all([ - fetch(`http://gamegrid-server.onrender.com/api/users/${params.id}/data`, { + fetch(`https://gamegrid-server.onrender.com/api/users/${params.id}/data`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }), - fetch(`http://gamegrid-server.onrender.com/api/users/${params.id}/list/following`, { + fetch(`https://gamegrid-server.onrender.com/api/users/${params.id}/list/following`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }), diff --git a/src/app/HomePage/Profile/[id]/stats/page.js b/src/app/HomePage/Profile/[id]/stats/page.js index e2e2536..dc809be 100644 --- a/src/app/HomePage/Profile/[id]/stats/page.js +++ b/src/app/HomePage/Profile/[id]/stats/page.js @@ -11,14 +11,14 @@ export default function ProfileStats({ params }) { useEffect(() => { const fetchUserData = async () => { try { - const userResponse = await fetch(`http://gamegrid-server.onrender.com/api/users/${params.id}/data`, { + const userResponse = await fetch(`https://gamegrid-server.onrender.com/api/users/${params.id}/data`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }) const user = await userResponse.json() const postsResponse = await fetch( - `http://gamegrid-server.onrender.com/api/posts/${params.id}/posts`, + `https://gamegrid-server.onrender.com/api/posts/${params.id}/posts`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, diff --git a/src/app/components/HomeNav.js b/src/app/components/HomeNav.js index 98ce824..006d61f 100644 --- a/src/app/components/HomeNav.js +++ b/src/app/components/HomeNav.js @@ -17,7 +17,7 @@ export const HomeNav = ({ userId }) => { const userResponse = async () => { try { if (userId) { - const response = await fetch(`http://gamegrid-server.onrender.com/api/users/${userId}/data`) + const response = await fetch(`https://gamegrid-server.onrender.com/api/users/${userId}/data`) const userData = await response.json() if (response.ok) { @@ -35,7 +35,7 @@ export const HomeNav = ({ userId }) => { const handleSearch = async () => { try { const response = await fetch( - `http://gamegrid-server.onrender.com/api/users/search?text=${encodeURIComponent(searchText)}` + `https://gamegrid-server.onrender.com/api/users/search?text=${encodeURIComponent(searchText)}` ) const searchData = await response.json() diff --git a/src/app/components/followButton.js b/src/app/components/followButton.js index 1df25b5..5aa24db 100644 --- a/src/app/components/followButton.js +++ b/src/app/components/followButton.js @@ -8,7 +8,7 @@ export default function FollowButton({ userId, followId, initialIsFollowing }) { if (isFollowing) { try { const response = await fetch( - `http://gamegrid-server.onrender.com/api/users/${userId}/${followId}/unfollow`, + `https://gamegrid-server.onrender.com/api/users/${userId}/${followId}/unfollow`, { method: 'POST', } @@ -21,7 +21,7 @@ export default function FollowButton({ userId, followId, initialIsFollowing }) { } else { try { const response = await fetch( - `http://gamegrid-server.onrender.com/api/users/${userId}/${followId}/follow`, + `https://gamegrid-server.onrender.com/api/users/${userId}/${followId}/follow`, { method: 'POST', } diff --git a/src/app/components/newPost.js b/src/app/components/newPost.js index 8aa55e5..21c6143 100644 --- a/src/app/components/newPost.js +++ b/src/app/components/newPost.js @@ -52,7 +52,7 @@ export default function NewPost() { return } - const response = await fetch(`http://gamegrid-server.onrender.com/api/posts/${userId}/post/insert`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/posts/${userId}/post/insert`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -67,7 +67,7 @@ export default function NewPost() { ImageData.append('image', imageFile) const imageResponse = await fetch( - `http://gamegrid-server.onrender.com/api/posts/${data.post_id}/files/upload`, + `https://gamegrid-server.onrender.com/api/posts/${data.post_id}/files/upload`, { method: 'POST', body: ImageData, diff --git a/src/app/components/posts.js b/src/app/components/posts.js index 17eebd9..dd3ea45 100644 --- a/src/app/components/posts.js +++ b/src/app/components/posts.js @@ -24,7 +24,7 @@ export default function Posts({ keyPost, item = null, category = null }) { try { if (keyPost === 'following') { const response = await fetch( - `http://gamegrid-server.onrender.com/api/posts/${userId}/${keyPost}/posts`, + `https://gamegrid-server.onrender.com/api/posts/${userId}/${keyPost}/posts`, { method: 'GET', headers: { @@ -40,7 +40,7 @@ export default function Posts({ keyPost, item = null, category = null }) { } if (keyPost === 'all') { - const response = await fetch(`http://gamegrid-server.onrender.com/api/posts/${keyPost}posts`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/posts/${keyPost}posts`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -83,7 +83,7 @@ export default function Posts({ keyPost, item = null, category = null }) { } if (keyPost === 'MyPost') { - const response = await fetch(`http://gamegrid-server.onrender.com/api/posts/${userId}/posts`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/posts/${userId}/posts`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -98,7 +98,7 @@ export default function Posts({ keyPost, item = null, category = null }) { } } if (keyPost === 'MySaved') { - const response = await fetch(`http://gamegrid-server.onrender.com/api/posts/${userId}/saved`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/posts/${userId}/saved`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -113,7 +113,7 @@ export default function Posts({ keyPost, item = null, category = null }) { } if (keyPost === 'MyLiked') { - const response = await fetch(`http://gamegrid-server.onrender.com/api/posts/${userId}/liked`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/posts/${userId}/liked`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -127,7 +127,7 @@ export default function Posts({ keyPost, item = null, category = null }) { } else { } } else if (keyPost !== 'all' && keyPost !== 'MySaved') { - const response = await fetch(`http://gamegrid-server.onrender.com/api/posts/${keyPost}/posts`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/posts/${keyPost}/posts`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -184,15 +184,18 @@ export default function Posts({ keyPost, item = null, category = null }) { if (isSaved) { // User already saved the post, remove the save - response = await fetch(`http://gamegrid-server.onrender.com/api/posts/${post._id}/${userId}/unsave`, { - method: 'DELETE', - headers: { - 'Content-Type': 'application/json', - }, - }) + response = await fetch( + `https://gamegrid-server.onrender.com/api/posts/${post._id}/${userId}/unsave`, + { + method: 'DELETE', + headers: { + 'Content-Type': 'application/json', + }, + } + ) } else { // User has not saved the post yet, add the save - response = await fetch(`http://gamegrid-server.onrender.com/api/posts/${post._id}/${userId}/save`, { + response = await fetch(`https://gamegrid-server.onrender.com/api/posts/${post._id}/${userId}/save`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -247,7 +250,7 @@ export default function Posts({ keyPost, item = null, category = null }) { } } - const response = await fetch(`http://gamegrid-server.onrender.com/api/posts/${userId}/post/share`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/posts/${userId}/post/share`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -277,7 +280,7 @@ export default function Posts({ keyPost, item = null, category = null }) { const handleDeleteClick = async (postId) => { try { - const response = await fetch(`http://gamegrid-server.onrender.com/api/posts/${postId}/post/delete`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/posts/${postId}/post/delete`, { method: 'DELETE', }) if (response.ok) { @@ -305,7 +308,7 @@ export default function Posts({ keyPost, item = null, category = null }) { const handleSaveEdit = async (index) => { const post = updatedPosts[index] try { - const response = await fetch(`http://gamegrid-server.onrender.com/api/posts/${post._id}/post/update`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/posts/${post._id}/post/update`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ @@ -350,7 +353,7 @@ export default function Posts({ keyPost, item = null, category = null }) { // User already liked the post, remove the like try { const response = await fetch( - `http://gamegrid-server.onrender.com/api/posts/${posts[postIndex]._id}/${userId}/unlike`, + `https://gamegrid-server.onrender.com/api/posts/${posts[postIndex]._id}/${userId}/unlike`, { method: 'GET', headers: { @@ -373,7 +376,7 @@ export default function Posts({ keyPost, item = null, category = null }) { // Send the updated like status to the server try { const response = await fetch( - `http://gamegrid-server.onrender.com/api/posts/${posts[postIndex]._id}/${userId}/like`, + `https://gamegrid-server.onrender.com/api/posts/${posts[postIndex]._id}/${userId}/like`, { method: 'GET', headers: { @@ -406,7 +409,7 @@ export default function Posts({ keyPost, item = null, category = null }) { if (post?.shared) { try { const response = await fetch( - `http://gamegrid-server.onrender.com/api/posts/${post.shared_post.original_post}/post`, + `https://gamegrid-server.onrender.com/api/posts/${post.shared_post.original_post}/post`, { method: 'GET', headers: { @@ -432,7 +435,7 @@ export default function Posts({ keyPost, item = null, category = null }) { try { const og_userResponse = await fetch( - `http://gamegrid-server.onrender.com/api/users/${post.shared_post.original_owner}/data` + `https://gamegrid-server.onrender.com/api/users/${post.shared_post.original_owner}/data` ) const original_data = await og_userResponse.json() @@ -450,7 +453,7 @@ export default function Posts({ keyPost, item = null, category = null }) { try { const userResponse = await fetch( - `http://gamegrid-server.onrender.com/api/users/${post.user_id}/data` + `https://gamegrid-server.onrender.com/api/users/${post.user_id}/data` ) const userData = await userResponse.json() diff --git a/src/app/login/page.js b/src/app/login/page.js index 3440882..be0e5e1 100644 --- a/src/app/login/page.js +++ b/src/app/login/page.js @@ -22,7 +22,7 @@ export default function Login() { //delay for loading components // await new Promise((resolve) => setTimeout(resolve, 2000)) // שליחת בקשת POST לשרת - const response = await fetch(`http://gamegrid-server.onrender.com/api/login/${input}`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/login/${input}`, { method: 'GET', headers: { 'Content-Type': 'application/json', diff --git a/src/app/register/page.js b/src/app/register/page.js index 9b23f4f..d08e944 100644 --- a/src/app/register/page.js +++ b/src/app/register/page.js @@ -67,7 +67,7 @@ export default function Register() { return } // שליחת בקשת POST לשרת - const response = await fetch(`http://gamegrid-server.onrender.com/api/users/insert`, { + const response = await fetch(`https://gamegrid-server.onrender.com/api/users/insert`, { method: 'POST', headers: { 'Content-Type': 'application/json', From 15d5f6db10432265ab7b8b4da3f5ccd14d211dfb Mon Sep 17 00:00:00 2001 From: woozai Date: Sat, 17 Aug 2024 18:10:06 +0300 Subject: [PATCH 08/14] fix bugs --- src/app/HomePage/Profile/[id]/edit/page.js | 13 +++++++---- src/app/components/HomeNav.js | 27 +++------------------- src/app/components/newPost.js | 1 - 3 files changed, 12 insertions(+), 29 deletions(-) diff --git a/src/app/HomePage/Profile/[id]/edit/page.js b/src/app/HomePage/Profile/[id]/edit/page.js index 544f864..93364c2 100644 --- a/src/app/HomePage/Profile/[id]/edit/page.js +++ b/src/app/HomePage/Profile/[id]/edit/page.js @@ -3,7 +3,7 @@ import { useState, useEffect } from 'react' import Head from 'next/head' import LoadingOverlay from '@/app/components/loading' import AlertDialog from '@/app/components/Alerts' - +import { logoutbtn } from '../../../../actions' export default function ProfilePage({ params }) { const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) @@ -101,6 +101,8 @@ export default function ProfilePage({ params }) { } catch (error) { console.error('Error ', error) } + console.log('1 ', inputPassword.value) + console.log('2 ', userPassword) if (inputPassword.value === userPassword) { try { const response = await fetch(`https://gamegrid-server.onrender.com/api/users/${params.id}/delete`, { @@ -108,12 +110,15 @@ export default function ProfilePage({ params }) { headers: { 'Content-Type': 'application/json' }, }) const data = await response.json() - if (response.ok) { document.getElementById('confirm_modal').close() document.getElementById('alert-success').showModal() await sleep(2000) - window.location.href = '/' + console.log('1 waddadw ') + logoutbtn().then(async () => { + console.log('2 waddadw ') + window.location.href = '/' + }) } } catch (error) { console.error('Error deleting user data:', error) @@ -226,7 +231,7 @@ export default function ProfilePage({ params }) { return } } - if (!inURL.value !== '') { + if (inURL.value !== '') { if (await !isValidUrl(inURL.value)) { inURL.placeholder = 'URL not valid' inURL.value = '' diff --git a/src/app/components/HomeNav.js b/src/app/components/HomeNav.js index 006d61f..b90c674 100644 --- a/src/app/components/HomeNav.js +++ b/src/app/components/HomeNav.js @@ -50,7 +50,6 @@ export const HomeNav = ({ userId }) => { } const handleLogout = () => { toast.success('Logged out successfully') - logoutbtn().then(() => { window.location.href = '/' }) @@ -144,29 +143,9 @@ export const HomeNav = ({ userId }) => { - - -
-
-
+
+
+
User avatar
diff --git a/src/app/components/newPost.js b/src/app/components/newPost.js index 21c6143..0fb09b7 100644 --- a/src/app/components/newPost.js +++ b/src/app/components/newPost.js @@ -88,7 +88,6 @@ export default function NewPost() { image: null, }) setImagePreview(null) // Clear the image preview - alert(JSON.stringify(data)) location.reload() } else { alert(JSON.stringify(data)) From 8ebf10aebf8b288c0505d0d3f40d0df8b88eb363 Mon Sep 17 00:00:00 2001 From: woozai Date: Sat, 17 Aug 2024 18:11:08 +0300 Subject: [PATCH 09/14] remove console log --- src/app/HomePage/Profile/[id]/edit/page.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/app/HomePage/Profile/[id]/edit/page.js b/src/app/HomePage/Profile/[id]/edit/page.js index 93364c2..fa96d11 100644 --- a/src/app/HomePage/Profile/[id]/edit/page.js +++ b/src/app/HomePage/Profile/[id]/edit/page.js @@ -114,9 +114,7 @@ export default function ProfilePage({ params }) { document.getElementById('confirm_modal').close() document.getElementById('alert-success').showModal() await sleep(2000) - console.log('1 waddadw ') logoutbtn().then(async () => { - console.log('2 waddadw ') window.location.href = '/' }) } From f521c73a252dc962b88c13c15b09cd5759a36917 Mon Sep 17 00:00:00 2001 From: woozai Date: Sun, 18 Aug 2024 02:02:53 +0300 Subject: [PATCH 10/14] new notification --- src/app/components/HomeNav.js | 24 +++++++++++++++--------- src/app/components/followButton.js | 2 +- src/app/components/posts.js | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/app/components/HomeNav.js b/src/app/components/HomeNav.js index fa7a063..10f8d0f 100644 --- a/src/app/components/HomeNav.js +++ b/src/app/components/HomeNav.js @@ -27,10 +27,13 @@ export const HomeNav = ({ userId }) => { if (response.ok) { setUsername(userData.nickname) setAvatarPreview(userData.avatar) - const userResponse = await fetch(`http://localhost:3001/api/users/${userId}/data`, { - method: 'GET', - headers: { 'Content-Type': 'application/json' }, - }) + const userResponse = await fetch( + `https://gamegrid-server.onrender.com/api/users/${userId}/data`, + { + method: 'GET', + headers: { 'Content-Type': 'application/json' }, + } + ) const user = await userResponse.json() const notList = user.notification.map((notification) => notification.message) setNotifyList(notList) @@ -92,7 +95,7 @@ export const HomeNav = ({ userId }) => { const toggleDropdown = async () => { try { - const userResponse = await fetch(`http://localhost:3001/api/users/${userId}/data`, { + const userResponse = await fetch(`https://gamegrid-server.onrender.com/api/users/${userId}/data`, { method: 'GET', headers: { 'Content-Type': 'application/json' }, }) @@ -111,10 +114,13 @@ export const HomeNav = ({ userId }) => { const clearNotification = async () => { try { - const response = await fetch(`http://localhost:3001/api/users/${userId}/notification/clear`, { - method: 'DELETE', - headers: { 'Content-Type': 'application/json' }, - }) + const response = await fetch( + `https://gamegrid-server.onrender.com/api/users/${userId}/notification/clear`, + { + method: 'DELETE', + headers: { 'Content-Type': 'application/json' }, + } + ) setNumNotify(0) } catch (error) { console.error(error) diff --git a/src/app/components/followButton.js b/src/app/components/followButton.js index 8cb9d71..197c8d5 100644 --- a/src/app/components/followButton.js +++ b/src/app/components/followButton.js @@ -29,7 +29,7 @@ export default function FollowButton({ userId, followId, initialIsFollowing }) { const data = await response.json() setIsFollowing(true) // Update the state const responseNotify = await fetch( - `http://localhost:3001/api/users/${followId}/${userId}/notification/follow`, + `https://gamegrid-server.onrender.com/api/users/${followId}/${userId}/notification/follow`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, diff --git a/src/app/components/posts.js b/src/app/components/posts.js index f0cc918..098f896 100644 --- a/src/app/components/posts.js +++ b/src/app/components/posts.js @@ -22,7 +22,7 @@ export default function Posts({ keyPost, item = null, category = null }) { async function sendNotification(user, clickedId, notType) { const response2 = await fetch( - `http://localhost:3001/api/users/${user}/${clickedId}/notification/${notType}`, + `https://gamegrid-server.onrender.com/api/users/${user}/${clickedId}/notification/${notType}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, From cad6c77cfdb79e39db65d8546addcd0697230b8a Mon Sep 17 00:00:00 2001 From: woozai Date: Sun, 18 Aug 2024 02:14:19 +0300 Subject: [PATCH 11/14] nfe --- src/app/components/HomeNav.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/HomeNav.js b/src/app/components/HomeNav.js index 10f8d0f..3a4b5ef 100644 --- a/src/app/components/HomeNav.js +++ b/src/app/components/HomeNav.js @@ -130,7 +130,7 @@ export const HomeNav = ({ userId }) => { return ( <> -
+
Logo From 78595882a33aa3ebbe38b7d64d4e992f0ace8698 Mon Sep 17 00:00:00 2001 From: kobia77 Date: Sun, 18 Aug 2024 10:38:48 +0300 Subject: [PATCH 12/14] hotfix on focus --- src/app/components/HomeNav.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/HomeNav.js b/src/app/components/HomeNav.js index d143ee1..6bc1ad6 100644 --- a/src/app/components/HomeNav.js +++ b/src/app/components/HomeNav.js @@ -198,7 +198,7 @@ export const HomeNav = ({ userId }) => {
-
+
-
+