feat: update mocks resolvers

This commit is contained in:
MTG2000
2022-04-17 11:40:07 +03:00
parent ae5cd27b5a
commit 7206910670
6 changed files with 89 additions and 30 deletions

View File

@@ -14,8 +14,8 @@ const { paginationArgs } = require('./helpers');
const PostBase = interfaceType({
name: 'PostBase',
resolveType(post) {
return post.type
resolveType() {
return null
},
definition(t) {
t.nonNull.int('id');

View File

@@ -92,6 +92,7 @@ export let projects = [
"website": "https://getalby.com/",
"lightning_address": "hello@getalby.com",
"votes_count": 335,
tags: [],
"category": {
"id": 9,
"title": "Misc / Other"
@@ -107,6 +108,7 @@ export let projects = [
"website": "https://geyser.fund/",
"lightning_address": "divineorgan67@walletofsatoshi.com",
"votes_count": 232,
tags: [],
"category": {
"id": 1,
"title": "Finance"
@@ -126,6 +128,7 @@ export let projects = [
"website": "https://kollider.xyz/",
"lightning_address": "johns@getalby.com",
"votes_count": 220,
tags: [],
"category": {
"id": 1,
"title": "Finance"
@@ -141,6 +144,7 @@ export let projects = [
"website": "https://lightning.video/",
"lightning_address": "moritz@getalby.com",
"votes_count": 205,
tags: [],
"category": {
"id": 7,
"title": "Media & News"
@@ -156,6 +160,7 @@ export let projects = [
"website": "https://www.wavlake.com/",
"lightning_address": "moritz@getalby.com",
"votes_count": 45,
tags: [],
"category": {
"id": 7,
"title": "Media & News"
@@ -171,6 +176,7 @@ export let projects = [
"website": "https://www.bitrefill.com/buy",
"lightning_address": "moritz@getalby.com",
"votes_count": 25,
tags: [],
"category": {
"id": 8,
"title": "Shopping"
@@ -186,6 +192,7 @@ export let projects = [
"website": "https://sparkshot.io/",
"lightning_address": "johns@getalby.com",
"votes_count": 11,
tags: [],
"category": {
"id": 3,
"title": "Art & Collectibles"
@@ -201,6 +208,7 @@ export let projects = [
"website": "https://lightning-roulette.com/",
"lightning_address": "moritz@getalby.com",
"votes_count": 10,
tags: [],
"category": {
"id": 4,
"title": "Gaming"
@@ -216,9 +224,11 @@ export let projects = [
"website": "https://lnshort.it/",
"lightning_address": "moritz@getalby.com",
"votes_count": 10,
tags: [],
"category": {
"id": 9,
"title": "Misc / Other"
"title": "Misc / Other",
}
},
{
@@ -231,6 +241,7 @@ export let projects = [
"website": "https://lightning.gifts/",
"lightning_address": "moritz@getalby.com",
"votes_count": 10,
tags: [],
"category": {
"id": 8,
"title": "Shopping"
@@ -246,6 +257,7 @@ export let projects = [
"website": "https://www.lnblackjack.com/",
"lightning_address": "moritz@getalby.com",
"votes_count": 5,
tags: [],
"category": {
"id": 4,
"title": "Gaming"
@@ -265,6 +277,7 @@ export let projects = [
"website": "https://satsbuster.herokuapp.com/",
"lightning_address": "subirachs@getalby.com",
"votes_count": 0,
tags: [],
"category": {
"id": 11,
"title": "Shock the Web ⚡️"
@@ -282,6 +295,7 @@ export let projects = [
"website": "https://satstreamer.vercel.app",
"lightning_address": "kiwiidb@getalby.com",
"votes_count": 0,
tags: [],
"category": {
"id": 11,
"title": "Shock the Web ⚡️"
@@ -300,6 +314,7 @@ export let projects = [
"website": "https://github.com/Zrce/tipwall-frontend",
"lightning_address": "tobitcoin@getalby.com",
"votes_count": 0,
tags: [],
"category": {
"id": 11,
"title": "Shock the Web ⚡️"
@@ -325,6 +340,7 @@ export let projects = [
"website": "https://arionparking.tech/",
"lightning_address": "atlantabitdevs@getalby.com",
"votes_count": 0,
tags: [],
"category": {
"id": 11,
"title": "Shock the Web ⚡️"
@@ -342,6 +358,7 @@ export let projects = [
"website": "https://webln.twentyuno.net/widget",
"lightning_address": "reneaaron@getalby.com",
"votes_count": 0,
tags: [],
"category": {
"id": 11,
"title": "Shock the Web ⚡️"
@@ -364,6 +381,7 @@ export let projects = [
"website": "https://lnshop.github.io/lnshop/",
"lightning_address": "alivesession77@walletofsatoshi.com",
"votes_count": 0,
tags: [],
"category": {
"id": 11,
"title": "Shock the Web ⚡️"
@@ -379,6 +397,7 @@ export let projects = [
"website": "https://lnmarkets.com/",
"lightning_address": "johns@getalby.com",
"votes_count": 0,
tags: [],
"category": {
"id": 1,
"title": "Finance"
@@ -400,6 +419,7 @@ export let projects = [
"website": "https://geyser.fund",
"lightning_address": "divineorgan67@walletofsatoshi.com",
"votes_count": 0,
tags: [],
"category": {
"id": 11,
"title": "Shock the Web ⚡️"
@@ -415,6 +435,7 @@ export let projects = [
"website": "https://loft.trade/",
"lightning_address": "moritz@getalby.com",
"votes_count": 0,
tags: [],
"category": {
"id": 1,
"title": "Finance"
@@ -430,6 +451,7 @@ export let projects = [
"website": "https://kriptode.com/satsforlikes/index.html",
"lightning_address": "moritz@getalby.com",
"votes_count": 0,
tags: [],
"category": {
"id": 9,
"title": "Misc / Other"
@@ -445,6 +467,7 @@ export let projects = [
"website": "https://scarce.city/",
"lightning_address": "moritz@getalby.com",
"votes_count": 0,
tags: [],
"category": {
"id": 3,
"title": "Art & Collectibles"
@@ -460,6 +483,7 @@ export let projects = [
"website": "https://stacker.news/",
"lightning_address": "moritz@getalby.com",
"votes_count": 0,
tags: [],
"category": {
"id": 7,
"title": "Media & News"
@@ -475,6 +499,7 @@ export let projects = [
"website": "https://www.starbackr.com/",
"lightning_address": "moritz@geralby.com",
"votes_count": 0,
tags: [],
"category": {
"id": 7,
"title": "Media & News"
@@ -490,6 +515,7 @@ export let projects = [
"website": "https://amboss.space/",
"lightning_address": "moritz@getalby.com",
"votes_count": 0,
tags: [],
"category": {
"id": 6,
"title": "Analytics"
@@ -505,6 +531,7 @@ export let projects = [
"website": "https://yalls.org/",
"lightning_address": "moritz@getalby.com",
"votes_count": 0,
tags: [],
"category": {
"id": 2,
"title": "Social"
@@ -520,6 +547,7 @@ export let projects = [
"website": "https://lightningnetworkstores.com/",
"lightning_address": "moritz@getalby.com",
"votes_count": 0,
tags: [],
"category": {
"id": 8,
"title": "Shopping"
@@ -535,6 +563,7 @@ export let projects = [
"website": "https://lightning-poker.com/",
"lightning_address": "moritz@getalby.com",
"votes_count": 0,
tags: [],
"category": {
"id": 4,
"title": "Gaming"
@@ -550,6 +579,7 @@ export let projects = [
"website": "https://lngames.net/",
"lightning_address": "moritz@getalby.com",
"votes_count": 0,
tags: [],
"category": {
"id": 4,
"title": "Gaming"

View File

@@ -1,35 +1,46 @@
import { graphql } from 'msw'
import { allCategories, getCategory, getProject, hottestProjects, newProjects, projectsByCategory, searchProjects } from './resolvers'
import {
NavCategoriesQuery,
ExploreProjectsQuery,
SearchProjectsQuery,
SearchProjectsQueryVariables,
CategoryPageQuery,
CategoryPageQueryVariables,
ProjectDetailsQuery,
ProjectDetailsQueryVariables,
HottestProjectsQuery,
HottestProjectsQueryVariables,
AllCategoriesQuery,
AllCategoriesQueryVariables
} from 'src/graphql'
const delay = (ms = 1000) => new Promise((res) => setTimeout(res, ms))
export const handlers = [
graphql.query('PROJECTS_IN_CATEGORY_QUERY', async (req, res, ctx) => {
graphql.query<NavCategoriesQuery>('NavCategories', async (req, res, ctx) => {
await delay()
const { categoryId } = req.variables
return res(
ctx.data({
projectsByCategory: projectsByCategory(categoryId),
getCategory: getCategory(categoryId)
allCategories: allCategories()
})
)
}),
graphql.query('SEARCH_PROJECTS_QUERY', async (req, res, ctx) => {
graphql.query<AllCategoriesQuery, AllCategoriesQueryVariables>('AllCategories', async (req, res, ctx) => {
await delay()
const { search } = req.variables
return res(
ctx.data({
searchProjects: searchProjects(search),
allCategories: allCategories()
})
)
}),
graphql.query('AllCategoriesProjects', async (req, res, ctx) => {
graphql.query<ExploreProjectsQuery>('ExploreProjects', async (req, res, ctx) => {
await delay()
return res(
@@ -40,27 +51,42 @@ export const handlers = [
)
}),
graphql.query('AllCategories', async (req, res, ctx) => {
graphql.query<CategoryPageQuery, CategoryPageQueryVariables>('CategoryPage', async (req, res, ctx) => {
await delay()
const { categoryId } = req.variables
return res(
ctx.data({
allCategories: allCategories()
projectsByCategory: projectsByCategory(categoryId),
getCategory: getCategory(categoryId)!
})
)
}),
graphql.query('Project', async (req, res, ctx) => {
graphql.query<SearchProjectsQuery, SearchProjectsQueryVariables>('SearchProjects', async (req, res, ctx) => {
await delay()
const { search } = req.variables
return res(
ctx.data({
searchProjects: searchProjects(search),
})
)
}),
graphql.query<ProjectDetailsQuery, ProjectDetailsQueryVariables>('ProjectDetails', async (req, res, ctx) => {
await delay()
const { projectId } = req.variables
return res(
ctx.data({
getProject: getProject(projectId)
getProject: getProject(projectId) as any
})
)
}),
graphql.query('HOTTEST_PROJECTS', async (req, res, ctx) => {
graphql.query<HottestProjectsQuery, HottestProjectsQueryVariables>('HottestProjects', async (req, res, ctx) => {
await delay()
return res(
@@ -69,4 +95,5 @@ export const handlers = [
})
)
}),
]

View File

@@ -2,8 +2,10 @@ import ASSETS from "src/assets";
import { MOCK_DATA } from "./data";
export function getCategory(id: number) {
const category = MOCK_DATA.categories.find(c => c.id === id)!;
return {
...MOCK_DATA.categories.find(c => c.id === id),
...category,
project: MOCK_DATA.projects.filter(p => p.category.id === id)
}
}
@@ -25,7 +27,7 @@ export function newProjects() {
}
export function getProject(projectId: number) {
return MOCK_DATA.projects.find(p => p.id === projectId)
return MOCK_DATA.projects.find(p => p.id === projectId)!
}
export function searchProjects(search: string) {

View File

@@ -97,8 +97,8 @@ export default function ProjectDetailsCard({ onClose, direction, ...props }: Pro
</div>
<div className="p-24">
<div className="flex gap-24 items-start">
<div className="flex-shrink-0 w-[93px] h-[93px] rounded-md overflow-hidden border">
<img className="w-full h-full" src={project?.thumbnail_image} alt="" />
<div className="flex-shrink-0 w-[93px] h-[93px]">
<img className="w-full h-full rounded-md border" src={project?.thumbnail_image} alt="" />
</div>
<div className='flex flex-col items-start justify-between self-stretch'>
<h3 className="text-h3 font-regular">{project?.title}</h3>
@@ -141,7 +141,7 @@ export default function ProjectDetailsCard({ onClose, direction, ...props }: Pro
<div className="grid grid-cols-2 md:grid-cols-4 gap-8 justify-items-center">
{project.screenshots.slice(0, 4).map((screenshot, idx) => <div
key={idx}
className="w-full relative pt-[56%] cursor-pointer bg-gray-300 border rounded-10 overflow-hidden"
className="w-full relative pt-[56%] cursor-pointer bg-gray-100 border rounded-10 overflow-hidden"
onClick={() => setScreenshotsOpen(idx)}
>
<img src={screenshot} className="absolute top-0 left-0 w-full h-full object-cover" alt='' />

View File

@@ -1,18 +1,18 @@
import { Tag } from "src/graphql";
import { Project as ApiProject, Tag } from "src/graphql";
import { Image } from ".";
export interface Project {
id: number;
title: string;
id: ApiProject['id'];
title: ApiProject['title'];
category: Pick<ProjectCategory, 'id' | 'title'>;
website?: string;
description: string;
website?: ApiProject['website'];
description: ApiProject['description'];
tags: Pick<Tag, 'id' | 'title'>[];
cover_image: Image;
thumbnail_image: Image;
lightning_address?: string | null,
cover_image: ApiProject['cover_image'];
thumbnail_image: ApiProject['thumbnail_image'];
lightning_address?: ApiProject['lightning_address'] | null,
screenshots: Image[];
votes_count: number;
votes_count: ApiProject['votes_count'];
}
export interface ProjectCategory {