From 1634bf0d1c24592f71838ad24bae3caffecbefc9 Mon Sep 17 00:00:00 2001 From: MTG2000 Date: Thu, 14 Jul 2022 08:34:50 +0300 Subject: [PATCH 1/6] update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ecdc8aa..624094d 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ yarn-debug.log* yarn-error.log* TODO +NOTES \ No newline at end of file From 822fd8048703c1901d328d85d3e4569f81e1cb64 Mon Sep 17 00:00:00 2001 From: MTG2000 Date: Thu, 14 Jul 2022 09:41:28 +0300 Subject: [PATCH 2/6] udpate graphql schema --- api/functions/graphql/schema.graphql | 269 --------------------------- 1 file changed, 269 deletions(-) delete mode 100644 api/functions/graphql/schema.graphql diff --git a/api/functions/graphql/schema.graphql b/api/functions/graphql/schema.graphql deleted file mode 100644 index b334d3f..0000000 --- a/api/functions/graphql/schema.graphql +++ /dev/null @@ -1,269 +0,0 @@ -### This file was generated by Nexus Schema -### Do not make changes to this file directly - - -type Author { - avatar: String! - id: Int! - join_date: Date! - name: String! -} - -type Award { - id: Int! - image: String! - project: Project! - title: String! - url: String! -} - -type Bounty implements PostBase { - applicants_count: Int! - applications: [BountyApplication!]! - author: Author! - body: String! - cover_image: String - createdAt: Date! - deadline: String! - excerpt: String! - id: Int! - is_published: Boolean - reward_amount: Int! - tags: [Tag!]! - title: String! - type: String! - updatedAt: Date! - votes_count: Int! -} - -type BountyApplication { - author: Author! - date: String! - id: Int! - workplan: String! -} - -type Category { - apps_count: Int! - cover_image: String - icon: String - id: Int! - project: [Project!]! - title: String! - votes_sum: Int! -} - -"""Date custom scalar type""" -scalar Date - -type Donation { - amount: Int! - by: User - createdAt: Date! - id: Int! - paid: Boolean! - payment_hash: String! - payment_request: String! -} - -type DonationsStats { - applications: String! - donations: String! - prizes: String! - touranments: String! -} - -type Hackathon { - cover_image: String! - description: String! - end_date: Date! - id: Int! - location: String! - start_date: Date! - tags: [Tag!]! - title: String! - website: String! -} - -type LnurlDetails { - commentAllowed: Int - maxSendable: Int - metadata: String - minSendable: Int -} - -type Mutation { - confirmDonation(payment_request: String!, preimage: String!): Donation! - confirmVote(payment_request: String!, preimage: String!): Vote! - createStory(data: StoryInputType): Story - deleteStory(id: Int!): Story - donate(amount_in_sat: Int!): Donation! - updateProfile(data: UpdateProfileInput): User - vote(amount_in_sat: Int!, item_id: Int!, item_type: VOTE_ITEM_TYPE!): Vote! -} - -enum POST_TYPE { - Bounty - Question - Story -} - -union Post = Bounty | Question | Story - -interface PostBase { - body: String! - createdAt: Date! - excerpt: String! - id: Int! - is_published: Boolean - title: String! - updatedAt: Date! - votes_count: Int! -} - -type PostComment { - author: Author! - body: String! - createdAt: Date! - id: Int! - parentId: Int - votes_count: Int! -} - -type Project { - awards: [Award!]! - category: Category! - cover_image: String! - description: String! - id: Int! - lightning_address: String - lnurl_callback_url: String - screenshots: [String!]! - tags: [Tag!]! - thumbnail_image: String! - title: String! - votes_count: Int! - website: String! -} - -type Query { - allCategories: [Category!]! - allProjects(skip: Int = 0, take: Int = 50): [Project!]! - getAllHackathons(sortBy: String, tag: Int): [Hackathon!]! - getCategory(id: Int!): Category! - getDonationsStats: DonationsStats! - getFeed(skip: Int = 0, sortBy: String, tag: Int = 0, take: Int = 10): [Post!]! - getLnurlDetailsForProject(project_id: Int!): LnurlDetails! - getMyDrafts(type: POST_TYPE!): [Post!]! - getPostById(id: Int!, type: POST_TYPE!): Post! - getProject(id: Int!): Project! - getTrendingPosts: [Post!]! - hottestProjects(skip: Int = 0, take: Int = 50): [Project!]! - me: User - newProjects(skip: Int = 0, take: Int = 50): [Project!]! - officialTags: [Tag!]! - popularTags: [Tag!]! - profile(id: Int!): User - projectsByCategory(category_id: Int!, skip: Int = 0, take: Int = 10): [Project!]! - searchProjects(search: String!, skip: Int = 0, take: Int = 50): [Project!]! -} - -type Question implements PostBase { - answers_count: Int! - author: Author! - body: String! - comments: [PostComment!]! - createdAt: Date! - excerpt: String! - id: Int! - is_published: Boolean - tags: [Tag!]! - title: String! - type: String! - updatedAt: Date! - votes_count: Int! -} - -type Story implements PostBase { - author: Author! - body: String! - comments: [PostComment!]! - comments_count: Int! - cover_image: String - createdAt: Date! - excerpt: String! - id: Int! - is_published: Boolean - tags: [Tag!]! - title: String! - type: String! - updatedAt: Date! - votes_count: Int! -} - -input StoryInputType { - body: String! - cover_image: String - id: Int - is_published: Boolean - tags: [String!]! - title: String! -} - -type Tag { - description: String - icon: String - id: Int! - isOfficial: Boolean - title: String! -} - -input UpdateProfileInput { - avatar: String - bio: String - email: String - github: String - jobTitle: String - lightning_address: String - linkedin: String - location: String - name: String - twitter: String - website: String -} - -type User { - avatar: String! - bio: String - email: String - github: String - id: Int! - jobTitle: String - join_date: Date! - lightning_address: String - linkedin: String - location: String - name: String! - role: String - twitter: String - website: String -} - -enum VOTE_ITEM_TYPE { - Bounty - PostComment - Project - Question - Story - User -} - -type Vote { - amount_in_sat: Int! - id: Int! - item_id: Int! - item_type: VOTE_ITEM_TYPE! - paid: Boolean! - payment_hash: String! - payment_request: String! -} \ No newline at end of file From 0fea4a9fd838c3a16d190be1ad0d3e3e935920ff Mon Sep 17 00:00:00 2001 From: MTG2000 Date: Wed, 20 Jul 2022 18:43:54 +0300 Subject: [PATCH 3/6] update: graphql schema --- api/functions/graphql/schema.graphql | 269 +++++++++++++++++++++++++++ 1 file changed, 269 insertions(+) create mode 100644 api/functions/graphql/schema.graphql diff --git a/api/functions/graphql/schema.graphql b/api/functions/graphql/schema.graphql new file mode 100644 index 0000000..b334d3f --- /dev/null +++ b/api/functions/graphql/schema.graphql @@ -0,0 +1,269 @@ +### This file was generated by Nexus Schema +### Do not make changes to this file directly + + +type Author { + avatar: String! + id: Int! + join_date: Date! + name: String! +} + +type Award { + id: Int! + image: String! + project: Project! + title: String! + url: String! +} + +type Bounty implements PostBase { + applicants_count: Int! + applications: [BountyApplication!]! + author: Author! + body: String! + cover_image: String + createdAt: Date! + deadline: String! + excerpt: String! + id: Int! + is_published: Boolean + reward_amount: Int! + tags: [Tag!]! + title: String! + type: String! + updatedAt: Date! + votes_count: Int! +} + +type BountyApplication { + author: Author! + date: String! + id: Int! + workplan: String! +} + +type Category { + apps_count: Int! + cover_image: String + icon: String + id: Int! + project: [Project!]! + title: String! + votes_sum: Int! +} + +"""Date custom scalar type""" +scalar Date + +type Donation { + amount: Int! + by: User + createdAt: Date! + id: Int! + paid: Boolean! + payment_hash: String! + payment_request: String! +} + +type DonationsStats { + applications: String! + donations: String! + prizes: String! + touranments: String! +} + +type Hackathon { + cover_image: String! + description: String! + end_date: Date! + id: Int! + location: String! + start_date: Date! + tags: [Tag!]! + title: String! + website: String! +} + +type LnurlDetails { + commentAllowed: Int + maxSendable: Int + metadata: String + minSendable: Int +} + +type Mutation { + confirmDonation(payment_request: String!, preimage: String!): Donation! + confirmVote(payment_request: String!, preimage: String!): Vote! + createStory(data: StoryInputType): Story + deleteStory(id: Int!): Story + donate(amount_in_sat: Int!): Donation! + updateProfile(data: UpdateProfileInput): User + vote(amount_in_sat: Int!, item_id: Int!, item_type: VOTE_ITEM_TYPE!): Vote! +} + +enum POST_TYPE { + Bounty + Question + Story +} + +union Post = Bounty | Question | Story + +interface PostBase { + body: String! + createdAt: Date! + excerpt: String! + id: Int! + is_published: Boolean + title: String! + updatedAt: Date! + votes_count: Int! +} + +type PostComment { + author: Author! + body: String! + createdAt: Date! + id: Int! + parentId: Int + votes_count: Int! +} + +type Project { + awards: [Award!]! + category: Category! + cover_image: String! + description: String! + id: Int! + lightning_address: String + lnurl_callback_url: String + screenshots: [String!]! + tags: [Tag!]! + thumbnail_image: String! + title: String! + votes_count: Int! + website: String! +} + +type Query { + allCategories: [Category!]! + allProjects(skip: Int = 0, take: Int = 50): [Project!]! + getAllHackathons(sortBy: String, tag: Int): [Hackathon!]! + getCategory(id: Int!): Category! + getDonationsStats: DonationsStats! + getFeed(skip: Int = 0, sortBy: String, tag: Int = 0, take: Int = 10): [Post!]! + getLnurlDetailsForProject(project_id: Int!): LnurlDetails! + getMyDrafts(type: POST_TYPE!): [Post!]! + getPostById(id: Int!, type: POST_TYPE!): Post! + getProject(id: Int!): Project! + getTrendingPosts: [Post!]! + hottestProjects(skip: Int = 0, take: Int = 50): [Project!]! + me: User + newProjects(skip: Int = 0, take: Int = 50): [Project!]! + officialTags: [Tag!]! + popularTags: [Tag!]! + profile(id: Int!): User + projectsByCategory(category_id: Int!, skip: Int = 0, take: Int = 10): [Project!]! + searchProjects(search: String!, skip: Int = 0, take: Int = 50): [Project!]! +} + +type Question implements PostBase { + answers_count: Int! + author: Author! + body: String! + comments: [PostComment!]! + createdAt: Date! + excerpt: String! + id: Int! + is_published: Boolean + tags: [Tag!]! + title: String! + type: String! + updatedAt: Date! + votes_count: Int! +} + +type Story implements PostBase { + author: Author! + body: String! + comments: [PostComment!]! + comments_count: Int! + cover_image: String + createdAt: Date! + excerpt: String! + id: Int! + is_published: Boolean + tags: [Tag!]! + title: String! + type: String! + updatedAt: Date! + votes_count: Int! +} + +input StoryInputType { + body: String! + cover_image: String + id: Int + is_published: Boolean + tags: [String!]! + title: String! +} + +type Tag { + description: String + icon: String + id: Int! + isOfficial: Boolean + title: String! +} + +input UpdateProfileInput { + avatar: String + bio: String + email: String + github: String + jobTitle: String + lightning_address: String + linkedin: String + location: String + name: String + twitter: String + website: String +} + +type User { + avatar: String! + bio: String + email: String + github: String + id: Int! + jobTitle: String + join_date: Date! + lightning_address: String + linkedin: String + location: String + name: String! + role: String + twitter: String + website: String +} + +enum VOTE_ITEM_TYPE { + Bounty + PostComment + Project + Question + Story + User +} + +type Vote { + amount_in_sat: Int! + id: Int! + item_id: Int! + item_type: VOTE_ITEM_TYPE! + paid: Boolean! + payment_hash: String! + payment_request: String! +} \ No newline at end of file From 99eb7e507b141cb2d99595bda54057b954eb36e4 Mon Sep 17 00:00:00 2001 From: MTG2000 Date: Wed, 20 Jul 2022 19:00:00 +0300 Subject: [PATCH 4/6] fix: temp attempt to fix broken posts --- api/functions/graphql/types/post.js | 2 +- environments/.dev.prod-server.env | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/functions/graphql/types/post.js b/api/functions/graphql/types/post.js index 3beddca..ee8c10b 100644 --- a/api/functions/graphql/types/post.js +++ b/api/functions/graphql/types/post.js @@ -72,7 +72,7 @@ const Story = objectType({ t.string('cover_image'); t.nonNull.list.nonNull.field('comments', { type: "PostComment", - resolve: (parent) => prisma.story.findUnique({ where: { id: parent.id } }).comments() + resolve: (parent) => [] }); t.nonNull.list.nonNull.field('tags', { type: "Tag", diff --git a/environments/.dev.prod-server.env b/environments/.dev.prod-server.env index 65016b7..8d3f82e 100644 --- a/environments/.dev.prod-server.env +++ b/environments/.dev.prod-server.env @@ -1 +1 @@ -REACT_APP_API_END_POINT = https://makers.bolt.fu/.netlify/functions \ No newline at end of file +REACT_APP_API_END_POINT = https://makers.bolt.fun/.netlify/functions \ No newline at end of file From 1a8f91825adb9d439377a9b5c6dbf53e9ba2618f Mon Sep 17 00:00:00 2001 From: MTG2000 Date: Tue, 26 Jul 2022 15:42:04 +0300 Subject: [PATCH 5/6] fix: products grid broken on large screens --- .../ExplorePage/ProjectsRow/ProjectsRow.tsx | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/features/Projects/pages/ExplorePage/ProjectsRow/ProjectsRow.tsx b/src/features/Projects/pages/ExplorePage/ProjectsRow/ProjectsRow.tsx index 08717e7..29fbe70 100644 --- a/src/features/Projects/pages/ExplorePage/ProjectsRow/ProjectsRow.tsx +++ b/src/features/Projects/pages/ExplorePage/ProjectsRow/ProjectsRow.tsx @@ -1,4 +1,4 @@ -import { ReactNode, useCallback, useEffect, useRef, useState } from "react"; +import { ReactNode, useCallback, useLayoutEffect, useEffect, useRef, useState } from "react"; import { ProjectCard } from "src/utils/interfaces"; import Carousel from 'react-multi-carousel'; import { MdDoubleArrow, } from 'react-icons/md'; @@ -30,8 +30,8 @@ const responsive = { // return items; // } -function calcNumItems() { - const items = (((window.innerWidth - 2 * 32) / (296 + 20))); +function calcNumItems(width = window.innerWidth) { + const items = ((width / (296 + 20))); return items; } @@ -39,11 +39,9 @@ function calcNumItems() { export default function ProjectsRow({ title, link, projects }: Props) { - const [carouselItmsCnt, setCarouselItmsCnt] = useState(calcNumItems); const dispatch = useAppDispatch() let drag = useRef(false); - - responsive.all.items = carouselItmsCnt + const rowRef = useRef(null!); useEffect(() => { @@ -62,7 +60,6 @@ export default function ProjectsRow({ title, link, projects }: Props) { const handleClick = (projectId: number) => { - console.log(projectId); if (!drag.current) { dispatch(openModal({ Modal: "ProjectDetailsCard", props: { projectId } })) @@ -71,10 +68,15 @@ export default function ProjectsRow({ title, link, projects }: Props) { const recalcItemsCnt = useCallback( () => { - setCarouselItmsCnt(calcNumItems()); + if (rowRef.current) { + responsive.all.items = calcNumItems(rowRef.current.clientWidth) + responsive.all.slidesToSlide = Math.floor(responsive.all.items); + } }, [], - ) + ); + + useLayoutEffect(recalcItemsCnt, [recalcItemsCnt]); useResizeListener(recalcItemsCnt) @@ -91,7 +93,7 @@ export default function ProjectsRow({ title, link, projects }: Props) { } -
+
Date: Tue, 26 Jul 2022 20:08:49 +0300 Subject: [PATCH 6/6] fix: flickering on mount in products grid --- .../ExplorePage/ProjectsRow/ProjectsRow.tsx | 50 +++++++++---------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/src/features/Projects/pages/ExplorePage/ProjectsRow/ProjectsRow.tsx b/src/features/Projects/pages/ExplorePage/ProjectsRow/ProjectsRow.tsx index 29fbe70..76ba7fd 100644 --- a/src/features/Projects/pages/ExplorePage/ProjectsRow/ProjectsRow.tsx +++ b/src/features/Projects/pages/ExplorePage/ProjectsRow/ProjectsRow.tsx @@ -1,4 +1,4 @@ -import { ReactNode, useCallback, useLayoutEffect, useEffect, useRef, useState } from "react"; +import { ReactNode, useCallback, useLayoutEffect, useEffect, useRef, } from "react"; import { ProjectCard } from "src/utils/interfaces"; import Carousel from 'react-multi-carousel'; import { MdDoubleArrow, } from 'react-icons/md'; @@ -8,7 +8,6 @@ import { useResizeListener } from 'src/utils/hooks' import { IoIosArrowBack, IoIosArrowForward } from "react-icons/io"; import './style.css'; import { Link } from "react-router-dom"; -import { openProject } from "src/redux/features/project.slice"; import ProjectCardMini from "src/features/Projects/Components/ProjectCardMini/ProjectCardMini"; interface Props { @@ -21,16 +20,12 @@ const responsive = { all: { breakpoint: { max: 5000, min: 0 }, items: calcNumItems(), - slidesToSlide: Math.floor(calcNumItems()) + slidesToSlide: Math.round(calcNumItems()) } } -// const calcNumItems = () => { -// const items = (((window.innerWidth - 32 - 296) / (296 + 20))); -// return items; -// } -function calcNumItems(width = window.innerWidth) { +function calcNumItems(width = Math.min(window.innerWidth - 32, 1440)) { const items = ((width / (296 + 20))); return items; } @@ -40,11 +35,25 @@ function calcNumItems(width = window.innerWidth) { export default function ProjectsRow({ title, link, projects }: Props) { const dispatch = useAppDispatch() + let drag = useRef(false); const rowRef = useRef(null!); + const recalcItemsCnt = useCallback( + () => { + if (rowRef.current) { + const count = calcNumItems(rowRef.current.clientWidth); + responsive.all.items = count; + responsive.all.slidesToSlide = Math.round(count) + } + }, + [], + ); + useLayoutEffect(recalcItemsCnt, [recalcItemsCnt]); + useResizeListener(recalcItemsCnt) useEffect(() => { + const mousedownListener = () => drag.current = false const mousemoveListener = () => drag.current = true @@ -55,34 +64,21 @@ export default function ProjectsRow({ title, link, projects }: Props) { document.removeEventListener('mousedown', mousedownListener); document.removeEventListener('mousemove', mousemoveListener); } - }, []) + }, []); + + + + if (projects.length === 0) + return <> const handleClick = (projectId: number) => { - if (!drag.current) { dispatch(openModal({ Modal: "ProjectDetailsCard", props: { projectId } })) } } - const recalcItemsCnt = useCallback( - () => { - if (rowRef.current) { - responsive.all.items = calcNumItems(rowRef.current.clientWidth) - responsive.all.slidesToSlide = Math.floor(responsive.all.items); - } - }, - [], - ); - - useLayoutEffect(recalcItemsCnt, [recalcItemsCnt]); - - - useResizeListener(recalcItemsCnt) - - if (projects.length === 0) - return <> return (