diff --git a/SETUP.md b/SETUP.md index 76ed216be..b4442a44c 100644 --- a/SETUP.md +++ b/SETUP.md @@ -56,12 +56,12 @@ Open two terminals: Backend: ```bash -npm run server +npm run backend ``` Frontend: ```bash -npm run dev +npm run frontend ``` --- @@ -99,7 +99,7 @@ You do not need to set `MONGODB_URL` or run the backend. #### 4. Start the frontend ```bash -npm run dev +npm run frontend ``` Your app will connect directly to the deployed backend. diff --git a/frontend/.env.example b/client/.env.example similarity index 100% rename from frontend/.env.example rename to client/.env.example diff --git a/frontend/.vercelignore b/client/.vercelignore similarity index 100% rename from frontend/.vercelignore rename to client/.vercelignore diff --git a/frontend/eslint.config.js b/client/eslint.config.js similarity index 100% rename from frontend/eslint.config.js rename to client/eslint.config.js diff --git a/frontend/index.html b/client/index.html similarity index 84% rename from frontend/index.html rename to client/index.html index 784d71fac..c8fb44594 100644 --- a/frontend/index.html +++ b/client/index.html @@ -10,7 +10,7 @@
- + \ No newline at end of file diff --git a/frontend/package-lock.json b/client/package-lock.json similarity index 99% rename from frontend/package-lock.json rename to client/package-lock.json index cb8a8ac40..b2683e322 100644 --- a/frontend/package-lock.json +++ b/client/package-lock.json @@ -1,11 +1,11 @@ { - "name": "frontend", + "name": "client", "version": "1.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "frontend", + "name": "client", "version": "1.1.1", "license": "ISC", "dependencies": { @@ -44,6 +44,7 @@ "eslint-plugin-react-hooks": "^5.1.0", "eslint-plugin-react-refresh": "^0.4.19", "globals": "^15.15.0", + "typescript": "^5.9.2", "vite": "^6.2.0" } }, @@ -4254,6 +4255,20 @@ "node": ">= 0.8.0" } }, + "node_modules/typescript": { + "version": "5.9.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.2.tgz", + "integrity": "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/undici-types": { "version": "6.20.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", diff --git a/frontend/package.json b/client/package.json similarity index 93% rename from frontend/package.json rename to client/package.json index 5e7d3b079..9e6a4897f 100644 --- a/frontend/package.json +++ b/client/package.json @@ -1,5 +1,5 @@ { - "name": "frontend", + "name": "client", "author": "Avdhesh Varshney", "license": "ISC", "description": "Code A2Z is a collaborative blogging platform for developers and writers to create, manage, and share projects with markdown support, customizable templates, and community contributions.", @@ -16,7 +16,8 @@ "private": true, "scripts": { "dev": "vite", - "build": "vite build", + "build": "tsc --noEmit && vite build", + "type-check": "tsc --noEmit", "lint": "eslint .", "preview": "vite preview" }, @@ -56,6 +57,7 @@ "eslint-plugin-react-hooks": "^5.1.0", "eslint-plugin-react-refresh": "^0.4.19", "globals": "^15.15.0", + "typescript": "^5.9.2", "vite": "^6.2.0" } } diff --git a/frontend/public/404.png b/client/public/404.png similarity index 100% rename from frontend/public/404.png rename to client/public/404.png diff --git a/frontend/public/full-logo.png b/client/public/full-logo.png similarity index 100% rename from frontend/public/full-logo.png rename to client/public/full-logo.png diff --git a/frontend/public/logo.png b/client/public/logo.png similarity index 100% rename from frontend/public/logo.png rename to client/public/logo.png diff --git a/frontend/public/vite.svg b/client/public/vite.svg similarity index 100% rename from frontend/public/vite.svg rename to client/public/vite.svg diff --git a/frontend/src/App.jsx b/client/src/App.tsx similarity index 79% rename from frontend/src/App.jsx rename to client/src/App.tsx index 69e6c0424..2afddb430 100644 --- a/frontend/src/App.jsx +++ b/client/src/App.tsx @@ -1,7 +1,7 @@ import { Route, Routes } from "react-router-dom"; import Navbar from "./components/Navbar"; import UserAuthForm from "./pages/UserAuthForm"; -import { createContext, useEffect, useState } from "react"; +import { createContext, useEffect, useState, ReactNode } from "react"; import { lookInSession } from "./common/session"; import Editor from "./pages/Editor"; import Home from "./pages/Home"; @@ -15,11 +15,28 @@ import EditProfile from "./pages/EditProfile"; import Notifications from "./pages/Notifications"; import ManageProjects from "./pages/ManageProjects"; -export const UserContext = createContext({}); +interface UserAuth { + access_token?: string | null; + username?: string; + profile_img?: string; + fullname?: string; + email?: string; + [key: string]: any; +} + +interface UserContextType { + userAuth: UserAuth; + setUserAuth: (auth: UserAuth) => void; +} + +export const UserContext = createContext({ + userAuth: { access_token: null }, + setUserAuth: () => {} +}); function App() { - const [userAuth, setUserAuth] = useState({}); + const [userAuth, setUserAuth] = useState({ access_token: null }); useEffect(() => { let userInSession = lookInSession("user"); diff --git a/frontend/src/assets/react.svg b/client/src/assets/react.svg similarity index 100% rename from frontend/src/assets/react.svg rename to client/src/assets/react.svg diff --git a/frontend/src/common/cloudinary.jsx b/client/src/common/cloudinary.tsx similarity index 100% rename from frontend/src/common/cloudinary.jsx rename to client/src/common/cloudinary.tsx diff --git a/frontend/src/common/date.jsx b/client/src/common/date.tsx similarity index 100% rename from frontend/src/common/date.jsx rename to client/src/common/date.tsx diff --git a/frontend/src/common/filter-pagination-data.jsx b/client/src/common/filter-pagination-data.tsx similarity index 74% rename from frontend/src/common/filter-pagination-data.jsx rename to client/src/common/filter-pagination-data.tsx index 062591351..637d0f38f 100644 --- a/frontend/src/common/filter-pagination-data.jsx +++ b/client/src/common/filter-pagination-data.tsx @@ -1,10 +1,18 @@ import axios from "axios"; -export const filterPaginationData = async ({ create_new_arr = false, state, data, page, countRoute, data_to_send = {}, user = undefined }) => { +export const filterPaginationData = async ({ create_new_arr = false, state, data, page, countRoute, data_to_send = {}, user = undefined }: { + create_new_arr?: boolean; + state: any; + data: any; + page: number; + countRoute: string; + data_to_send?: any; + user?: string; +}) => { - let obj; + let obj: any; - let headers = {}; + let headers: { headers?: { Authorization: string } } = {}; if (user) { headers.headers = { diff --git a/client/src/common/page-animation.tsx b/client/src/common/page-animation.tsx new file mode 100644 index 000000000..0178f8c74 --- /dev/null +++ b/client/src/common/page-animation.tsx @@ -0,0 +1,29 @@ +import { AnimatePresence, motion } from "framer-motion"; +import React, { ReactNode } from "react"; + +interface AnimationWrapperProps { + children: ReactNode; + keyValue?: any; + initial?: { opacity: number }; + animate?: { opacity: number }; + transition?: { duration?: number; delay?: number }; + className?: any; +} + +const AnimationWrapper = ({ children, keyValue = "", initial = { opacity: 0 }, animate = { opacity: 1 }, transition = { duration: 1 }, className = "" }: AnimationWrapperProps) => { + return ( + + + {children} + + + ) +} + +export default AnimationWrapper; diff --git a/frontend/src/common/session.jsx b/client/src/common/session.tsx similarity index 100% rename from frontend/src/common/session.jsx rename to client/src/common/session.tsx diff --git a/frontend/src/components/AboutUser.jsx b/client/src/components/AboutUser.tsx similarity index 100% rename from frontend/src/components/AboutUser.jsx rename to client/src/components/AboutUser.tsx diff --git a/frontend/src/components/CommentCard.jsx b/client/src/components/CommentCard.tsx similarity index 96% rename from frontend/src/components/CommentCard.jsx rename to client/src/components/CommentCard.tsx index 97920f841..d02b9fc22 100644 --- a/frontend/src/components/CommentCard.jsx +++ b/client/src/components/CommentCard.tsx @@ -10,7 +10,7 @@ const CommentCard = ({ index, leftVal, commentData }) => { let { commented_by: { personal_info: { profile_img, fullname, username: commented_by_username } }, commentedAt, comment, _id, children } = commentData; - let { project, project: { comments, comments: { results: commentsArr }, activity, activity: { total_parent_comments }, author: { personal_info: { username: project_author } } }, setProject, setTotalParentCommentsLoaded } = useContext(ProjectContext); + let { project, project: { comments, comments: { results: commentsArr }, activity, activity: { total_parent_comments }, author: { personal_info: { username: project_author } } }, setProject, totalParentCommentsLoaded, setTotalParentCommentsLoaded } = useContext(ProjectContext); let { userAuth: { access_token, username } } = useContext(UserContext); @@ -55,7 +55,7 @@ const CommentCard = ({ index, leftVal, commentData }) => { } if (commentData.childrenLevel === 0 && isDelete) { - setTotalParentCommentsLoaded(preVal => preVal - 1); + setTotalParentCommentsLoaded(totalParentCommentsLoaded - 1); } setProject({ ...project, comments: { results: commentsArr }, activity: { ...activity, total_parent_comments: total_parent_comments - (commentData.childrenLevel === 0 && isDelete ? 1 : 0) } }); @@ -165,7 +165,7 @@ const CommentCard = ({ index, leftVal, commentData }) => { Hide Reply :