From c5f640e405d288673e17af6f58b3ef2d93fd7f09 Mon Sep 17 00:00:00 2001 From: MTG2000 Date: Sat, 17 Sep 2022 12:14:22 +0300 Subject: [PATCH 1/4] refactor: change story&feed routes structure, change default route, add banner to feed page, fix Loadable component props typing --- api/functions/graphql/nexus-typegen.ts | 1 + src/App.tsx | 7 ++-- src/Components/Navbar/NavDesktop.tsx | 6 ++-- src/Components/Navbar/NavMobile.tsx | 4 +-- .../pages/HackathonsPage/HackathonsPage.tsx | 2 +- .../PostCard/StoryCard/StoryCard.tsx | 2 +- .../pages/CreatePostPage/CreatePostPage.tsx | 9 ++--- .../Posts/pages/FeedPage/FeedPage.tsx | 18 +++++++++- .../Components/PostActions/PostActions.tsx | 3 +- .../pages/PostDetailsPage/PostDetailsPage.tsx | 16 ++++++--- src/utils/routing/loadable.tsx | 12 ++++--- src/utils/routing/routes.ts | 33 +++++++++++-------- 12 files changed, 73 insertions(+), 40 deletions(-) diff --git a/api/functions/graphql/nexus-typegen.ts b/api/functions/graphql/nexus-typegen.ts index 5c95153..d405ede 100644 --- a/api/functions/graphql/nexus-typegen.ts +++ b/api/functions/graphql/nexus-typegen.ts @@ -114,6 +114,7 @@ export interface NexusGenObjects { applicants_count: number; // Int! applications: NexusGenRootTypes['BountyApplication'][]; // [BountyApplication!]! body: string; // String! + cover_image?: string | null; // String createdAt: NexusGenScalars['Date']; // Date! deadline: string; // String! excerpt: string; // String! diff --git a/src/App.tsx b/src/App.tsx index 0ac275f..4234abe 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -92,15 +92,16 @@ function App() { }> - } /> + } /> }> } /> } /> } /> - } /> + } /> } /> + } /> } /> @@ -114,7 +115,7 @@ function App() { } /> } /> - } /> + } /> diff --git a/src/Components/Navbar/NavDesktop.tsx b/src/Components/Navbar/NavDesktop.tsx index 3088142..d752197 100644 --- a/src/Components/Navbar/NavDesktop.tsx +++ b/src/Components/Navbar/NavDesktop.tsx @@ -14,7 +14,7 @@ import { import '@szhsin/react-menu/dist/index.css'; import { FiChevronDown } from "react-icons/fi"; import Avatar from "src/features/Profiles/Components/Avatar/Avatar"; -import { createRoute } from "src/utils/routing"; +import { createRoute, PAGES_ROUTES } from "src/utils/routing"; import Button from "../Button/Button"; @@ -64,10 +64,10 @@ export default function NavDesktop() { menuStyle={{ border: '1px solid' }} > { e.syntheticEvent.preventDefault(); - navigate("/blog"); + navigate(PAGES_ROUTES.blog.feed); }} className='!p-16 font-medium flex gap-16 hover:bg-gray-100 !rounded-12 ' > diff --git a/src/Components/Navbar/NavMobile.tsx b/src/Components/Navbar/NavMobile.tsx index 15a214a..58564bd 100644 --- a/src/Components/Navbar/NavMobile.tsx +++ b/src/Components/Navbar/NavMobile.tsx @@ -14,7 +14,7 @@ import styles from './styles.module.css' import '@szhsin/react-menu/dist/index.css'; import { Menu, MenuButton, MenuItem } from "@szhsin/react-menu"; import Avatar from "src/features/Profiles/Components/Avatar/Avatar"; -import { createRoute } from "src/utils/routing"; +import { createRoute, PAGES_ROUTES } from "src/utils/routing"; const navBtnVariant = { menuHide: { rotate: 90, opacity: 0 }, @@ -186,7 +186,7 @@ export default function NavMobile() { >
toggleDrawerOpen(false)} className='font-medium flex gap-16 !rounded-12 ' > diff --git a/src/features/Hackathons/pages/HackathonsPage/HackathonsPage.tsx b/src/features/Hackathons/pages/HackathonsPage/HackathonsPage.tsx index a69618f..2198817 100644 --- a/src/features/Hackathons/pages/HackathonsPage/HackathonsPage.tsx +++ b/src/features/Hackathons/pages/HackathonsPage/HackathonsPage.tsx @@ -37,7 +37,7 @@ export default function HackathonsPage() {
diff --git a/src/features/Posts/Components/PostCard/StoryCard/StoryCard.tsx b/src/features/Posts/Components/PostCard/StoryCard/StoryCard.tsx index 286a316..d31164c 100644 --- a/src/features/Posts/Components/PostCard/StoryCard/StoryCard.tsx +++ b/src/features/Posts/Components/PostCard/StoryCard/StoryCard.tsx @@ -39,7 +39,7 @@ export default function StoryCard({ story }: Props) { {story.cover_image && }
- +

{story.title}

{story.excerpt}...

diff --git a/src/features/Posts/pages/CreatePostPage/CreatePostPage.tsx b/src/features/Posts/pages/CreatePostPage/CreatePostPage.tsx index 64eb671..840fb70 100644 --- a/src/features/Posts/pages/CreatePostPage/CreatePostPage.tsx +++ b/src/features/Posts/pages/CreatePostPage/CreatePostPage.tsx @@ -6,12 +6,13 @@ import BountyForm from "./Components/BountyForm/BountyForm"; import QuestionForm from "./Components/QuestionForm/QuestionForm"; import CreateStoryPage from "./CreateStoryPage/CreateStoryPage"; +interface Props { + initType: 'story' | 'bounty' | 'question' +} -export default function CreatePostPage() { +export default function CreatePostPage(props: Props) { - const { type } = useParams() - - const [postType] = useState<'story' | 'bounty' | 'question'>((type as any) ?? 'story'); + const [postType] = useState<'story' | 'bounty' | 'question'>(props.initType); const navigate = useNavigate(); diff --git a/src/features/Posts/pages/FeedPage/FeedPage.tsx b/src/features/Posts/pages/FeedPage/FeedPage.tsx index bb3eb84..45c15ba 100644 --- a/src/features/Posts/pages/FeedPage/FeedPage.tsx +++ b/src/features/Posts/pages/FeedPage/FeedPage.tsx @@ -14,6 +14,7 @@ import { FaDiscord } from 'react-icons/fa' import { FiArrowRight } from 'react-icons/fi' import { capitalize } from 'src/utils/helperFunctions' import { bannerData } from 'src/features/Projects/pages/ExplorePage/Header/Header' +import { PAGES_ROUTES } from 'src/utils/routing' export default function FeedPage() { @@ -46,6 +47,21 @@ export default function FeedPage() {
+
+ +
+
+ {bannerData.title} +
+ + +
{tagFilter &&

@@ -76,7 +92,7 @@ export default function FeedPage() {

From f5e48d31c4b6b2f2f6984a732e56a83900c394bd Mon Sep 17 00:00:00 2001 From: MTG2000 Date: Sun, 18 Sep 2022 15:36:43 +0300 Subject: [PATCH 4/4] update: add project-members to DB schema --- .../migration.sql | 14 ++++++++++++++ prisma/schema.prisma | 13 +++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 prisma/migrations/20220918123547_add_project_makers_table/migration.sql diff --git a/prisma/migrations/20220918123547_add_project_makers_table/migration.sql b/prisma/migrations/20220918123547_add_project_makers_table/migration.sql new file mode 100644 index 0000000..42fc30a --- /dev/null +++ b/prisma/migrations/20220918123547_add_project_makers_table/migration.sql @@ -0,0 +1,14 @@ +-- CreateTable +CREATE TABLE "ProjectMember" ( + "projectId" INTEGER NOT NULL, + "userId" INTEGER NOT NULL, + "level" TEXT NOT NULL, + + CONSTRAINT "ProjectMember_pkey" PRIMARY KEY ("projectId","userId") +); + +-- AddForeignKey +ALTER TABLE "ProjectMember" ADD CONSTRAINT "ProjectMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "ProjectMember" ADD CONSTRAINT "ProjectMember_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 1808c83..a0be888 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -70,6 +70,7 @@ model User { userKeys UserKey[] skills Skill[] roles UsersOnWorkRoles[] + projects ProjectMember[] tournaments TournamentParticipant[] } @@ -157,6 +158,7 @@ model Project { tags Tag[] capabilities Capability[] + members ProjectMember[] recruit_roles ProjectRecruitRoles[] tournaments TournamentProject[] } @@ -172,6 +174,17 @@ model ProjectRecruitRoles { @@id([projectId, roleId]) } +model ProjectMember { + project Project @relation(fields: [projectId], references: [id]) + projectId Int + user User @relation(fields: [userId], references: [id]) + userId Int + + level String // Admin | Maker | (new_roles_later) + + @@id([projectId, userId]) +} + model Award { id Int @id @default(autoincrement()) title String