Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Auth Improvement #93

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6134d20
added cred to env
shashank21raj Jul 17, 2024
8d2aa04
Merge branch 'dev-priyanshu' into dev-raj
shashank21raj Jul 17, 2024
cb736a7
Merge branch 'main' into dev-raj
shashank21raj Jul 17, 2024
e6d550c
google auth improvements
shashank21raj Jul 29, 2024
f6b980e
minor commit
shashank21raj Jul 29, 2024
c9a701a
minor changes
shashank21raj Jul 29, 2024
e7a87e5
Merge branch 'main' into dev-raj
shashank21raj Jul 30, 2024
860d83a
Intoduction of single post page
Akangkha Jul 30, 2024
69602dd
Fixed the minor ui issues
Akangkha Jul 30, 2024
91b137a
Merge pull request #96 from iot-lab-kiit/akangkha-final
Akangkha Jul 30, 2024
80843ce
handlePostClick change
KudoAkinichi Jul 30, 2024
7c4e961
not found page
KudoAkinichi Jul 30, 2024
299a428
improvement in community page
JATIN0926 Jul 30, 2024
6a53000
Merge pull request #97 from KudoAkinichi/main
Akangkha Jul 30, 2024
cae9a25
Lock file updated
kpriyanshu2003 Jul 30, 2024
273b0d3
Merge branch 'develop' of https://github.com/iot-lab-kiit/intern-fair…
Akangkha Jul 30, 2024
9d81040
added the error page
Akangkha Jul 30, 2024
5105cea
Merge branch 'main' into main
JATIN0926 Jul 30, 2024
4820342
Merge pull request #98 from JATIN0926/main
Akangkha Jul 30, 2024
31b502e
Merge branch 'main' of https://github.com/iot-lab-kiit/intern-fair in…
Akangkha Jul 30, 2024
aec0635
Fixed Backend Functions
kpriyanshu2003 Jul 30, 2024
90dd83f
Merge branch 'develop' of https://github.com/iot-lab-kiit/intern-fair…
Akangkha Jul 30, 2024
751cf79
Update in folder structure
kpriyanshu2003 Jul 30, 2024
7d48a7c
Removed Useless Packages
kpriyanshu2003 Jul 30, 2024
59cd498
Fixed Logins
kpriyanshu2003 Jul 30, 2024
7e5d3e5
Ui changes
Akangkha Jul 30, 2024
eb9da1e
Added a feature in Login
kpriyanshu2003 Jul 30, 2024
b7c3200
minor ui changes
Akangkha Jul 30, 2024
e8e7002
update branch
Akangkha Jul 30, 2024
dc3eedf
update branch
Akangkha Jul 30, 2024
197c9dc
minor: update ui components
Akangkha Jul 30, 2024
06280af
Merge branch 'develop' into dev-raj
shashank21raj Aug 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# InternFair
# GuideLy

**InternFair** is a web application designed to help students learn and get guidance in various domains such as web development, app development, competitive programming (CP), machine learning (ML), information technology (IT), and more. It also harbors the legacy our IoT Lab holds.
**GuideLy** is a web application designed to help students learn and get guidance in various domains such as web development, app development, competitive programming (CP), machine learning (ML), information technology (IT), and more. It also harbors the legacy our IoT Lab holds.
![image](https://github.com/user-attachments/assets/0d615fc7-7d60-4d78-bdfe-4a4ca3c44f0b)


Expand Down
8 changes: 7 additions & 1 deletion client/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
DIRECTUS_URL=__directus_url__
TOKEN=__token__
USER_ROLE=__user_role__
USER_ROLE=__user_role__
API_KEY=__api_key__
AUTH_DOMAIN=__auth_domain__
PROJECT_ID=__project_id__
STORAGE_BUCKET=__storage_bucket__
MESSAGE_SENDER_ID=__message_sender__
APP_ID=__app_id__
6 changes: 1 addition & 5 deletions client/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{
"compilerOptions": {
"paths": {
"@/*": ["./src/*"]
}
}
"compilerOptions": { "paths": { "@/*": ["./src/*"] } }
}
23 changes: 3 additions & 20 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,27 @@
"@babel/core": "^7.24.0",
"@digitalocean/do-markdownit": "^1.14.0",
"@directus/sdk": "^15.0.3",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.0",
"@headlessui/react": "^1.7.18",
"@mui/icons-material": "^5.15.12",
"@mui/material": "^5.15.12",
"@nextui-org/react": "^2.2.10",
"@nextui-org/system": "^2.2.2",
"all": "^0.0.0",
"aws4": "^1.12.0",
"@nextui-org/react": "^2.4.6",
"clipboard": "^2.0.11",
"date-fns": "^3.6.0",
"embla-carousel": "^8.0.0",
"embla-carousel-react": "^8.0.0",
"firebase": "^10.12.3",
"firebase": "^10.12.4",
"framer-motion": "^11.0.20",
"fuse.js": "^7.0.0",
"highlight.js": "^11.9.0",
"js-cookie": "^3.0.5",
"jwt-decode": "^4.0.0",
"lucide-react": "^0.396.0",
"markdown-it": "^14.1.0",
"mongoose": "^8.2.1",
"next": "14.1.0",
"react": "^18",
"react-dom": "^18",
"react-hot-toast": "^2.4.1",
"react-html-parser": "^2.0.2",
"react-icons": "^5.2.1",
"react-infinite-scroll-component": "^6.1.0",
"react-intersection-observer": "^9.10.3",
"react-markdown": "^9.0.1",
"react-select": "^5.8.0",
"react-toastify": "^10.0.5",
"react-web-share": "^2.0.2",
"react-youtube": "^10.1.0",
"sharp": "^0.33.3",
"swiper": "^11.0.7",
"uuid": "^9.0.1"
"swiper": "^11.0.7"
},
"devDependencies": {
"autoprefixer": "^10.0.1",
Expand Down
113 changes: 34 additions & 79 deletions client/src/actions/post.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
"use server";
import { clientToken } from "@/db/directus";

import {
createItem,
updateItem,
updateItems,
deleteItem,
readItem,
readItems,
uploadFiles,
updateFile,
readUser,
} from "@directus/sdk";

import { cookies } from "next/headers";
import { clientToken } from "@/config/directus";

const validateData = (data) => {
if (!data.content || !data.tag)
throw new Error([{ message: "Missing Required Fields: Content, Tags" }]);

if (typeof data.content !== "string")
throw new Error([{ message: "Content must be a string" }]);

if (
!Array.isArray(data.tag) ||
!data.tag.every((tag) => typeof tag == "string")
)
throw new Error([{ message: "Tags must be an array of String" }]);
};

// Create POST
export const createPost = async (data, formData) => {
try {
const user_token = cookies().get("user_session").value;
Expand All @@ -38,13 +21,11 @@ export const createPost = async (data, formData) => {
uploadFiles(formData)
);

if (!fileUploadResponse.id) {
throw new Error("File upload failed");
}
if (!fileUploadResponse.id) throw new Error("File upload failed");

const updateResponse = await clientToken(user_token).request(
updateFile(fileUploadResponse.id, {
location: "46e88712-846e-4e1d-af06-0a907aa5e04a",
location: "e8ac07d7-1503-41f6-bd0e-6528c9301ac7",
})
);

Expand All @@ -67,26 +48,23 @@ export const createPost = async (data, formData) => {
result: postResponse,
};
} catch (e) {
console.error("Error in createPost:", e);
throw new Error(e.errors?.[0]?.message || e.message);
console.error(e);
// throw new Error(e.errors?.[0]?.message || e.message);
}
};

// Get All POST
export const getAllPost = async (offset, POSTS_PER_PAGE) => {
try {
const user_token = cookies().get("user_session").value;
const result = await clientToken(process.env.TOKEN).request(
const result = await clientToken(user_token).request(
readItems("Post", {
fields: [
"id",
"content",
"tag",
"image",
"date_created",
{
user_created: ["id", "first_name", "last_name", "email"],
},
{ user_created: ["id", "first_name", "last_name", "email"] },
"likes",
{
likesUserCollection: [
Expand All @@ -101,42 +79,41 @@ export const getAllPost = async (offset, POSTS_PER_PAGE) => {
},
],
offset: parseInt(offset),
limit: parseInt(POSTS_PER_PAGE), // Limit for pagination
limit: parseInt(POSTS_PER_PAGE),
})
);

if (!result) throw new Error([{ message: "No post found" }]);

return { success: true, message: "Found All Post", result: result };
} catch (error) {
console.log(error);
// throw new Error(e.errors[0].message || e.message);
} catch (e) {
console.error(e);
// throw new Error(e.errors?.[0]?.message || e.message);
}
};

// Get POST By Id
export const getPostById = async (data) => {
try {
const user_token = cookies().get("user_session").value;
console.log("data:", data);
const result = await clientToken(process.env.TOKEN).request(
"data:", data;
const result = await clientToken(user_token).request(
readItem("Post", data.id, {
likesUserCollection: data.likedBy,
})
);
if (!result) throw new Error([{ message: "No post found with that id" }]);
return { success: true, message: "Post with the Id", result };
} catch (e) {
throw new Error(e.errors[0].message || e.message);
console.error(e);
// throw new Error(e.errors?.[0]?.message || e.message);
}
};

// Update POst
export const updatePost = async (data) => {
try {
const user_token = cookies().get("user_session").value;
data = JSON.parse(data);
console.log(data);
const result = await clientToken(process.env.TOKEN).request(
const result = await clientToken(user_token).request(
updateItem("Post", data.id, {
content: data.content,
tag: data.tag,
Expand All @@ -148,18 +125,17 @@ export const updatePost = async (data) => {
if (!result) throw new Error([{ message: "Post Not updated" }]);
return { success: true, message: "Post Updated successfully", result };
} catch (e) {
console.log(e);
// throw new Error(e.errors[0].message || e.message);
console.error(e);
// throw new Error(e.errors?.[0]?.message || e.message);
}
};

export const updateLikes = async (data) => {
try {
const user_token = cookies().get("user_session").value;
data = JSON.parse(data);
console.log(data);

const post = await clientToken(process.env.TOKEN).request(
const post = await clientToken(user_token).request(
readItem("Post", data.id, {
fields: [
{
Expand All @@ -171,19 +147,14 @@ export const updateLikes = async (data) => {
})
);

console.log(post);

let likedBy = post.likesUserCollection.map(
(like) => like.directus_users_id.id
);

if (!likedBy.includes(data.userID)) {
likedBy.push(data.userID);
} else {
likedBy = likedBy.filter((user) => user !== data.userID);
}
if (!likedBy.includes(data.userID)) likedBy.push(data.userID);
else likedBy = likedBy.filter((user) => user !== data.userID);

const result = await clientToken(process.env.TOKEN).request(
const result = await clientToken(user_token).request(
updateItem("Post", data.id, {
likesUserCollection: likedBy.map((userId) => ({
directus_users_id: { id: userId },
Expand All @@ -193,25 +164,25 @@ export const updateLikes = async (data) => {
})
);

console.log(result);
if (!result) throw new Error([{ message: "liked" }]);
return { success: true, message: "Post liked successfully", result };
} catch (error) {
console.log(error);
} catch (e) {
console.error(e);
// throw new Error(e.errors?.[0]?.message || e.message);
}
};

export const updateShare = async (data) => {
try {
const user_token = cookies().get("user_session").value;
data = JSON.parse(data);
// console.log("data: ", data);
const user = await clientToken(process.env.TOKEN).request(

const user = await clientToken(user_token).request(
readUser(data.userID, {
fields: ["id", "first_name", "last_name", "email"],
})
);
console.log("user", user);
const post = await clientToken(process.env.TOKEN).request(
const post = await clientToken(user_token).request(
readItem("Post", data.id, {
fields: [
{
Expand All @@ -231,7 +202,7 @@ export const updateShare = async (data) => {
existingShareUsers.push({ id: data.userID });
}

const result = await clientToken(process.env.TOKEN).request(
const result = await clientToken(user_token).request(
updateItem("Post", data.id, {
share: existingShareUsers.length,
shareUserCollection: existingShareUsers.map((user) => ({
Expand All @@ -240,24 +211,8 @@ export const updateShare = async (data) => {
})),
})
);
console.log("result", result);
} catch (e) {
console.log(e);
// console.error(e.errors[0].message);
console.error(e);
// throw new Error(e.errors?.[0]?.message || e.message);
}
};

// Delete POST
// export const deletePost = async (data) => {
// try {
// if (!data.id) throw new Error([{ message: "Please provide the id" }]);

// const result = await clientToken(user_token).request(
// deleteItem("Post", data.id)
// );
// if (!result) throw new Error([{ message: "Post Not Deleted" }]);
// return { success: true, message: "Post Deleted successfully", result };
// } catch (e) {
// throw new Error(e.errors[0].message || e.message);
// }
// };
Loading