From fdc82984ac4eee8172f9fde1cf45c227cc9e9fed Mon Sep 17 00:00:00 2001 From: yash raj Date: Sun, 7 Jul 2024 23:00:47 +0530 Subject: [PATCH] remove old code --- .eslintrc.json | 80 +++++- .github/workflows/pre-commit-checks.yml | 5 +- .husky/pre-commit | 4 - .prettierrc | 7 - __mocks__/db/common.ts | 11 - __mocks__/db/endorsementDetails.json | 52 ---- __mocks__/db/users.ts | 25 -- __mocks__/endorsements.js | 35 --- __mocks__/handler.ts | 5 - __mocks__/handlers/endorsements.handler.js | 9 - __mocks__/handlers/users.ts | 18 -- __mocks__/requestBoardData.js | 242 ------------------ __mocks__/server.js | 4 - .../Unit/Componets/Avatar/Avatar.test.tsx | 24 -- .../AvatarGroup/AvatarGroup.test.tsx | 64 ----- .../Unit/Componets/Button/Button.test.tsx | 29 --- .../Unit/Componets/InputBox/Input.test.tsx | 87 ------- .../Componets/SkillLabel/SkillLabel.test.tsx | 11 - .../VotesListModal/VotesDescription.test.tsx | 22 -- .../VotesListModal/VotesListModal.test.tsx | 53 ---- __tests__/components/button/Button.test.tsx | 38 --- .../components/common/navbar/Navbar.test.tsx | 54 ---- __tests__/components/drawer/Drawer.test.tsx | 34 --- .../endorsementCard/EndorsementCard.test.tsx | 53 ---- __tests__/components/tag/Tag.test.tsx | 11 - __tests__/pages/endorsements.tests.tsx | 19 -- __tests__/services/endorsements.test.js | 28 -- __tests__/services/users.test.tsx | 66 ----- __tests__/utils.tsx | 18 -- jest.config.js | 16 -- jest.setup.js | 15 -- package.json | 2 + prettier.config.js | 10 + process-env.d.ts | 11 - src/components/Avatar/index.tsx | 72 ------ src/components/AvatarGroup/index.tsx | 32 --- src/components/Button/index.tsx | 50 ---- src/components/DropDown/index.tsx | 42 --- src/components/Input/index.tsx | 79 ------ src/components/Layout.tsx | 19 -- .../RequestBoardTable/BoardCategoryRow.tsx | 15 -- .../RequestBoardTable/BoardDetailsRow.tsx | 65 ----- src/components/RequestBoardTable/index.tsx | 27 -- src/components/SearchBox/index.tsx | 24 -- src/components/SkillLabel/index.tsx | 33 --- .../VotesListModal/VotesDescription.tsx | 31 --- src/components/VotesListModal/index.tsx | 36 --- src/components/Wrapper/index.tsx | 10 - src/components/common/Navbar/Navbar.tsx | 56 ---- .../common/Navbar/navbar.constants.ts | 28 -- src/components/common/Navbar/navbar.types.ts | 5 - src/components/drawer/Drawer.tsx | 33 --- .../endorsementCard/EndorsementCard.tsx | 42 --- .../EndorsementDetailsSlideOver.tsx | 53 ---- src/components/tag/Tag.tsx | 19 -- src/constants/comman.ts | 1 - src/constants/image.ts | 3 - src/constants/request-board.ts | 43 ---- src/constants/urls.ts | 50 ---- src/hooks/useScrollDirection.ts | 30 --- src/pages/endorsements/index.tsx | 63 ----- src/pages/index.tsx | 74 +----- src/services/endorsements.js | 13 - src/services/users.ts | 18 -- src/setupTests.js | 17 -- src/types/index.d.ts | 19 -- src/types/users.d.ts | 42 --- tailwind.config.js | 60 ----- tailwind.config.ts | 14 + tsconfig.json | 21 +- yarn.lock | 59 ++++- 71 files changed, 168 insertions(+), 2292 deletions(-) delete mode 100644 .husky/pre-commit delete mode 100644 .prettierrc delete mode 100644 __mocks__/db/common.ts delete mode 100644 __mocks__/db/endorsementDetails.json delete mode 100644 __mocks__/db/users.ts delete mode 100644 __mocks__/endorsements.js delete mode 100644 __mocks__/handler.ts delete mode 100644 __mocks__/handlers/endorsements.handler.js delete mode 100644 __mocks__/handlers/users.ts delete mode 100644 __mocks__/requestBoardData.js delete mode 100644 __mocks__/server.js delete mode 100644 __tests__/Unit/Componets/Avatar/Avatar.test.tsx delete mode 100644 __tests__/Unit/Componets/AvatarGroup/AvatarGroup.test.tsx delete mode 100644 __tests__/Unit/Componets/Button/Button.test.tsx delete mode 100644 __tests__/Unit/Componets/InputBox/Input.test.tsx delete mode 100644 __tests__/Unit/Componets/SkillLabel/SkillLabel.test.tsx delete mode 100644 __tests__/Unit/Componets/VotesListModal/VotesDescription.test.tsx delete mode 100644 __tests__/Unit/Componets/VotesListModal/VotesListModal.test.tsx delete mode 100644 __tests__/components/button/Button.test.tsx delete mode 100644 __tests__/components/common/navbar/Navbar.test.tsx delete mode 100644 __tests__/components/drawer/Drawer.test.tsx delete mode 100644 __tests__/components/endorsementCard/EndorsementCard.test.tsx delete mode 100644 __tests__/components/tag/Tag.test.tsx delete mode 100644 __tests__/pages/endorsements.tests.tsx delete mode 100644 __tests__/services/endorsements.test.js delete mode 100644 __tests__/services/users.test.tsx delete mode 100644 __tests__/utils.tsx delete mode 100644 jest.config.js delete mode 100644 jest.setup.js create mode 100644 prettier.config.js delete mode 100644 process-env.d.ts delete mode 100644 src/components/Avatar/index.tsx delete mode 100644 src/components/AvatarGroup/index.tsx delete mode 100644 src/components/Button/index.tsx delete mode 100644 src/components/DropDown/index.tsx delete mode 100644 src/components/Input/index.tsx delete mode 100644 src/components/Layout.tsx delete mode 100644 src/components/RequestBoardTable/BoardCategoryRow.tsx delete mode 100644 src/components/RequestBoardTable/BoardDetailsRow.tsx delete mode 100644 src/components/RequestBoardTable/index.tsx delete mode 100644 src/components/SearchBox/index.tsx delete mode 100644 src/components/SkillLabel/index.tsx delete mode 100644 src/components/VotesListModal/VotesDescription.tsx delete mode 100644 src/components/VotesListModal/index.tsx delete mode 100644 src/components/Wrapper/index.tsx delete mode 100644 src/components/common/Navbar/Navbar.tsx delete mode 100644 src/components/common/Navbar/navbar.constants.ts delete mode 100644 src/components/common/Navbar/navbar.types.ts delete mode 100644 src/components/drawer/Drawer.tsx delete mode 100644 src/components/endorsementCard/EndorsementCard.tsx delete mode 100644 src/components/endorsementDetailsSlideOver/EndorsementDetailsSlideOver.tsx delete mode 100644 src/components/tag/Tag.tsx delete mode 100644 src/constants/comman.ts delete mode 100644 src/constants/image.ts delete mode 100644 src/constants/request-board.ts delete mode 100644 src/constants/urls.ts delete mode 100644 src/hooks/useScrollDirection.ts delete mode 100644 src/pages/endorsements/index.tsx delete mode 100644 src/services/endorsements.js delete mode 100644 src/services/users.ts delete mode 100644 src/setupTests.js delete mode 100644 src/types/index.d.ts delete mode 100644 src/types/users.d.ts delete mode 100644 tailwind.config.js create mode 100644 tailwind.config.ts diff --git a/.eslintrc.json b/.eslintrc.json index beb46d7..eb6f8fe 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,14 +1,72 @@ { - "plugins": ["react", "react-hooks", "prettier", "@typescript-eslint"], - "extends": ["eslint:recommended", "next", "next/core-web-vitals", "prettier"], - "env": { - "jest": true - }, - "rules": { - "indent": ["error", 4], - "quotes": ["error", "double"], - "semi": ["error", "always"], - "no-unused-vars": "off", - "@typescript-eslint/no-unused-vars": "error" + "extends": [ + "eslint:recommended", + "plugin:react/recommended", + "plugin:@typescript-eslint/recommended", + "plugin:react-hooks/recommended", + "prettier", + "next/core-web-vitals" + ], + "parser": "@typescript-eslint/parser", + "plugins": [ + "react", + "@typescript-eslint", + "react-hooks", + "import" + ], + "rules": { + "eol-last": [ + "error", + "always" + ], + "linebreak-style": [ + "error", + "unix" + ], + "@typescript-eslint/no-explicit-any": "error", + "@typescript-eslint/no-non-null-assertion": "warn", + "import/order": [ + "error", + { + "alphabetize": { + "order": "asc", + "caseInsensitive": true + }, + "newlines-between": "always", + "groups": [ + "builtin", + "external", + "internal", + "parent", + "sibling", + "index" + ], + "pathGroups": [ + { + "pattern": "react", + "group": "external", + "position": "before" + }, + { + "pattern": "@/*", + "group": "internal" + } + ], + "pathGroupsExcludedImportTypes": [ + "builtin", + "@/*" + ] + } + ] + }, + "settings": { + "react": { + "version": "detect" } + }, + "ignorePatterns": [ + "node_modules/", + ".next/", + "out/" + ] } diff --git a/.github/workflows/pre-commit-checks.yml b/.github/workflows/pre-commit-checks.yml index 9fa0a7c..6b4889d 100644 --- a/.github/workflows/pre-commit-checks.yml +++ b/.github/workflows/pre-commit-checks.yml @@ -37,5 +37,6 @@ jobs: - name: Prettier check run: yarn check-format - - name: Run tests - run: yarn test + # TODO : Uncomment the following lines after adding tests + # - name: Run tests + # run: yarn test diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100644 index cf343da..0000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -yarn run test-all diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 31ac305..0000000 --- a/.prettierrc +++ /dev/null @@ -1,7 +0,0 @@ -{ - "trailingComma": "es5", - "tabWidth": 4, - "semi": true, - "singleQuote": false, - "printWidth": 120 -} diff --git a/__mocks__/db/common.ts b/__mocks__/db/common.ts deleted file mode 100644 index f327c13..0000000 --- a/__mocks__/db/common.ts +++ /dev/null @@ -1,11 +0,0 @@ -export const unauthorizedResponse = { - error: "Unauthorized", - message: "Unauthenticated User", - statusCode: 401, -}; - -export const serverErrorResponse = { - statusCode: 500, - error: "Internal Server Error", - message: "An internal server error occurred", -}; diff --git a/__mocks__/db/endorsementDetails.json b/__mocks__/db/endorsementDetails.json deleted file mode 100644 index 307786e..0000000 --- a/__mocks__/db/endorsementDetails.json +++ /dev/null @@ -1,52 +0,0 @@ -[ - { - "id": "abc1", - "title": "Oppenheimer ✨", - "date": "12 Jan 2023", - "skills": "Pinning in Rust", - "endorsers": ["Vaibhav", "Yash", "Tejas"], - "status": "Atomic", - "endorsements": [ - { - "id": 1, - "name": "Vaibhav", - "description": "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat." - }, - { - "id": 2, - "name": "Yash", - "description": "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur Et ut non semper quam a consectetur." - }, - { - "id": 3, - "name": "Tejas", - "description": "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur Et ut non semper quam a consectetur." - } - ] - }, - { - "id": "abc2", - "title": "Oppenheimer ✨", - "date": "12 Jan 2023", - "skills": "Pinning in Rust", - "endorsers": ["Vaibhav", "Yash", "Tejas"], - "status": "Atomic", - "endorsements": [ - { - "id": 1, - "name": "Vaibhav", - "description": "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur Et ut non semper quam a consectetur." - }, - { - "id": 2, - "name": "Yash", - "description": "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat." - }, - { - "id": 3, - "name": "Tejas", - "description": "Cat milk copy park pee walk owner escape bored tired cage droppings sick vet vomit cough hairball, eat toilet paper. Pounce on unsuspecting person i is not fat, i is fluffy. Whenever a door is opened, rush in before the human." - } - ] - } -] diff --git a/__mocks__/db/users.ts b/__mocks__/db/users.ts deleted file mode 100644 index 808a8ac..0000000 --- a/__mocks__/db/users.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { UserData } from "@/types/users"; - -export const selfUser: UserData = { - id: "some-test-id", - profileURL: "https://github.com/Real-Dev-Squad/sample-profile-service", - discordJoinedAt: "2022-11-14T15:36:24.920000+00:00", - roles: { - archived: true, - in_discord: false, - member: true, - super_user: true, - }, - github_created_at: 1622727146000, - github_display_name: "Satyam Bajpai", - github_id: "satyam73", - github_user_id: "satyam73-test-github-id", - incompleteUserDetails: false, - last_name: "Bajpai", - first_name: "Satyam", - status: "active", - username: "satyam-bajpai", - profileStatus: "VERIFIED", - updated_at: 1709236001723, - created_at: 1709236001723, -}; diff --git a/__mocks__/endorsements.js b/__mocks__/endorsements.js deleted file mode 100644 index 58762d7..0000000 --- a/__mocks__/endorsements.js +++ /dev/null @@ -1,35 +0,0 @@ -export const endorsementsListsMock = [ - { - id: 1, - endorserName: "Prakash", - skill: "usestate", - color: "green", - }, - { - id: 2, - endorserName: "vaibhav", - skill: "pinning", - color: "blue", - }, - { - id: 3, - endorserName: "Yash Raj", - skill: "useEffect", - color: "yellow", - }, -]; - -export const skillMockData = [ - { - id: 1, - skill: "React", - }, - { - id: 2, - skill: "Go", - }, - { - id: 3, - skill: "Vanilla JS", - }, -]; diff --git a/__mocks__/handler.ts b/__mocks__/handler.ts deleted file mode 100644 index 9f0f2ac..0000000 --- a/__mocks__/handler.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { endorsementsHandler } from "./handlers/endorsements.handler"; -import { usersHandler } from "./handlers/users"; - -const handlers = [...endorsementsHandler, ...usersHandler]; -export default handlers; diff --git a/__mocks__/handlers/endorsements.handler.js b/__mocks__/handlers/endorsements.handler.js deleted file mode 100644 index 0af4efc..0000000 --- a/__mocks__/handlers/endorsements.handler.js +++ /dev/null @@ -1,9 +0,0 @@ -import { rest } from "msw"; -import { BASE_URL } from "@/constants/urls"; -import endorsementDetails from "../db/endorsementDetails.json"; - -export const endorsementsHandler = [ - rest.get(`${BASE_URL}/endorsements`, (req, res, ctx) => { - return res(ctx.status(200), ctx.json(endorsementDetails)); - }), -]; diff --git a/__mocks__/handlers/users.ts b/__mocks__/handlers/users.ts deleted file mode 100644 index 0572996..0000000 --- a/__mocks__/handlers/users.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { rest } from "msw"; -import { RDS_BACKEND_URL } from "@/constants/urls"; -import { selfUser } from "../db/users"; -import { serverErrorResponse, unauthorizedResponse } from "../db/common"; - -export const usersHandler = [ - rest.get(`${RDS_BACKEND_URL}/users/self`, (req, res, ctx) => { - return res(ctx.status(200), ctx.json(selfUser)); - }), -]; - -export const selfUserUnauthorizedHandler = rest.get(`${RDS_BACKEND_URL}/users/self`, (req, res, ctx) => { - return res(ctx.status(401), ctx.json(unauthorizedResponse)); -}); - -export const selfUserServerErrorHandler = rest.get(`${RDS_BACKEND_URL}/users/self`, (req, res, ctx) => { - return res(ctx.status(401), ctx.json(serverErrorResponse)); -}); diff --git a/__mocks__/requestBoardData.js b/__mocks__/requestBoardData.js deleted file mode 100644 index 1cf102f..0000000 --- a/__mocks__/requestBoardData.js +++ /dev/null @@ -1,242 +0,0 @@ -export const requestBoardData = [ - { - id: "1", - name: "varun", - skill: "useEffect", - color: "green", - votes: [ - { - name: "Prakash", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Manish", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Yash", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - ], - }, - { - id: "2", - name: "Yasj Raj", - skill: "useState", - color: "blue", - votes: [ - { - name: "Samarth", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Rahul", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Pankaj", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Prasidh", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Virat", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Prakash", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - ], - }, - { - id: "3", - name: "Manish", - skill: "java", - color: "blue", - votes: [ - { - name: "Virat", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Prachi", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Akriti", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Prakash", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - ], - }, - { - id: "4", - name: "Ankush Dharkar", - skill: "rust", - color: "yellow", - votes: [ - { - name: "Anushka", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Simran", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Alia", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Prakash", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Prakah", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Pakash", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - ], - }, - { - id: "5", - name: "Bhavika", - skill: "react", - color: "green", - votes: [ - { - name: "Preeti", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Bhavika", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Kanchan", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Prakash", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Arakash", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Mrakash", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Poakash", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - ], - }, - { - id: "6", - name: "Sunny", - skill: "firebase", - color: "blue", - votes: [ - { - name: "Prakash", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Praash", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Praakash", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "APrakash", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "LPrakash", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - { - name: "Drakash", - img: "", - date: "16/07/2022", - reason: "Lorem ipsum dolor sit amet consectetur. Lacus consequat non porttitor faucibus. Mattis nec felis sagittis justo id volutpat. Et ut non semper quam a consectetur erat. Eget eu in diam semper eu sit dui id.", - }, - ], - }, -]; diff --git a/__mocks__/server.js b/__mocks__/server.js deleted file mode 100644 index c920b6c..0000000 --- a/__mocks__/server.js +++ /dev/null @@ -1,4 +0,0 @@ -import { setupServer } from "msw/node"; -import handlers from "./handler"; - -export const server = setupServer(...handlers); diff --git a/__tests__/Unit/Componets/Avatar/Avatar.test.tsx b/__tests__/Unit/Componets/Avatar/Avatar.test.tsx deleted file mode 100644 index 377c19a..0000000 --- a/__tests__/Unit/Componets/Avatar/Avatar.test.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { render, screen } from "@testing-library/react"; -import { dummyImg } from "@/constants/image"; -import Avatar from "@/components/Avatar"; - -describe("Avatar Component", function () { - it("Should render the image if src is provided", function () { - render(); - - const avatarImageElement = screen.getByTestId("avatar-img"); - expect(avatarImageElement).toHaveAttribute("src", dummyImg); - expect(avatarImageElement).toHaveAttribute("alt", "Dummy"); - expect(avatarImageElement).toHaveAttribute("width", "32"); - expect(avatarImageElement).toHaveAttribute("height", "32"); - }); - - it("Should render the name initials if src is false", function () { - render(); - - const avatarImageElement = screen.queryByTestId("avatar-img"); - const avatarInitialsElement = screen.getByTestId("avatar-name-intials"); - expect(avatarImageElement).not.toBeInTheDocument(); - expect(avatarInitialsElement).toHaveTextContent("M"); - }); -}); diff --git a/__tests__/Unit/Componets/AvatarGroup/AvatarGroup.test.tsx b/__tests__/Unit/Componets/AvatarGroup/AvatarGroup.test.tsx deleted file mode 100644 index 2c49ae2..0000000 --- a/__tests__/Unit/Componets/AvatarGroup/AvatarGroup.test.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import { render, screen } from "@testing-library/react"; -import AvatarGroup from "@/components/AvatarGroup"; - -describe("Avatar Component", function () { - it("should not show the remaining avatars text", function () { - const votes = [ - { - name: "Prakash", - img: "", - date: "16/07/2022", - reason: "", - }, - { - name: "Manish", - img: "", - date: "16/07/2022", - reason: "", - }, - { - name: "Yash", - img: "", - date: "16/07/2022", - reason: "", - }, - ]; - render(); - - const remainingAvatarElement = screen.queryByTestId("remaining-avatars"); - expect(remainingAvatarElement).not.toBeInTheDocument(); - }); - - it("should show the remaing avatar text as 1", function () { - const votes = [ - { - name: "Prakash", - img: "", - date: "16/07/2022", - reason: "", - }, - { - name: "Manish", - img: "", - date: "16/07/2022", - reason: "", - }, - { - name: "Yash", - img: "", - date: "16/07/2022", - reason: "", - }, - { - name: "Mansi", - img: "", - date: "16/07/2022", - reason: "", - }, - ]; - render(); - - const remainingAvatarElement = screen.queryByTestId("remaining-avatars"); - expect(remainingAvatarElement).toHaveTextContent("+1"); - }); -}); diff --git a/__tests__/Unit/Componets/Button/Button.test.tsx b/__tests__/Unit/Componets/Button/Button.test.tsx deleted file mode 100644 index a521351..0000000 --- a/__tests__/Unit/Componets/Button/Button.test.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import Button from "@/components/Button"; -import { render, screen, fireEvent } from "@testing-library/react"; - -describe("Button Test", function () { - it("should render the correct details", function () { - const mock = jest.fn(); - render( - - ); - - const buttonElement = screen.getByText("Click Me"); - expect(buttonElement).toHaveTextContent("Click Me"); - }); - - it("should call the button onclick if button got clicked", function () { - const mock = jest.fn(); - render( - - ); - - const buttonElement = screen.getByTestId("button"); - fireEvent.click(buttonElement); - expect(mock).toHaveBeenCalledTimes(1); - }); -}); diff --git a/__tests__/Unit/Componets/InputBox/Input.test.tsx b/__tests__/Unit/Componets/InputBox/Input.test.tsx deleted file mode 100644 index 91ff97b..0000000 --- a/__tests__/Unit/Componets/InputBox/Input.test.tsx +++ /dev/null @@ -1,87 +0,0 @@ -import { render, screen, fireEvent } from "@testing-library/react"; -import { GrPrevious } from "react-icons/gr"; -import Input from "@/components/Input"; - -describe("Input Component", function () { - it("should render correct details", function () { - const onChangeMock = jest.fn(); - - render( - } - onChange={onChangeMock} - /> - ); - - const inputLabelElement = screen.getByTestId("input-label"); - const inputElement = screen.getByTestId("input"); - const inputIconElement = screen.getByTestId("input-icon-right"); - expect(inputLabelElement).toHaveTextContent("Full Name"); - expect(inputElement).toHaveAttribute("type", "text"); - expect(inputElement).toHaveAttribute("value", "Manish Devrani"); - expect(inputElement).toHaveAttribute("placeholder", "Enter full name"); - expect(inputIconElement).toBeInTheDocument(); - }); - - it("should render icon on the left side", function () { - const onChangeMock = jest.fn(); - - render( - } - iconPosition="left" - onChange={onChangeMock} - /> - ); - - const inputLeftIcon = screen.getByTestId("input-icon-left"); - const inputRightIcon = screen.queryByTestId("input-icon-right"); - expect(inputRightIcon).not.toBeInTheDocument(); - expect(inputLeftIcon).toBeInTheDocument(); - }); - - it("should render icon on the right side", function () { - const onChangeMock = jest.fn(); - - render( - } - iconPosition="right" - onChange={onChangeMock} - /> - ); - - const inputLeftIcon = screen.queryByTestId("input-icon-left"); - const inputRightIcon = screen.queryByTestId("input-icon-right"); - expect(inputLeftIcon).not.toBeInTheDocument(); - expect(inputRightIcon).toBeInTheDocument(); - }); - - it("calls the input onChange handler when input value changes", function () { - const onChangeMock = jest.fn(); - - render( - - ); - - const inputElement = screen.getByTestId("input"); - fireEvent.change(inputElement, { target: { value: "abc" } }); - expect(onChangeMock).toHaveBeenCalledTimes(1); - }); -}); diff --git a/__tests__/Unit/Componets/SkillLabel/SkillLabel.test.tsx b/__tests__/Unit/Componets/SkillLabel/SkillLabel.test.tsx deleted file mode 100644 index 4e74926..0000000 --- a/__tests__/Unit/Componets/SkillLabel/SkillLabel.test.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import SkillLabel from "@/components/SkillLabel"; -import { render, screen } from "@testing-library/react"; - -describe("Skill Label Component", function () { - it("should render the correct details", function () { - render(); - - const skillLabelTitleElement = screen.getByTestId("skill-label-title"); - expect(skillLabelTitleElement).toHaveTextContent("useState"); - }); -}); diff --git a/__tests__/Unit/Componets/VotesListModal/VotesDescription.test.tsx b/__tests__/Unit/Componets/VotesListModal/VotesDescription.test.tsx deleted file mode 100644 index 38f5315..0000000 --- a/__tests__/Unit/Componets/VotesListModal/VotesDescription.test.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { render, screen } from "@testing-library/react"; -import VotesDescription from "@/components/VotesListModal/VotesDescription"; - -describe("Votes Description Component", function () { - it("should render the component data correctly", function () { - const votesDescriptionData = { - src: "", - name: "Manish", - date: "16/15/42", - description: "This is the description", - }; - - render(); - - const voterNameElement = screen.getByTestId("voter-name"); - const voteDateElement = screen.getByTestId("vote-date"); - const voteReasonElement = screen.getByTestId("vote-reason"); - expect(voterNameElement).toHaveTextContent("Manish"); - expect(voteDateElement).toHaveTextContent("16/15/42"); - expect(voteReasonElement).toHaveTextContent("This is the description"); - }); -}); diff --git a/__tests__/Unit/Componets/VotesListModal/VotesListModal.test.tsx b/__tests__/Unit/Componets/VotesListModal/VotesListModal.test.tsx deleted file mode 100644 index d2036c1..0000000 --- a/__tests__/Unit/Componets/VotesListModal/VotesListModal.test.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import { render, screen, fireEvent } from "@testing-library/react"; -import VotesListModal from "@/components/VotesListModal"; - -describe("Votes Description Component", function () { - it("should render the component data correctly", function () { - const mock = jest.fn(); - const votes = [ - { - name: "Prakash", - img: "", - date: "16/07/2022", - reason: "", - }, - { - name: "Manish", - img: "", - date: "16/07/2022", - reason: "", - }, - ]; - - render(); - - const votesModalTitleElement = screen.getByTestId("votes-title"); - const votesLengthElement = screen.getByTestId("votes-length"); - expect(votesModalTitleElement).toHaveTextContent("Member Votes:"); - expect(votesLengthElement).toHaveTextContent("2"); - }); - - it("should call the onclose method on clicking outside of modal", function () { - const mock = jest.fn(); - const votes = [ - { - name: "Prakash", - img: "", - date: "16/07/2022", - reason: "", - }, - { - name: "Manish", - img: "", - date: "16/07/2022", - reason: "", - }, - ]; - - render(); - - const outsideModalWrapperElement = screen.getByTestId("close-modal"); - fireEvent.click(outsideModalWrapperElement); - expect(mock).toHaveBeenCalledTimes(1); - }); -}); diff --git a/__tests__/components/button/Button.test.tsx b/__tests__/components/button/Button.test.tsx deleted file mode 100644 index 0c40f4f..0000000 --- a/__tests__/components/button/Button.test.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import React from "react"; -import { render, fireEvent } from "@testing-library/react"; -import Button from "@/components/Button"; -import { IoCheckmarkSharp } from "react-icons/io5"; - -describe("Button Component", () => { - test("renders button with default type and text", () => { - const { getByRole } = render(); - const button = getByRole("button", { - name: "click me", - }); - expect(button).toBeInTheDocument(); - }); - - test("renders button with custom type, color, icon and textn width", () => { - const { getByRole } = render( - - ); - const button = getByRole("button", { - name: "custom", - }); - expect(button).toBeInTheDocument(); - expect(button).toHaveClass("bg-red-100"); - }); - - test("handles onClick event", () => { - const handleClick = jest.fn(); - const { getByRole } = render(); - const button = getByRole("button", { - name: "click", - }); - fireEvent.click(button); - expect(handleClick).toHaveBeenCalledTimes(1); - }); -}); diff --git a/__tests__/components/common/navbar/Navbar.test.tsx b/__tests__/components/common/navbar/Navbar.test.tsx deleted file mode 100644 index bdfcbd1..0000000 --- a/__tests__/components/common/navbar/Navbar.test.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import React from "react"; -import { fireEvent, render, screen } from "@testing-library/react"; - -import { NavbarLink } from "@/components/common/Navbar/navbar.types"; -import { NAVBAR_LINKS, SIGNIN_URL } from "@/components/common/Navbar/navbar.constants"; - -import Navbar from "@/components/common/Navbar/Navbar"; - -describe("Navbar Component", () => { - it("should render the Navbar", () => { - render(); - const nav = screen.getByRole("banner"); - - expect(nav).toBeInTheDocument(); - - // nav links assertions - desktop - NAVBAR_LINKS.forEach((link: NavbarLink) => { - const navLink = screen.getAllByText(link.name)[0]; - expect(navLink).toHaveTextContent(link.name); - }); - - // signin button assertions - const signinButton = screen.getByTestId("signin-button"); - const signInText = screen.getByText("Sign in with Github"); - - expect(signInText).toBeInTheDocument(); - expect(signinButton).toBeInTheDocument(); - expect(signinButton).toHaveAttribute("href", SIGNIN_URL); - }); - - it("should render the mobile navbar when hamburger button is clicked", () => { - render(); - - const mobileNav = screen.queryByTestId("mobile-nav"); - const hamburgerButton = screen.queryByRole("button"); - - // hamburgerButton assertions - expect(hamburgerButton).toBeInTheDocument(); - expect(hamburgerButton).toHaveClass("hamburger"); - - // toggle navlinks assertions - expect(mobileNav).toHaveClass("hidden"); - - fireEvent.click(hamburgerButton!); - - expect(mobileNav).toHaveClass("visible"); - - // nav links assertions - mobile - NAVBAR_LINKS.forEach((link: NavbarLink) => { - const navLink = screen.queryAllByText(link.name)[1]; - expect(navLink).toHaveTextContent(link.name); - }); - }); -}); diff --git a/__tests__/components/drawer/Drawer.test.tsx b/__tests__/components/drawer/Drawer.test.tsx deleted file mode 100644 index 3d3eb52..0000000 --- a/__tests__/components/drawer/Drawer.test.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import React from "react"; -import { fireEvent, render } from "@testing-library/react"; -import Drawer from "@/components/drawer/Drawer"; - -describe("Drawer", () => { - test("when open render drawer ", () => { - const { getByRole } = render( {}} />); - const drawer = getByRole("drawer"); - - expect(drawer).toBeInTheDocument(); - expect(drawer).toHaveClass("!translate-x-0"); - }); - - test("when close do not renders drawer ", () => { - const { queryByRole } = render( {}} />); - const drawer = queryByRole("drawer"); - - expect(drawer).toBeInTheDocument(); - expect(drawer).toHaveClass("translate-x-full"); - }); - - test("handle onClose event", () => { - const handleClose = jest.fn(); - const { queryByRole, getByTestId } = render(); - const drawer = queryByRole("drawer"); - const closeButton = getByTestId("close-button"); - - expect(drawer).toBeInTheDocument(); - - fireEvent.click(closeButton); - - expect(handleClose).toHaveBeenCalledTimes(1); - }); -}); diff --git a/__tests__/components/endorsementCard/EndorsementCard.test.tsx b/__tests__/components/endorsementCard/EndorsementCard.test.tsx deleted file mode 100644 index 433cefc..0000000 --- a/__tests__/components/endorsementCard/EndorsementCard.test.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import React from "react"; -import { render, fireEvent } from "@testing-library/react"; -import EndorsementCard from "@/components/endorsementCard/EndorsementCard"; -import { TRUNCATION_LENGTH } from "@/constants/comman"; - -describe("EndorsementCard", () => { - const cardProps = { - name: "suhas", - description: "Lorem ipsum dolor sit amet consectetur adipisicing elit", - }; - - test("renders card with name, small description and avatar", () => { - const { getByText, getByRole, queryByText } = render(); - const listElement = getByRole("listitem"); - const nameElement = getByText(cardProps.name); - const avatarElement = getByText(cardProps.name.charAt(0)); - - const descriptionElement = getByText(/Lorem ipsum dolor sit amet consectetur adipisicing elit/i); - const seeMoreElement = queryByText("...see more"); - - expect(listElement).toBeInTheDocument(); - expect(nameElement).toBeInTheDocument(); - expect(avatarElement).toBeInTheDocument(); - expect(descriptionElement).toBeInTheDocument(); - expect(seeMoreElement).not.toBeInTheDocument(); - }); - - test("renders card with name and long description", () => { - const cardProps = { - name: "pratik", - description: - "Lorem, ipsum dolor sit amet consectetur adipisicing elit. Aliquid, quas hic. Animi consequuntur, ullam ad qui, architecto molestias natus, libero soluta explicabo impedit aperiam magnam", - }; - - const { getByText, getByRole } = render(); - const listElement = getByRole("listitem"); - const nameElement = getByText(cardProps.name); - const seeMoreElement = getByRole("button", { name: "... see more" }); - const truncDescElement = getByText(new RegExp(cardProps.description.slice(0, TRUNCATION_LENGTH))); - - expect(listElement).toBeInTheDocument(); - expect(nameElement).toBeInTheDocument(); - expect(seeMoreElement).toBeInTheDocument(); - expect(seeMoreElement).toBeInTheDocument(); - expect(truncDescElement).toBeInTheDocument(); - - fireEvent.click(seeMoreElement); - const seeLessElement = getByRole("button", { name: "see less" }); - const fullDescElement = getByText(new RegExp(cardProps.description)); - expect(seeLessElement).toBeInTheDocument(); - expect(fullDescElement).toBeInTheDocument(); - }); -}); diff --git a/__tests__/components/tag/Tag.test.tsx b/__tests__/components/tag/Tag.test.tsx deleted file mode 100644 index e2217aa..0000000 --- a/__tests__/components/tag/Tag.test.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import React from "react"; -import { render } from "@testing-library/react"; -import Tag from "@/components/tag/Tag"; - -describe("Tag Component", () => { - test("renders text correctly", () => { - const { getByText } = render(Atomic); - const tagElement = getByText("Atomic"); - expect(tagElement).toBeInTheDocument(); - }); -}); diff --git a/__tests__/pages/endorsements.tests.tsx b/__tests__/pages/endorsements.tests.tsx deleted file mode 100644 index 69224fd..0000000 --- a/__tests__/pages/endorsements.tests.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import Endorsements from "@/pages/endorsements"; -import { render, screen } from "@testing-library/react"; - -describe("Endorsements", () => { - test("renders Endorsements ui", () => { - render(); - const upvoteButton = screen.getByText("Upvote"); - const downvoteButton = screen.getByText("Downvote"); - const CompleteEndorsementButton = screen.getByText("Complete Endorsement"); - - expect(screen.getByText("Endorsements")).toBeInTheDocument(); - expect(screen.getByText("search")).toBeInTheDocument(); - expect(screen.getByTestId("input")).toBeInTheDocument(); - expect(upvoteButton).toBeInTheDocument(); - expect(downvoteButton).toBeInTheDocument(); - expect(screen.getByPlaceholderText("placeholder text here")).toBeInTheDocument(); - expect(CompleteEndorsementButton).toBeInTheDocument(); - }); -}); diff --git a/__tests__/services/endorsements.test.js b/__tests__/services/endorsements.test.js deleted file mode 100644 index b4a9b13..0000000 --- a/__tests__/services/endorsements.test.js +++ /dev/null @@ -1,28 +0,0 @@ -import { useGetEndorsements, usePostEndorsement } from "@/services/endorsements"; -import { renderHook, waitFor } from "@testing-library/react"; -import { createWrapper } from "../utils"; -const { server } = require("../../__mocks__/server"); - -beforeAll(() => { - server.listen({ - onUnhandledRequest: "warn", - }); -}); - -afterEach(() => { - server.resetHandlers(); -}); - -afterAll(() => { - server.close(); -}); - -test("test useGetEndorsements hook", async () => { - const { result } = renderHook(() => useGetEndorsements(), { wrapper: createWrapper }); - await waitFor(() => result.current.isSuccess); -}); - -test("test usePostEndorsement hook", async () => { - const { result } = renderHook(() => usePostEndorsement({ endorsementData: {} }), { wrapper: createWrapper }); - await waitFor(() => result.current.isSuccess); -}); diff --git a/__tests__/services/users.test.tsx b/__tests__/services/users.test.tsx deleted file mode 100644 index ebcf353..0000000 --- a/__tests__/services/users.test.tsx +++ /dev/null @@ -1,66 +0,0 @@ -import { renderHook, waitFor } from "@testing-library/react"; - -import { selfUserServerErrorHandler, selfUserUnauthorizedHandler } from "../../__mocks__/handlers/users"; -import { server } from "../../__mocks__/server"; -import { useGetSelfUser } from "@/services/users"; -import { createWrapper, testQueryClient } from "../utils"; - -import { serverErrorResponse, unauthorizedResponse } from "../../__mocks__/db/common"; -import { selfUser } from "../../__mocks__/db/users"; -import { AxiosError } from "axios"; - -beforeAll(() => { - server.listen({ - onUnhandledRequest: "warn", - }); -}); - -afterEach(() => { - server.resetHandlers(); - testQueryClient.clear(); -}); - -afterEach(() => { - testQueryClient.clear(); -}); - -afterAll(() => { - server.close(); -}); - -describe("useGetSelfUser", () => { - it("should return isSuccess true and return self user details", async () => { - const { result } = renderHook(() => useGetSelfUser(), { wrapper: createWrapper }); - await waitFor(() => expect(result.current.isSuccess).toBe(true)); - - expect(result.current.data).toBeDefined(); - expect(result.current.data).toStrictEqual(selfUser); - }); - - it("should return isError true and return unauthorized error message", async () => { - server.use(selfUserUnauthorizedHandler); - const { result } = renderHook(() => useGetSelfUser(), { wrapper: createWrapper }); - - await waitFor(() => expect(result.current.isLoading).toBe(false)); - - expect(result?.current.isError).toStrictEqual(true); - - if (result?.current?.error instanceof AxiosError) { - expect(result?.current?.error?.response?.data).toStrictEqual(unauthorizedResponse); - } - }); - - it("should return server error with server error response message", async () => { - server.use(selfUserServerErrorHandler); - - const { result } = renderHook(() => useGetSelfUser(), { wrapper: createWrapper }); - - await waitFor(() => expect(result.current.isLoading).toBe(false)); - - expect(result?.current.isError).toStrictEqual(true); - - if (result?.current?.error instanceof AxiosError) { - expect(result?.current?.error?.response?.data).toStrictEqual(serverErrorResponse); - } - }); -}); diff --git a/__tests__/utils.tsx b/__tests__/utils.tsx deleted file mode 100644 index d934ba4..0000000 --- a/__tests__/utils.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; -import { ReactNode } from "react"; - -export const testQueryClient = new QueryClient({ - defaultOptions: { - queries: { - retry: false, - }, - }, -}); - -type TestWrapperProps = { - children: ReactNode; -}; - -export function createWrapper({ children }: TestWrapperProps) { - return {children}; -} diff --git a/jest.config.js b/jest.config.js deleted file mode 100644 index 464890e..0000000 --- a/jest.config.js +++ /dev/null @@ -1,16 +0,0 @@ -const nextJest = require("next/jest"); - -const createJestConfig = nextJest({ - // Provide the path to your Next.js app to load next.config.js and .env files in your test environment - dir: "./", -}); - -// Add any custom config to be passed to Jest -const customJestConfig = { - setupFilesAfterEnv: ["/jest.setup.js"], - testEnvironment: "jest-environment-jsdom", - testPathIgnorePatterns: ["/__tests__/utils.tsx"], -}; - -// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async -module.exports = createJestConfig(customJestConfig); diff --git a/jest.setup.js b/jest.setup.js deleted file mode 100644 index 5383663..0000000 --- a/jest.setup.js +++ /dev/null @@ -1,15 +0,0 @@ -import "@testing-library/jest-dom/extend-expect"; -import { server } from "./__mocks__/server"; -beforeAll(() => { - server.listen({ - onUnhandledRequest: "warn", - }); -}); - -afterEach(() => { - server.resetHandlers(); -}); - -afterAll(() => { - server.close(); -}); diff --git a/package.json b/package.json index df9f7ce..aa67c93 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "eslint": "8.41.0", "eslint-config-next": "13.4.4", "eslint-config-prettier": "^8.8.0", + "eslint-plugin-import": "^2.29.1", "eslint-plugin-jsx-a11y": "^6.7.1", "eslint-plugin-next": "^0.0.0", "eslint-plugin-prettier": "^4.2.1", @@ -60,6 +61,7 @@ "msw": "^1.3.0", "npm-run-all": "^4.1.5", "prettier": "^2.8.8", + "prettier-plugin-tailwindcss": "^0.6.5", "ts-jest": "^29.1.1" }, "volta": { diff --git a/prettier.config.js b/prettier.config.js new file mode 100644 index 0000000..fb6fb82 --- /dev/null +++ b/prettier.config.js @@ -0,0 +1,10 @@ +/** @type {import("prettier").Config} */ +const config = { + trailingComma: "es5", + tabWidth: 4, + semi: false, + printWidth: 120, + plugins: ["prettier-plugin-tailwindcss"], +}; + +module.exports = config; diff --git a/process-env.d.ts b/process-env.d.ts deleted file mode 100644 index 0d9e55a..0000000 --- a/process-env.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -declare namespace NodeJS { - interface ProcessEnv { - NEXT_PUBLIC_BACKEND_BASE_URL: string; - NEXT_PUBLIC_STATUS_SITE: string; - NEXT_PUBLIC_MEMBERS_SITE: string; - NEXT_PUBLIC_WELCOME_SITE: string; - NEXT_PUBLIC_WWW_SITE: string; - NEXT_PUBLIC_MY_SITE: string; - NEXT_PUBLIC_APP_ENV: "staging" | "production" | "test" | "development"; - } -} diff --git a/src/components/Avatar/index.tsx b/src/components/Avatar/index.tsx deleted file mode 100644 index 786c3ba..0000000 --- a/src/components/Avatar/index.tsx +++ /dev/null @@ -1,72 +0,0 @@ -"use client"; - -import Image from "next/image"; - -type AvatarProps = { - name: string; - src?: string; - size?: string; -}; - -type getAvatarSizeTypes = { - size: string; -}; - -function getAvatarSize({ size }: getAvatarSizeTypes) { - const sizeVariants = { - lg: { - width: 50, - height: 50, - }, - md: { - width: 40, - height: 40, - }, - sm: { - width: 32, - height: 32, - }, - }; - - return sizeVariants[size as keyof typeof sizeVariants] || sizeVariants.md; -} - -function getAvatarInitialsStyles({ size }: getAvatarSizeTypes) { - const baseStyles = - "text-sm font-medium rounded-full bg-gray-100 flex items-center justify-center border border-gray-600"; - const variantStyles = { - size: { - lg: "w-[50px] h-[50px]", - md: "w-[40px] h-[40px]", - sm: "w-[32px] h-[32px]", - }, - }; - - const sizeClass = variantStyles.size[size as keyof typeof variantStyles.size] || variantStyles.size.md; - - return `${baseStyles} ${sizeClass}`; -} - -export default function Avatar({ src, name, size = "sm" }: AvatarProps) { - const { width, height } = getAvatarSize({ size }); - const initials = name.trim().charAt(0).toUpperCase(); - - return ( -
- {src ? ( - {name} - ) : ( -

- {initials} -

- )} -
- ); -} diff --git a/src/components/AvatarGroup/index.tsx b/src/components/AvatarGroup/index.tsx deleted file mode 100644 index 26b122f..0000000 --- a/src/components/AvatarGroup/index.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import Avatar from "../Avatar"; - -type VotesTypes = { - img?: string; - date: string; - name: string; - reason: string; -}; - -type AvatarGroupTypes = { - votes: VotesTypes[]; -}; - -export default function AvatarGroup({ votes }: AvatarGroupTypes) { - const visibleAvatars = votes.slice(0, 3); - const remainingAvatars = votes.slice(3); - - return ( -
- {visibleAvatars.map((vote) => { - return ; - })} -

0 && "border border-gray-400 hover:bg-gray-100 transition cursor-pointer" - }`} - > - {remainingAvatars.length > 0 && +{remainingAvatars.length}} -

-
- ); -} diff --git a/src/components/Button/index.tsx b/src/components/Button/index.tsx deleted file mode 100644 index 783fe5b..0000000 --- a/src/components/Button/index.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import { ReactNode } from "react"; - -type ButtonProps = { - children: ReactNode; - roundness?: string; - variant?: string; - onClick?: () => void; -}; - -type ButtonStylesProps = { - roundness?: string; - variant?: string; - block?: boolean; -}; - -function getButtonStyle({ roundness = "pill", variant = "default" }: ButtonStylesProps) { - const baseStyles = "px-4 lg:px-6 py-2 text-sm font-semibold flex items-center justify-center gap-2"; - const variantsStyles = { - roundness: { - medium: "rounded-md", - large: "rounded-lg", - pill: "rounded-full", - square: "rounded-none", - }, - variant: { - primary: "bg-[#2563EB] text-white", - secondary: "bg-black-dark text-white", - success: "bg-green text-white", - error: "bg-red-100 border-2 border-solid border-red-300 text-red-600", - default: "bg-gray-100 text-black-light", - outline: "bg-transparent text-black-dark border", - text: "bg-gray-100 lg:bg-transparent text-black-light border-none hover:bg-gray-100 hover:text-red-dark-500 transition", - }, - }; - - const roundnessClass = - variantsStyles.roundness[roundness as keyof typeof variantsStyles.roundness] || variantsStyles.roundness.pill; - const variantClass = - variantsStyles.variant[variant as keyof typeof variantsStyles.variant] || variantsStyles.variant.default; - - return `${baseStyles} ${roundnessClass} ${variantClass}`; -} - -export default function Button({ children, roundness, variant, onClick }: ButtonProps) { - return ( - - ); -} diff --git a/src/components/DropDown/index.tsx b/src/components/DropDown/index.tsx deleted file mode 100644 index 981b143..0000000 --- a/src/components/DropDown/index.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import React, { useState, FC } from "react"; -import { BsChevronDown, BsChevronUp } from "react-icons/bs"; -import { skillMockData } from "../../../__mocks__/endorsements"; - -export const DropDown: FC = () => { - const [isOpen, setIsOpen] = useState(false); - const [selectedOption, setSelectedOption] = useState("Select an option"); - - const toggleDropdown = () => { - setIsOpen(!isOpen); - }; - - const handleOptionClick = (option: string) => { - setSelectedOption(option); - setIsOpen(false); - }; - - return ( -
- - {isOpen && ( -
-
    -
  • handleOptionClick("Select an option")}> - Select an option -
  • - {skillMockData.map((skill) => ( - -
  • handleOptionClick(skill.skill)}> - {skill.skill} -
  • -
    - ))} -
-
- )} -
- ); -}; diff --git a/src/components/Input/index.tsx b/src/components/Input/index.tsx deleted file mode 100644 index 3a8b310..0000000 --- a/src/components/Input/index.tsx +++ /dev/null @@ -1,79 +0,0 @@ -import { ReactNode, ChangeEvent } from "react"; - -type InputProps = { - label: string; - value: string; - placeholder?: string; - icon?: ReactNode; - disabled?: boolean; - name?: string; - roundness?: string; - variant?: string; - iconPosition?: string; - type: "text" | "number" | "email" | "password"; - onChange?: (e: ChangeEvent) => void; -}; - -type InputStylesProps = { - roundness?: string; - variant?: string; -}; - -function getInputStyle({ roundness = "pill", variant = "filled" }: InputStylesProps) { - const baseStyles = "flex gap-4 py-3 px-5 w-max text-base items-center relative"; - const variantsStyles = { - roundness: { - square: "rounded-none", - medium: "rounded-xl", - pill: "rounded-[50px]", - }, - variant: { - filled: "bg-gray-100", - outlined: "border-2 border-gray-400 focus-within:border-blue-700", - }, - }; - - const roundnessClass = - variantsStyles.roundness[roundness as keyof typeof variantsStyles.roundness] || variantsStyles.roundness.pill; - const variantClass = - variantsStyles.variant[variant as keyof typeof variantsStyles.variant] || variantsStyles.variant.filled; - - return `${baseStyles} ${roundnessClass} ${variantClass}`; -} - -export default function Input({ - type, - label, - name, - value, - placeholder, - disabled = false, - icon, - iconPosition = "right", - roundness, - variant, - onChange, -}: InputProps) { - return ( -
- {iconPosition === "left" && {icon}} -
- - -
- {iconPosition === "right" && {icon}} -
- ); -} diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx deleted file mode 100644 index 6f0d9dc..0000000 --- a/src/components/Layout.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { ReactNode } from "react"; -import Head from "next/head"; -import Navbar from "./common/Navbar/Navbar"; - -type LayoutProps = { - title: string; - children: ReactNode; -}; -export default function Layout({ title, children }: LayoutProps) { - return ( -
- - {title} - - - {children} -
- ); -} diff --git a/src/components/RequestBoardTable/BoardCategoryRow.tsx b/src/components/RequestBoardTable/BoardCategoryRow.tsx deleted file mode 100644 index b1d83c2..0000000 --- a/src/components/RequestBoardTable/BoardCategoryRow.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { REQUEST_BOARD_TABLE_CATEGORIES } from "@/constants/request-board"; - -export default function BoardCategoryRow() { - return ( - <> - {Object.values(REQUEST_BOARD_TABLE_CATEGORIES).map((category) => { - return ( -

- {category} -

- ); - })} - - ); -} diff --git a/src/components/RequestBoardTable/BoardDetailsRow.tsx b/src/components/RequestBoardTable/BoardDetailsRow.tsx deleted file mode 100644 index a130fef..0000000 --- a/src/components/RequestBoardTable/BoardDetailsRow.tsx +++ /dev/null @@ -1,65 +0,0 @@ -"use client"; - -import { useState } from "react"; -import AvatarGroup from "../AvatarGroup"; -import Button from "../Button"; -import SkillLabel from "../SkillLabel"; -import VotesListModal from "../VotesListModal"; - -type VotesTypes = { - img?: string; - date: string; - name: string; - reason: string; -}; - -type BoardDetailsRowProps = { - name: string; - skill: string; - colorScheme: string; - votes: VotesTypes[]; - openDetails: () => void; -}; - -export default function BoardDetailsRow({ name, skill, votes, colorScheme, openDetails }: BoardDetailsRowProps) { - const [isModalOpen, setIsModalOpen] = useState(false); - - return ( -
-

- {name} -

- -
- -
-
-
-
- { - setIsModalOpen(true); - }} - > - - - {isModalOpen && setIsModalOpen(false)} />} -
-

+8

-
-
- - -
-
-
- ); -} diff --git a/src/components/RequestBoardTable/index.tsx b/src/components/RequestBoardTable/index.tsx deleted file mode 100644 index 192a67a..0000000 --- a/src/components/RequestBoardTable/index.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import BoardCategoryRow from "./BoardCategoryRow"; -import BoardDetailsRow from "./BoardDetailsRow"; -import { requestBoardData } from "../../../__mocks__/requestBoardData"; -import { SKILL_LABEL_COLOR_MAPPING } from "@/constants/request-board"; -import { useGetEndorsements } from "@/services/endorsements"; - -export default function RequestBoardTable({ openDetails }: { openDetails: () => void }) { - const { data: endorsements, isLoading } = useGetEndorsements(); - console.log(endorsements, isLoading); //will remove this when BE APIs are ready - - const renderBoardDetailsRow = requestBoardData.map((skillItem, index) => ( - - )); - return ( -
-
- -
-
{renderBoardDetailsRow}
-
- ); -} diff --git a/src/components/SearchBox/index.tsx b/src/components/SearchBox/index.tsx deleted file mode 100644 index 6ef675e..0000000 --- a/src/components/SearchBox/index.tsx +++ /dev/null @@ -1,24 +0,0 @@ -"use client"; - -import { useState } from "react"; -import { BiSearch } from "react-icons/bi"; -import Input from "../Input"; - -export default function SearchBox() { - const [searchQuery, setSearchQuery] = useState(""); - return ( - } - iconPosition="right" - variant="filled" - onChange={(e) => { - setSearchQuery(e.target.value); - }} - /> - ); -} diff --git a/src/components/SkillLabel/index.tsx b/src/components/SkillLabel/index.tsx deleted file mode 100644 index 298c005..0000000 --- a/src/components/SkillLabel/index.tsx +++ /dev/null @@ -1,33 +0,0 @@ -type SkillLabelProps = { - title: string; - colorScheme?: string; -}; - -type SkillLabelStylesProps = { - colorScheme?: string; -}; - -export function getSkillLableStyles({ colorScheme = "default" }: SkillLabelStylesProps) { - const baseStyles = "py-1.5 px-5 text-sm rounded-[50px] font-semibold w-max"; - const variants = { - colorScheme: { - default: "bg-gray-100 text-black-dark", - green: "text-[#15803D] bg-[#DCFCE7]", - blue: "text-[#1D4ED8] bg-[#DBEAFE]", - yellow: "text-[#A16207] bg-[#FEF9C3]", - }, - }; - - const colorSchemeClass = - variants.colorScheme[colorScheme as keyof typeof variants.colorScheme] || variants.colorScheme.default; - - return `${baseStyles} ${colorSchemeClass}`; -} - -export default function SkillLabel({ title, colorScheme }: SkillLabelProps) { - return ( -
-

{title}

-
- ); -} diff --git a/src/components/VotesListModal/VotesDescription.tsx b/src/components/VotesListModal/VotesDescription.tsx deleted file mode 100644 index 61461a4..0000000 --- a/src/components/VotesListModal/VotesDescription.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import Avatar from "../Avatar"; - -type VotesTypes = { - src?: string; - name: string; - date: string; - description: string; -}; - -export default function VotesDescription({ src, name, date, description }: VotesTypes) { - return ( -
-
- -
-
-
-

- {name} -

-

- {date} -

-
-
-

{description}

-
-
-
- ); -} diff --git a/src/components/VotesListModal/index.tsx b/src/components/VotesListModal/index.tsx deleted file mode 100644 index a771e0e..0000000 --- a/src/components/VotesListModal/index.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import VotesDescription from "./VotesDescription"; - -type VotesTypes = { - img?: string; - date: string; - name: string; - reason: string; -}; - -type VotesListModalTypes = { - votes: VotesTypes[]; - onClose: () => void; -}; - -export default function VotesListModal({ votes, onClose }: VotesListModalTypes) { - const renderVotes = votes.map((vote) => ( - - )); - - return ( -
-
-
-
-

- Member Votes: -

-

- {votes.length} -

-
-
{renderVotes}
-
-
- ); -} diff --git a/src/components/Wrapper/index.tsx b/src/components/Wrapper/index.tsx deleted file mode 100644 index 0349013..0000000 --- a/src/components/Wrapper/index.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { ReactNode } from "react"; - -type WrapperTypes = { - children: ReactNode; - styles?: string; -}; - -export default function Wrapper({ children, styles }: WrapperTypes) { - return
{children}
; -} diff --git a/src/components/common/Navbar/Navbar.tsx b/src/components/common/Navbar/Navbar.tsx deleted file mode 100644 index 1e74fc0..0000000 --- a/src/components/common/Navbar/Navbar.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import Image from "next/image"; -import React, { useState } from "react"; -import { GiHamburgerMenu } from "react-icons/gi"; -import { IoLogoGithub } from "react-icons/io5"; - -import { NAVBAR_LINKS, SIGNIN_URL } from "./navbar.constants"; -import { NavbarLink } from "./navbar.types"; - -function Navbar() { - const [isNavbarLinksVisible, setIsNavbarLinksVisible] = useState(false); - - function toggleNavbarLinksVisibility() { - setIsNavbarLinksVisible((prevState) => !prevState); - } - - const navbarItemsMapping = NAVBAR_LINKS.map((item: NavbarLink) => ( -
  • - - {item.name} - -
  • - )); - - return ( -
    -
    - Real Dev Squad - - - - - Sign in with Github - - - -
    - -
    - ); -} - -export default Navbar; diff --git a/src/components/common/Navbar/navbar.constants.ts b/src/components/common/Navbar/navbar.constants.ts deleted file mode 100644 index faa0c81..0000000 --- a/src/components/common/Navbar/navbar.constants.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { RDS_BACKEND_URL, URLS } from "@/constants/urls"; -import { NavbarLink } from "./navbar.types"; - -// ?v2=true so that we get rds-session-v2 cookie from RDS backend -export const SIGNIN_URL = `${RDS_BACKEND_URL}/auth/github/login?redirectURL=${URLS.SKILL_TREE_SITE}?v2=true`; - -export const NAVBAR_LINKS: NavbarLink[] = [ - { - id: "welcome-site", - name: "Welcome", - link: URLS.WELCOME_SITE, - }, - { - id: "events-site", - name: "Events", - link: `${URLS.WWW_SITE}/events`, - }, - { - id: "members-site", - name: "Members", - link: URLS.MEMBERS_SITE, - }, - { - id: "status-site", - name: "Status", - link: URLS.STATUS_SITE, - }, -]; diff --git a/src/components/common/Navbar/navbar.types.ts b/src/components/common/Navbar/navbar.types.ts deleted file mode 100644 index 2527636..0000000 --- a/src/components/common/Navbar/navbar.types.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type NavbarLink = { - id: string; - name: string; - link: string; -}; diff --git a/src/components/drawer/Drawer.tsx b/src/components/drawer/Drawer.tsx deleted file mode 100644 index 6f7c208..0000000 --- a/src/components/drawer/Drawer.tsx +++ /dev/null @@ -1,33 +0,0 @@ -"use client"; -import React, { ReactNode } from "react"; -import { IoCloseOutline } from "react-icons/io5"; -import classNames from "classnames"; -type DrawerProps = { - open: Boolean; - onClose: () => void; - children?: ReactNode; -}; - -const Drawer = ({ open, onClose, children }: DrawerProps) => { - return ( -
    - - {children} -
    - ); -}; - -export default Drawer; diff --git a/src/components/endorsementCard/EndorsementCard.tsx b/src/components/endorsementCard/EndorsementCard.tsx deleted file mode 100644 index 0d27935..0000000 --- a/src/components/endorsementCard/EndorsementCard.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { TRUNCATION_LENGTH } from "@/constants/comman"; -import { useState } from "react"; - -type EndorsementCardProps = { - name: string; - description: string; -}; - -const EndorsementCard = ({ name, description }: EndorsementCardProps) => { - const showToggleDescButton = description.length > TRUNCATION_LENGTH; - - const [showFullDescription, setShowFullDescription] = useState(false); - - const toggleDescription = () => { - setShowFullDescription((prev) => !prev); - }; - - return ( -
  • -
    - - {name.charAt(0)} - -
    {name}
    -
    - -

    - {showFullDescription ? description : description.slice(0, TRUNCATION_LENGTH)} - {showToggleDescButton ? ( - - ) : null} -

    -
  • - ); -}; - -export default EndorsementCard; diff --git a/src/components/endorsementDetailsSlideOver/EndorsementDetailsSlideOver.tsx b/src/components/endorsementDetailsSlideOver/EndorsementDetailsSlideOver.tsx deleted file mode 100644 index 205f2c7..0000000 --- a/src/components/endorsementDetailsSlideOver/EndorsementDetailsSlideOver.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import React from "react"; -import Drawer from "../drawer/Drawer"; -import Tag from "../tag/Tag"; -import { RxCross2 } from "react-icons/rx"; -import { IoCheckmarkSharp } from "react-icons/io5"; -import endorsementDetails from "../../../__mocks__/db/endorsementDetails.json"; -import EndorsementCard from "../endorsementCard/EndorsementCard"; -import Button from "@/components/Button"; - -type EndorsementDetailsSlideOverProps = { - endorsementId: string; - open: Boolean; - onClose: () => void; -}; - -const EndorsementDetailsSlideOver = ({ endorsementId, open, onClose }: EndorsementDetailsSlideOverProps) => { - const data = endorsementDetails.find((end) => end.id === endorsementId); - - return ( - -
    -

    {data?.title}

    -

    {data?.date}

    -

    Skills: {data?.skills}

    -
    Endorsers: {data?.endorsers.join(", ")}
    - Atomic -
    - -
    -

    Endorsements

    - -
      - {data?.endorsements.map((end) => ( - - ))} -
    -
    - -
    - - -
    -
    - ); -}; - -export default EndorsementDetailsSlideOver; diff --git a/src/components/tag/Tag.tsx b/src/components/tag/Tag.tsx deleted file mode 100644 index c88ad96..0000000 --- a/src/components/tag/Tag.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import React, { ReactNode } from "react"; - -export type TagProps = { - children: ReactNode; -}; - -const Tag = ({ children }: TagProps) => { - return ( - - {children} - - ); -}; - -export default Tag; diff --git a/src/constants/comman.ts b/src/constants/comman.ts deleted file mode 100644 index e554769..0000000 --- a/src/constants/comman.ts +++ /dev/null @@ -1 +0,0 @@ -export const TRUNCATION_LENGTH = 160; diff --git a/src/constants/image.ts b/src/constants/image.ts deleted file mode 100644 index c13e1e3..0000000 --- a/src/constants/image.ts +++ /dev/null @@ -1,3 +0,0 @@ -const dummyImg = "/dummy-img.svg"; - -export { dummyImg }; diff --git a/src/constants/request-board.ts b/src/constants/request-board.ts deleted file mode 100644 index 7b09483..0000000 --- a/src/constants/request-board.ts +++ /dev/null @@ -1,43 +0,0 @@ -const REQUEST_BOARD_TABLE_CATEGORIES = { - NAME: "Name", - SKILL: "Skill", - VOTES: "Votes", -}; - -const BUTTON_VARIANTS = { - DEFAULT: "default", - TEXT: "text", - OUTLINED: "outlined", - PRIMARY: "primary", - SECONDARY: "secondary", -}; - -const INPUT_VARIANTS = { - OUTLINED: "outlined", - FILLED: "filled", -}; - -const ROUNDNESS_VARIANTS = { - PILL: "pill", - SQUARE: "square", - MEDIUM: "medium", -}; - -const COLOR_SCHEMES = { - GREEN: "green", - BLUE: "blue", - YELLOW: "yellow", -}; - -type SkillLabelColor = "green" | "yellow" | "blue"; - -const SKILL_LABEL_COLOR_MAPPING: SkillLabelColor[] = ["green", "blue", "blue", "yellow", "green", "blue"]; - -export { - REQUEST_BOARD_TABLE_CATEGORIES, - COLOR_SCHEMES, - ROUNDNESS_VARIANTS, - BUTTON_VARIANTS, - INPUT_VARIANTS, - SKILL_LABEL_COLOR_MAPPING, -}; diff --git a/src/constants/urls.ts b/src/constants/urls.ts deleted file mode 100644 index 9a9dbe4..0000000 --- a/src/constants/urls.ts +++ /dev/null @@ -1,50 +0,0 @@ -type Urls = { - [key: string]: { - BACKEND_BASE_URL: string; - RDS_BACKEND_URL: string; - SKILL_TREE_SITE: string; - STATUS_SITE: string; - MEMBERS_SITE: string; - WELCOME_SITE: string; - WWW_SITE: string; - MY_SITE: string; - }; -}; - -export const URLS_MAP: Urls = { - production: { - BACKEND_BASE_URL: "https://skilltree-api.realdevsquad.com/v1", - RDS_BACKEND_URL: "https://api.realdevsquad.com", - SKILL_TREE_SITE: "https:/skilltree.realdevsquad.com", - STATUS_SITE: "https://status.realdevsquad.com", - MEMBERS_SITE: "https://members.realdevsquad.com", - WELCOME_SITE: "https://welcome.realdevsquad.com", - WWW_SITE: "https://www.realdevsquad.com", - MY_SITE: "https://my.realdevsquad.com", - }, - staging: { - BACKEND_BASE_URL: "https://staging-skilltree-api.realdevsquad.com/v1", - RDS_BACKEND_URL: "https://staging-api.realdevsquad.com", - SKILL_TREE_SITE: "https://staging-skilltree.realdevsquad.com", - STATUS_SITE: "https://staging-status.realdevsquad.com", - MEMBERS_SITE: "https://staging-members.realdevsquad.com", - WELCOME_SITE: "https://welcome.realdevsquad.com", - WWW_SITE: "https://staging-www.realdevsquad.com", - MY_SITE: "https://staging-my.realdevsquad.com", - }, - development: { - BACKEND_BASE_URL: "https://staging-skilltree-api.realdevsquad.com/v1", - RDS_BACKEND_URL: "http://localhost:3000", - SKILL_TREE_SITE: "http://localhost:4000", - STATUS_SITE: "https://staging-status.realdevsquad.com", - MEMBERS_SITE: "https://staging-members.realdevsquad.com", - WELCOME_SITE: "https://welcome.realdevsquad.com", - WWW_SITE: "https://staging-www.realdevsquad.com", - MY_SITE: "https://staging-my.realdevsquad.com", - }, -}; - -export const URLS = { ...URLS_MAP[process.env.NEXT_PUBLIC_APP_ENV] }; - -export const BASE_URL: string = URLS.BACKEND_BASE_URL; -export const RDS_BACKEND_URL: string = URLS.RDS_BACKEND_URL; diff --git a/src/hooks/useScrollDirection.ts b/src/hooks/useScrollDirection.ts deleted file mode 100644 index 410fccd..0000000 --- a/src/hooks/useScrollDirection.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { useState, useEffect } from "react"; - -type ScrollDirectionType = "up" | "down"; - -function useScrollDirection() { - const [scrollDirection, setScrollDirection] = useState("up"); - - useEffect(() => { - let previousScrollYPosition = window.scrollY; - - function updateScrollDirection() { - const currentScrollYPosition = window.scrollY; - const newScrollDirection = currentScrollYPosition < previousScrollYPosition ? "up" : "down"; - setScrollDirection(newScrollDirection); - previousScrollYPosition = currentScrollYPosition > 0 ? currentScrollYPosition : 0; - } - - const onScroll = function () { - return window.requestAnimationFrame(updateScrollDirection); - }; - - window.addEventListener("scroll", onScroll); - - return () => window.removeEventListener("scroll", onScroll); - }, []); - - return scrollDirection; -} - -export { useScrollDirection }; diff --git a/src/pages/endorsements/index.tsx b/src/pages/endorsements/index.tsx deleted file mode 100644 index f477975..0000000 --- a/src/pages/endorsements/index.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import React, { FC } from "react"; -import { DropDown } from "@/components/DropDown"; -import Layout from "@/components/Layout"; -import SearchBox from "@/components/SearchBox"; -import { BsHandThumbsUp, BsHandThumbsDown } from "react-icons/bs"; -import SkillLabel from "@/components/SkillLabel"; -import { endorsementsListsMock } from "../../../__mocks__/endorsements"; - -const Endorsements: FC = () => { - return ( - -
    -
    -

    Endorsements

    -
    - -
    - {endorsementsListsMock.map((endorsement) => ( - -
    -

    {endorsement.endorserName}

    - -
    -
    - ))} -
    -
    -
    -
    -

    Prakash

    -
    -

    skill:

    - -
    - -
    -

    vote:

    - - -
    -
    -

    Description

    - -
    - -
    -
    -
    - ); -}; - -export default Endorsements; diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 746d74f..d247b4a 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,73 +1,9 @@ -"use client"; - -import { IoFilterOutline } from "react-icons/io5"; -import { AiOutlineRight, AiOutlineLeft } from "react-icons/ai"; -import { useScrollDirection } from "@/hooks/useScrollDirection"; -import Wrapper from "@/components/Wrapper"; -import SearchBox from "@/components/SearchBox"; -import Button from "@/components/Button"; -import RequestBoardTable from "@/components/RequestBoardTable"; -import EndorsementDetailsSlideOver from "@/components/endorsementDetailsSlideOver/EndorsementDetailsSlideOver"; -import { useState } from "react"; -import Layout from "@/components/Layout"; - export default function Home() { - const scrollDirection = useScrollDirection(); - - const [open, setOpen] = useState(false); - - const handleSlideover = (value: Boolean) => { - setOpen(value); - }; - return ( - -
    - handleSlideover(false)} open={open} /> - -
    - -

    Request board

    -
    - -
    -

    Request board

    -
    - - -
    -
    -
    - - handleSlideover(true)} /> - - -
    - - -
    -
    -
    -
    -
    +
    +
    + Homepage +
    +
    ); } diff --git a/src/services/endorsements.js b/src/services/endorsements.js deleted file mode 100644 index c4dfed2..0000000 --- a/src/services/endorsements.js +++ /dev/null @@ -1,13 +0,0 @@ -import { useQuery, useMutation } from "@tanstack/react-query"; -import { BASE_URL } from "@/constants/urls"; -export const useGetEndorsements = () => - useQuery({ - queryKey: ["endorsements"], - queryFn: () => fetch(`${BASE_URL}/endorsements`).then((res) => res.json()), - }); - -export const usePostEndorsement = ({ endorsementData }) => - useMutation({ - mutationKey: ["endorsements"], - mutationFn: () => fetch(`${BASE_URL}/endorsements`, endorsementData).then((res) => res.json()), - }); diff --git a/src/services/users.ts b/src/services/users.ts deleted file mode 100644 index c65f3bf..0000000 --- a/src/services/users.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { useQuery } from "@tanstack/react-query"; -import { RDS_BACKEND_URL } from "@/constants/urls"; -import axios from "axios"; - -export const useGetSelfUser = () => - useQuery({ - queryKey: ["users.getSelfUser"], - queryFn: () => - axios - .get(`${RDS_BACKEND_URL}/users/self`, { - withCredentials: true, - headers: { "Content-Type": "application/json" }, - }) - .then((res) => res.data), - onError(err) { - return err; - }, - }); diff --git a/src/setupTests.js b/src/setupTests.js deleted file mode 100644 index 018af82..0000000 --- a/src/setupTests.js +++ /dev/null @@ -1,17 +0,0 @@ -import "@testing-library/jest-dom/extend-expect"; - -const { server } = require("../__mocks__/server"); - -beforeAll(() => { - server.listen({ - onUnhandledRequest: "warn", - }); -}); - -afterEach(() => { - server.resetHandlers(); -}); - -afterAll(() => { - server.close(); -}); diff --git a/src/types/index.d.ts b/src/types/index.d.ts deleted file mode 100644 index 67f1434..0000000 --- a/src/types/index.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -interface Skill { - id; - name: string; - type: string; -} -interface User { - id; - name: string; -} -interface Endorsers extends User { - description: string; - type: "POSITIVE" | "NEGATIVE"; -} -interface Endorsement { - user: User; - skill: Skill; - created_at: Date; - endorsers: Endorsers[]; -} diff --git a/src/types/users.d.ts b/src/types/users.d.ts deleted file mode 100644 index 0b32851..0000000 --- a/src/types/users.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -export type UserProfileStatus = "PENDING" | "BLOCKED" | "VERIFIED"; - -export type UserStatus = "ooo" | "idle" | "active" | "onboarding"; - -export type UserData = { - id: string; - profileURL?: string; - discordJoinedAt?: string; - roles: { - archived: boolean; - in_discord: boolean; - member?: boolean; - maven?: boolean; - designer?: boolean; - product_manager?: boolean; - super_user?: boolean; - }; - profileStatus?: UserProfileStatus; - status?: UserStatus; - yoe?: number; - github_created_at: number; - company?: string; - twitter_id?: string; - first_name?: string; - incompleteUserDetails: boolean; - discordId?: string; - last_name?: string; - linkedin_id?: string; - picture?: { - url?: string; - publicId?: string; - }; - instagram_id?: string; - github_display_name: string; - github_id: string; - designation?: string; - username?: string; - created_at: number; - updated_at: number; - github_user_id: string; - website?: string; -}; diff --git a/tailwind.config.js b/tailwind.config.js deleted file mode 100644 index 14373a2..0000000 --- a/tailwind.config.js +++ /dev/null @@ -1,60 +0,0 @@ -/** @type {import('tailwindcss').Config} */ -module.exports = { - content: [ - "./src/pages/**/*.{js,ts,jsx,tsx,mdx}", - "./src/components/**/*.{js,ts,jsx,tsx,mdx}", - "./src/app/**/*.{js,ts,jsx,tsx,mdx}", - ], - theme: { - extend: { - textColor: { - black: "#020617", - blueBerry: "#3B82F6", - magicRed: "#F43F5E", - cadetGrey: "#94A3B8", - slatGrey: "#64748B", - }, - backgroundColor: { - aliceBlue: "#EFF6FF", - lavendarBlush: "#FFF1F2", - }, - borderColor: { - azuresihWhite: "#E2E8F0", - }, - }, - colors: { - primary: "#041187", - secondary: "#E30062", - contrast: "#85DA6B", - green: "#059669", - red: { - 100: "#FEF2F2", - 300: "#FCA5A5", - 500: "#DC2626", - 600: "#E13110", - }, - transparent: "transparent", - black: { - dark: "#000", - light: "#4B5563", - }, - white: "#fff", - gray: { - 100: "#F3F4F6", - 400: "#e5e5e5", - 500: "#e6e6e6", - 600: "#D9D9D9", - 300: "#475569", - 700: "#334155", - 800: "#78716c", - }, - yellow: { - dark: "#A16207", - light: "#FEF3C7", - 100: "#FAF8F5", - }, - blue: { 700: "#1D4ED8", 100: "#F8FAFC", 200: "#F1F5F9", 300: "#E2E8F0" }, - }, - }, - plugins: [], -}; diff --git a/tailwind.config.ts b/tailwind.config.ts new file mode 100644 index 0000000..ee7937e --- /dev/null +++ b/tailwind.config.ts @@ -0,0 +1,14 @@ +import type { Config } from "tailwindcss"; + +const config: Config = { + content: ["./src/**/*.{js,ts,jsx,tsx,mdx}"], + theme: { + extend: { + fontFamily: { + sans: ["var(--font-inter)"], + }, + }, + }, + plugins: [], +}; +export default config; diff --git a/tsconfig.json b/tsconfig.json index bf99860..9cbea6e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,31 +5,24 @@ "allowJs": true, "skipLibCheck": true, "strict": true, - "forceConsistentCasingInFileNames": true, "noEmit": true, "esModuleInterop": true, "module": "esnext", - "moduleResolution": "node", + "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve", "incremental": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@/*": ["./src/*"] + }, "plugins": [ { "name": "next" } - ], - "paths": { - "@/*": ["./src/*"] - } + ] }, - "include": [ - "process-env.d.ts", - "next-env.d.ts", - "**/*.ts", - "**/*.tsx", - ".next/types/**/*.ts", - "src/pages/_app.tsx" - ], + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], "exclude": ["node_modules"] } diff --git a/yarn.lock b/yarn.lock index 215db23..8fe3e37 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3167,7 +3167,7 @@ __metadata: languageName: node linkType: hard -"eslint-plugin-import@npm:^2.26.0": +"eslint-plugin-import@npm:^2.26.0, eslint-plugin-import@npm:^2.29.1": version: 2.29.1 resolution: "eslint-plugin-import@npm:2.29.1" dependencies: @@ -5751,6 +5751,7 @@ __metadata: eslint: "npm:8.41.0" eslint-config-next: "npm:13.4.4" eslint-config-prettier: "npm:^8.8.0" + eslint-plugin-import: "npm:^2.29.1" eslint-plugin-jsx-a11y: "npm:^6.7.1" eslint-plugin-next: "npm:^0.0.0" eslint-plugin-prettier: "npm:^4.2.1" @@ -5765,6 +5766,7 @@ __metadata: npm-run-all: "npm:^4.1.5" postcss: "npm:8.4.23" prettier: "npm:^2.8.8" + prettier-plugin-tailwindcss: "npm:^0.6.5" react: "npm:18.2.0" react-dom: "npm:18.2.0" react-icons: "npm:^4.10.1" @@ -6512,6 +6514,61 @@ __metadata: languageName: node linkType: hard +"prettier-plugin-tailwindcss@npm:^0.6.5": + version: 0.6.5 + resolution: "prettier-plugin-tailwindcss@npm:0.6.5" + peerDependencies: + "@ianvs/prettier-plugin-sort-imports": "*" + "@prettier/plugin-pug": "*" + "@shopify/prettier-plugin-liquid": "*" + "@trivago/prettier-plugin-sort-imports": "*" + "@zackad/prettier-plugin-twig-melody": "*" + prettier: ^3.0 + prettier-plugin-astro: "*" + prettier-plugin-css-order: "*" + prettier-plugin-import-sort: "*" + prettier-plugin-jsdoc: "*" + prettier-plugin-marko: "*" + prettier-plugin-organize-attributes: "*" + prettier-plugin-organize-imports: "*" + prettier-plugin-sort-imports: "*" + prettier-plugin-style-order: "*" + prettier-plugin-svelte: "*" + peerDependenciesMeta: + "@ianvs/prettier-plugin-sort-imports": + optional: true + "@prettier/plugin-pug": + optional: true + "@shopify/prettier-plugin-liquid": + optional: true + "@trivago/prettier-plugin-sort-imports": + optional: true + "@zackad/prettier-plugin-twig-melody": + optional: true + prettier-plugin-astro: + optional: true + prettier-plugin-css-order: + optional: true + prettier-plugin-import-sort: + optional: true + prettier-plugin-jsdoc: + optional: true + prettier-plugin-marko: + optional: true + prettier-plugin-organize-attributes: + optional: true + prettier-plugin-organize-imports: + optional: true + prettier-plugin-sort-imports: + optional: true + prettier-plugin-style-order: + optional: true + prettier-plugin-svelte: + optional: true + checksum: 10c0/30d62928592b48cab03c46ff63edd35d4a33c4e7c40e583f12bff7223eba8b6f780fd394965b0250160bcf39688f6fb602420374b2055bcbb6a69560b818ca4e + languageName: node + linkType: hard + "prettier@npm:^2.8.8": version: 2.8.8 resolution: "prettier@npm:2.8.8"