chore: make graphql queries auto generated

This commit is contained in:
MTG2000
2022-03-26 16:53:22 +03:00
parent df8a82eb3f
commit e22b4858d8
34 changed files with 869 additions and 585 deletions

4
.gitignore vendored
View File

@@ -1,6 +1,7 @@
.netlify
.env
build
environments/.dev.preview-server.env
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
@@ -8,6 +9,7 @@ build
/.pnp
.pnp.js
# testing
/coverage
@@ -25,4 +27,4 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
TODO
TODO

View File

@@ -1,11 +1,12 @@
overwrite: true
schema: "https://deploy-preview-2--makers-bolt-fun.netlify.app/.netlify/functions/graphql"
documents: "./src/components/**/*.{ts,tsx}"
schema: "https://makers-bolt-fun-preview.netlify.app/.netlify/functions/graphql"
documents: "./src/**/*.{ts,graphql}"
generates:
src/generated/graphql.tsx:
src/graphql/index.tsx:
plugins:
- "typescript"
- "typescript-operations"
- "typescript-react-apollo"
config:
withHooks: true
avoidOptionals: true

103
package-lock.json generated
View File

@@ -52,8 +52,9 @@
"devDependencies": {
"@craco/craco": "^6.4.0",
"@graphql-codegen/cli": "2.3.0",
"@graphql-codegen/typescript": "2.4.1",
"@graphql-codegen/typescript-operations": "2.2.1",
"@graphql-codegen/typed-document-node": "^2.2.8",
"@graphql-codegen/typescript": "^2.4.1",
"@graphql-codegen/typescript-operations": "^2.2.1",
"@graphql-codegen/typescript-react-apollo": "3.2.2",
"@storybook/addon-actions": "^6.3.12",
"@storybook/addon-essentials": "^6.3.12",
@@ -2436,14 +2437,14 @@
}
},
"node_modules/@graphql-codegen/plugin-helpers": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/@graphql-codegen/plugin-helpers/-/plugin-helpers-2.3.1.tgz",
"integrity": "sha512-rWH7igcjYqZ6rqNFTb4Wyp31863fRmmVpsRN8VHzBCltrepOO97jwTwB93aAw+T6Dm8aZto3QFfDIC79u8wA2Q==",
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/@graphql-codegen/plugin-helpers/-/plugin-helpers-2.4.2.tgz",
"integrity": "sha512-LJNvwAPv/sKtI3RnRDm+nPD+JeOfOuSOS4FFIpQCMUCyMnFcchV/CPTTv7tT12fLUpEg6XjuFfDBvOwndti30Q==",
"dev": true,
"dependencies": {
"@graphql-tools/utils": "^8.5.2",
"change-case-all": "1.0.14",
"common-tags": "1.8.0",
"common-tags": "1.8.2",
"import-from": "4.0.0",
"lodash": "~4.17.0",
"tslib": "~2.3.0"
@@ -2478,6 +2479,43 @@
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
}
},
"node_modules/@graphql-codegen/typed-document-node": {
"version": "2.2.8",
"resolved": "https://registry.npmjs.org/@graphql-codegen/typed-document-node/-/typed-document-node-2.2.8.tgz",
"integrity": "sha512-72qTGNOMVnT51Fenk1MvavOwdyJewCZlrEp0miiTjtOSiTPzAm1acOck7cx8smNWyxNaDh3g4Jf60MkS8VCySw==",
"dev": true,
"dependencies": {
"@graphql-codegen/plugin-helpers": "^2.4.0",
"@graphql-codegen/visitor-plugin-common": "2.7.4",
"auto-bind": "~4.0.0",
"change-case-all": "1.0.14",
"tslib": "~2.3.0"
},
"peerDependencies": {
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
}
},
"node_modules/@graphql-codegen/typed-document-node/node_modules/@graphql-codegen/visitor-plugin-common": {
"version": "2.7.4",
"resolved": "https://registry.npmjs.org/@graphql-codegen/visitor-plugin-common/-/visitor-plugin-common-2.7.4.tgz",
"integrity": "sha512-aaDoEudDD+B7DK/UwDSL2Fzej75N9hNJ3N8FQuTIeDyw6FNGWUxmkjVBLQGlzfnYfK8IYkdfYkrPn3Skq0pVxA==",
"dev": true,
"dependencies": {
"@graphql-codegen/plugin-helpers": "^2.4.0",
"@graphql-tools/optimize": "^1.0.1",
"@graphql-tools/relay-operation-optimizer": "^6.3.7",
"@graphql-tools/utils": "^8.3.0",
"auto-bind": "~4.0.0",
"change-case-all": "1.0.14",
"dependency-graph": "^0.11.0",
"graphql-tag": "^2.11.0",
"parse-filepath": "^1.0.2",
"tslib": "~2.3.0"
},
"peerDependencies": {
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
}
},
"node_modules/@graphql-codegen/typescript": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/@graphql-codegen/typescript/-/typescript-2.4.1.tgz",
@@ -14032,9 +14070,9 @@
}
},
"node_modules/common-tags": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.0.tgz",
"integrity": "sha512-6P6g0uetGpW/sdyUy/iQQCbFF0kWVMSIVSyYz7Zgjcgh8mgw8PQzDNZeyZ5DQ2gM7LBoZPHmnjz8rUthkBG5tw==",
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.2.tgz",
"integrity": "sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA==",
"engines": {
"node": ">=4.0.0"
}
@@ -62599,14 +62637,14 @@
}
},
"@graphql-codegen/plugin-helpers": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/@graphql-codegen/plugin-helpers/-/plugin-helpers-2.3.1.tgz",
"integrity": "sha512-rWH7igcjYqZ6rqNFTb4Wyp31863fRmmVpsRN8VHzBCltrepOO97jwTwB93aAw+T6Dm8aZto3QFfDIC79u8wA2Q==",
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/@graphql-codegen/plugin-helpers/-/plugin-helpers-2.4.2.tgz",
"integrity": "sha512-LJNvwAPv/sKtI3RnRDm+nPD+JeOfOuSOS4FFIpQCMUCyMnFcchV/CPTTv7tT12fLUpEg6XjuFfDBvOwndti30Q==",
"dev": true,
"requires": {
"@graphql-tools/utils": "^8.5.2",
"change-case-all": "1.0.14",
"common-tags": "1.8.0",
"common-tags": "1.8.2",
"import-from": "4.0.0",
"lodash": "~4.17.0",
"tslib": "~2.3.0"
@@ -62631,6 +62669,39 @@
"tslib": "~2.3.0"
}
},
"@graphql-codegen/typed-document-node": {
"version": "2.2.8",
"resolved": "https://registry.npmjs.org/@graphql-codegen/typed-document-node/-/typed-document-node-2.2.8.tgz",
"integrity": "sha512-72qTGNOMVnT51Fenk1MvavOwdyJewCZlrEp0miiTjtOSiTPzAm1acOck7cx8smNWyxNaDh3g4Jf60MkS8VCySw==",
"dev": true,
"requires": {
"@graphql-codegen/plugin-helpers": "^2.4.0",
"@graphql-codegen/visitor-plugin-common": "2.7.4",
"auto-bind": "~4.0.0",
"change-case-all": "1.0.14",
"tslib": "~2.3.0"
},
"dependencies": {
"@graphql-codegen/visitor-plugin-common": {
"version": "2.7.4",
"resolved": "https://registry.npmjs.org/@graphql-codegen/visitor-plugin-common/-/visitor-plugin-common-2.7.4.tgz",
"integrity": "sha512-aaDoEudDD+B7DK/UwDSL2Fzej75N9hNJ3N8FQuTIeDyw6FNGWUxmkjVBLQGlzfnYfK8IYkdfYkrPn3Skq0pVxA==",
"dev": true,
"requires": {
"@graphql-codegen/plugin-helpers": "^2.4.0",
"@graphql-tools/optimize": "^1.0.1",
"@graphql-tools/relay-operation-optimizer": "^6.3.7",
"@graphql-tools/utils": "^8.3.0",
"auto-bind": "~4.0.0",
"change-case-all": "1.0.14",
"dependency-graph": "^0.11.0",
"graphql-tag": "^2.11.0",
"parse-filepath": "^1.0.2",
"tslib": "~2.3.0"
}
}
}
},
"@graphql-codegen/typescript": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/@graphql-codegen/typescript/-/typescript-2.4.1.tgz",
@@ -71546,9 +71617,9 @@
"integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA=="
},
"common-tags": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.0.tgz",
"integrity": "sha512-6P6g0uetGpW/sdyUy/iQQCbFF0kWVMSIVSyYz7Zgjcgh8mgw8PQzDNZeyZ5DQ2gM7LBoZPHmnjz8rUthkBG5tw=="
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.2.tgz",
"integrity": "sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA=="
},
"commondir": {
"version": "1.0.1",

View File

@@ -46,20 +46,20 @@
},
"scripts": {
"client:prod-server": "env-cmd -f ./environments/.dev.prod-server.env craco start",
"client:preview-server": "env-cmd -f ./environments/.dev.preview-server.env craco start",
"client:mocks": "env-cmd -f ./environments/.dev.mock-server.env craco start",
"client:dev-server": "env-cmd -f ./environments/.dev.server.env craco start",
"server:dev": "serverless offline",
"generate-graphql":"graphql-codegen",
"build": "craco build",
"build:mocks": "env-cmd -f ./environments/.prod.mock-server.env craco build",
"build:mocks": "env-cmd -f ./environments/.prod.mock-server.env craco build",
"test": "craco test",
"eject": "react-scripts eject",
"predeploy": "env-cmd -f ./environments/.prod.github.env npm run build",
"deploy": "gh-pages -d build",
"only-deploy": "gh-pages -d build",
"storybook": "env-cmd -f ./environments/.dev.mock-server.env start-storybook -p 6006 -s public",
"build-storybook": "env-cmd -f ./environments/.prod.mock-server.env build-storybook -s public",
"db:migrate-dev": "prisma migrate dev",
"db:migrate-deploy": "prisma migrate deploy",
"db:reset": "prisma migrate reset",
@@ -100,8 +100,9 @@
"devDependencies": {
"@craco/craco": "^6.4.0",
"@graphql-codegen/cli": "2.3.0",
"@graphql-codegen/typescript": "2.4.1",
"@graphql-codegen/typescript-operations": "2.2.1",
"@graphql-codegen/typed-document-node": "^2.2.8",
"@graphql-codegen/typescript": "^2.4.1",
"@graphql-codegen/typescript-operations": "^2.2.1",
"@graphql-codegen/typescript-react-apollo": "3.2.2",
"@storybook/addon-actions": "^6.3.12",
"@storybook/addon-essentials": "^6.3.12",

View File

@@ -1,8 +1,7 @@
import { useQuery } from '@apollo/client'
import Skeleton from 'react-loading-skeleton'
import { Link } from 'react-router-dom'
import { useNavCategoriesQuery } from 'src/graphql'
import { numberFormatter } from 'src/utils/helperFunctions'
import { ALL_CATEGORIES_QUERY, ALL_CATEGORIES_QUERY_RES } from './query'
interface Props {
// categories: Pick<ProjectCategory, 'id' | 'title' | 'icon' | 'votes_sum'>[]
@@ -13,8 +12,7 @@ interface Props {
export default function CategoriesList({ classes = {}, onClick }: Props) {
const { data, loading } = useQuery<ALL_CATEGORIES_QUERY_RES>(ALL_CATEGORIES_QUERY);
const { data, loading } = useNavCategoriesQuery()
if (loading)

View File

@@ -0,0 +1,8 @@
query NavCategories {
allCategories {
id
title
icon
votes_sum
}
}

View File

@@ -1,22 +0,0 @@
import { gql } from "@apollo/client";
import { ProjectCategory } from "src/utils/interfaces";
export const ALL_CATEGORIES_QUERY = gql`
query AllCategories {
allCategories {
id
title
icon
votes_sum
}
}
`;
export type ALL_CATEGORIES_QUERY_RES = {
allCategories: Pick<ProjectCategory,
| 'id'
| 'title'
| 'icon'
| 'votes_sum'
>[];
};

View File

@@ -3,16 +3,17 @@ import { motion } from 'framer-motion'
import { BsSearch } from 'react-icons/bs';
import { useClickOutside, useThrottledCallback } from '@react-hookz/web'
import SearchResults from './SearchResults/SearchResults'
import { useLazyQuery } from '@apollo/client';
import { SEARCH_PROJECTS_QUERY, SEARCH_PROJECTS_QUERY_RES_TYPE, SEARCH_PROJECTS_QUERY_VARS } from './query';
import { useAppDispatch, useAppSelector } from 'src/utils/hooks';
import { toggleSearch } from 'src/redux/features/ui.slice';
import { SearchProjectsQuery, useSearchProjectsLazyQuery } from 'src/graphql';
interface Props {
height?: number | string;
width?: number | string;
}
export type ProjectSearchItem = SearchProjectsQuery['searchProjects'][number];
const SearchResultsListVariants = {
hidden: {
opacity: 0,
@@ -46,8 +47,8 @@ export default function Search({
dispatch(toggleSearch(false))
})
const [executeQuery, { data, loading }] = useLazyQuery<SEARCH_PROJECTS_QUERY_RES_TYPE, SEARCH_PROJECTS_QUERY_VARS>(SEARCH_PROJECTS_QUERY);
const [executeQuery, { data, loading }] = useSearchProjectsLazyQuery()
const throttledExecuteQuery = useThrottledCallback((search: string) => {
executeQuery({

View File

@@ -1,6 +1,6 @@
import { ProjectSearchItem } from '../query'
import SearchProjectCardSkeleton from './SearchProjectCard.Skeleton'
import { ProjectSearchItem } from '../Search';
type Props =
{

View File

@@ -2,8 +2,7 @@
import { openModal } from 'src/redux/features/modals.slice';
import { toggleSearch } from 'src/redux/features/ui.slice';
import { useAppDispatch } from 'src/utils/hooks';
import { ProjectCard } from 'src/utils/interfaces'
import { ProjectSearchItem } from '../query';
import { ProjectSearchItem } from '../Search';
import SearchProjectCard from '../SearchProjectCard/SearchProjectCard';
import styles from './styles.module.css'

View File

@@ -1,39 +0,0 @@
import { gql } from "@apollo/client";
import { ProjectCard, ProjectCategory } from "src/utils/interfaces";
export const SEARCH_PROJECTS_QUERY = gql`
query SEARCH_PROJECTS_QUERY($search: String!) {
searchProjects(search: $search) {
id
thumbnail_image
title
category {
title
id
}
}
}
`
export type SEARCH_PROJECTS_QUERY_VARS = {
search: string;
}
export type ProjectSearchItem =
(
Pick<ProjectCard,
| 'id'
| 'thumbnail_image'
| 'title'>
&
{
category: Pick<ProjectCategory,
| 'id'
| 'title'>
}
)
export type SEARCH_PROJECTS_QUERY_RES_TYPE = {
searchProjects: ProjectSearchItem[],
}

View File

@@ -0,0 +1,11 @@
query SearchProjects($search: String!) {
searchProjects(search: $search) {
id
thumbnail_image
title
category {
title
id
}
}
}

View File

@@ -1,257 +0,0 @@
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
export type Maybe<T> = T | null;
export type InputMaybe<T> = Maybe<T>;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
const defaultOptions = {}
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: string;
String: string;
Boolean: boolean;
Int: number;
Float: number;
};
export type Category = {
__typename?: 'Category';
id: Scalars['Int'];
project?: Maybe<Array<Project>>;
title: Scalars['String'];
};
export type Mutation = {
__typename?: 'Mutation';
confirmVote: Vote;
vote: Vote;
};
export type MutationConfirmVoteArgs = {
payment_request: Scalars['String'];
preimage: Scalars['String'];
};
export type MutationVoteArgs = {
amount_in_sat: Scalars['Int'];
project_id: Scalars['Int'];
};
export type Project = {
__typename?: 'Project';
category: Category;
cover_image: Scalars['String'];
id: Scalars['Int'];
lightning_address: Scalars['String'];
thumbnail_image: Scalars['String'];
title: Scalars['String'];
votes_count: Scalars['Int'];
website: Scalars['String'];
};
export type Query = {
__typename?: 'Query';
allCategories: Array<Category>;
allProjects: Array<Project>;
getCategory: Category;
getProject: Project;
newProjects: Array<Maybe<Project>>;
projectsByCategory: Array<Maybe<Project>>;
};
export type QueryAllProjectsArgs = {
skip?: InputMaybe<Scalars['Int']>;
take?: InputMaybe<Scalars['Int']>;
};
export type QueryGetCategoryArgs = {
id: Scalars['Int'];
};
export type QueryGetProjectArgs = {
id: Scalars['Int'];
};
export type QueryNewProjectsArgs = {
skip?: InputMaybe<Scalars['Int']>;
take?: InputMaybe<Scalars['Int']>;
};
export type QueryProjectsByCategoryArgs = {
category_id: Scalars['Int'];
skip?: InputMaybe<Scalars['Int']>;
take?: InputMaybe<Scalars['Int']>;
};
export type Vote = {
__typename?: 'Vote';
amount_in_sat: Scalars['Int'];
id: Scalars['Int'];
paid: Scalars['Boolean'];
payment_hash: Scalars['String'];
payment_request: Scalars['String'];
project: Project;
};
export type AllCategoriesQueryVariables = Exact<{ [key: string]: never; }>;
export type AllCategoriesQuery = {
__typename?: 'Query',
allCategories: Array<{ __typename?: 'Category', id: number, title: string }>
};
export type AllCategoriesProjectsQueryVariables = Exact<{ [key: string]: never; }>;
export type AllCategoriesProjectsQuery = {
__typename?: 'Query',
allCategories: Array<{ __typename?: 'Category', id: number, title: string, project?: Array<{ __typename?: 'Project', id: number, thumbnail_image: string, title: string, votes_count: number }> | null | undefined }>, newProjects: Array<{ __typename?: 'Project', id: number, title: string, thumbnail_image: string, votes_count: number, category: { __typename?: 'Category', title: string, id: number } }>
};
export type GetProjectQueryVariables = Exact<{
getProjectId: Scalars['Int'];
}>;
export type GetProjectQuery = { __typename?: 'Query', getProject: { __typename?: 'Project', id: number, cover_image: string, thumbnail_image: string, title: string, website: string, votes_count: number, category: { __typename?: 'Category', id: number, title: string } } };
export const AllCategoriesDocument = gql`
query AllCategories {
allCategories {
id
title
}
}
`;
/**
* __useAllCategoriesQuery__
*
* To run a query within a React component, call `useAllCategoriesQuery` and pass it any options that fit your needs.
* When your component renders, `useAllCategoriesQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useAllCategoriesQuery({
* variables: {
* },
* });
*/
export function useAllCategoriesQuery(baseOptions?: Apollo.QueryHookOptions<AllCategoriesQuery, AllCategoriesQueryVariables>) {
const options = { ...defaultOptions, ...baseOptions }
return Apollo.useQuery<AllCategoriesQuery, AllCategoriesQueryVariables>(AllCategoriesDocument, options);
}
export function useAllCategoriesLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<AllCategoriesQuery, AllCategoriesQueryVariables>) {
const options = { ...defaultOptions, ...baseOptions }
return Apollo.useLazyQuery<AllCategoriesQuery, AllCategoriesQueryVariables>(AllCategoriesDocument, options);
}
export type AllCategoriesQueryHookResult = ReturnType<typeof useAllCategoriesQuery>;
export type AllCategoriesLazyQueryHookResult = ReturnType<typeof useAllCategoriesLazyQuery>;
export type AllCategoriesQueryResult = Apollo.QueryResult<AllCategoriesQuery, AllCategoriesQueryVariables>;
export const AllCategoriesProjectsDocument = gql`
query AllCategoriesProjects {
allCategories {
id
title
project {
id
thumbnail_image
title
votes_count
}
}
newProjects {
id
title
thumbnail_image
votes_count
category {
title
id
}
}
}
`;
/**
* __useAllCategoriesProjectsQuery__
*
* To run a query within a React component, call `useAllCategoriesProjectsQuery` and pass it any options that fit your needs.
* When your component renders, `useAllCategoriesProjectsQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useAllCategoriesProjectsQuery({
* variables: {
* },
* });
*/
export function useAllCategoriesProjectsQuery(baseOptions?: Apollo.QueryHookOptions<AllCategoriesProjectsQuery, AllCategoriesProjectsQueryVariables>) {
const options = { ...defaultOptions, ...baseOptions }
return Apollo.useQuery<AllCategoriesProjectsQuery, AllCategoriesProjectsQueryVariables>(AllCategoriesProjectsDocument, options);
}
export function useAllCategoriesProjectsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<AllCategoriesProjectsQuery, AllCategoriesProjectsQueryVariables>) {
const options = { ...defaultOptions, ...baseOptions }
return Apollo.useLazyQuery<AllCategoriesProjectsQuery, AllCategoriesProjectsQueryVariables>(AllCategoriesProjectsDocument, options);
}
export type AllCategoriesProjectsQueryHookResult = ReturnType<typeof useAllCategoriesProjectsQuery>;
export type AllCategoriesProjectsLazyQueryHookResult = ReturnType<typeof useAllCategoriesProjectsLazyQuery>;
export type AllCategoriesProjectsQueryResult = Apollo.QueryResult<AllCategoriesProjectsQuery, AllCategoriesProjectsQueryVariables>;
export const GetProjectDocument = gql`
query GetProject($getProjectId: Int!) {
getProject(id: $getProjectId) {
id
cover_image
thumbnail_image
title
website
votes_count
category {
id
title
}
}
}
`;
/**
* __useGetProjectQuery__
*
* To run a query within a React component, call `useGetProjectQuery` and pass it any options that fit your needs.
* When your component renders, `useGetProjectQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useGetProjectQuery({
* variables: {
* getProjectId: // value for 'getProjectId'
* },
* });
*/
export function useGetProjectQuery(baseOptions: Apollo.QueryHookOptions<GetProjectQuery, GetProjectQueryVariables>) {
const options = { ...defaultOptions, ...baseOptions }
return Apollo.useQuery<GetProjectQuery, GetProjectQueryVariables>(GetProjectDocument, options);
}
export function useGetProjectLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<GetProjectQuery, GetProjectQueryVariables>) {
const options = { ...defaultOptions, ...baseOptions }
return Apollo.useLazyQuery<GetProjectQuery, GetProjectQueryVariables>(GetProjectDocument, options);
}
export type GetProjectQueryHookResult = ReturnType<typeof useGetProjectQuery>;
export type GetProjectLazyQueryHookResult = ReturnType<typeof useGetProjectLazyQuery>;
export type GetProjectQueryResult = Apollo.QueryResult<GetProjectQuery, GetProjectQueryVariables>;

606
src/graphql/index.tsx Normal file
View File

@@ -0,0 +1,606 @@
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
export type Maybe<T> = T | null;
export type InputMaybe<T> = Maybe<T>;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
const defaultOptions = {}
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: string;
String: string;
Boolean: boolean;
Int: number;
Float: number;
};
export type Award = {
__typename?: 'Award';
id: Scalars['Int'];
image: Scalars['String'];
project: Project;
title: Scalars['String'];
url: Scalars['String'];
};
export type Category = {
__typename?: 'Category';
apps_count: Scalars['Int'];
cover_image: Maybe<Scalars['String']>;
icon: Maybe<Scalars['String']>;
id: Scalars['Int'];
project: Array<Project>;
title: Scalars['String'];
votes_sum: Scalars['Int'];
};
export type LnurlDetails = {
__typename?: 'LnurlDetails';
commentAllowed: Maybe<Scalars['Int']>;
maxSendable: Maybe<Scalars['Int']>;
metadata: Maybe<Scalars['String']>;
minSendable: Maybe<Scalars['Int']>;
};
export type Mutation = {
__typename?: 'Mutation';
confirmVote: Vote;
vote: Vote;
};
export type MutationConfirmVoteArgs = {
payment_request: Scalars['String'];
preimage: Scalars['String'];
};
export type MutationVoteArgs = {
amount_in_sat: Scalars['Int'];
project_id: Scalars['Int'];
};
export type Project = {
__typename?: 'Project';
awards: Array<Award>;
category: Category;
cover_image: Scalars['String'];
description: Scalars['String'];
id: Scalars['Int'];
lightning_address: Maybe<Scalars['String']>;
lnurl_callback_url: Maybe<Scalars['String']>;
screenshots: Array<Scalars['String']>;
tags: Array<Tag>;
thumbnail_image: Scalars['String'];
title: Scalars['String'];
votes_count: Scalars['Int'];
website: Scalars['String'];
};
export type Query = {
__typename?: 'Query';
allCategories: Array<Category>;
allProjects: Array<Project>;
getCategory: Category;
getLnurlDetailsForProject: LnurlDetails;
getProject: Project;
hottestProjects: Array<Project>;
newProjects: Array<Project>;
projectsByCategory: Array<Project>;
searchProjects: Array<Project>;
};
export type QueryAllProjectsArgs = {
skip?: InputMaybe<Scalars['Int']>;
take?: InputMaybe<Scalars['Int']>;
};
export type QueryGetCategoryArgs = {
id: Scalars['Int'];
};
export type QueryGetLnurlDetailsForProjectArgs = {
project_id: Scalars['Int'];
};
export type QueryGetProjectArgs = {
id: Scalars['Int'];
};
export type QueryHottestProjectsArgs = {
skip?: InputMaybe<Scalars['Int']>;
take?: InputMaybe<Scalars['Int']>;
};
export type QueryNewProjectsArgs = {
skip?: InputMaybe<Scalars['Int']>;
take?: InputMaybe<Scalars['Int']>;
};
export type QueryProjectsByCategoryArgs = {
category_id: Scalars['Int'];
skip?: InputMaybe<Scalars['Int']>;
take?: InputMaybe<Scalars['Int']>;
};
export type QuerySearchProjectsArgs = {
search: Scalars['String'];
skip?: InputMaybe<Scalars['Int']>;
take?: InputMaybe<Scalars['Int']>;
};
export type Tag = {
__typename?: 'Tag';
id: Scalars['Int'];
project: Array<Project>;
title: Scalars['String'];
};
export type Vote = {
__typename?: 'Vote';
amount_in_sat: Scalars['Int'];
id: Scalars['Int'];
paid: Scalars['Boolean'];
payment_hash: Scalars['String'];
payment_request: Scalars['String'];
project: Project;
};
export type NavCategoriesQueryVariables = Exact<{ [key: string]: never; }>;
export type NavCategoriesQuery = { __typename?: 'Query', allCategories: Array<{ __typename?: 'Category', id: number, title: string, icon: string | null | undefined, votes_sum: number }> };
export type SearchProjectsQueryVariables = Exact<{
search: Scalars['String'];
}>;
export type SearchProjectsQuery = { __typename?: 'Query', searchProjects: Array<{ __typename?: 'Project', id: number, thumbnail_image: string, title: string, category: { __typename?: 'Category', title: string, id: number } }> };
export type CategoryPageQueryVariables = Exact<{
categoryId: Scalars['Int'];
}>;
export type CategoryPageQuery = { __typename?: 'Query', projectsByCategory: Array<{ __typename?: 'Project', id: number, thumbnail_image: string, title: string, votes_count: number, category: { __typename?: 'Category', title: string, id: number } }>, getCategory: { __typename?: 'Category', id: number, title: string, cover_image: string | null | undefined, apps_count: number } };
export type AllCategoriesQueryVariables = Exact<{ [key: string]: never; }>;
export type AllCategoriesQuery = { __typename?: 'Query', allCategories: Array<{ __typename?: 'Category', id: number, title: string }> };
export type ExploreProjectsQueryVariables = Exact<{ [key: string]: never; }>;
export type ExploreProjectsQuery = { __typename?: 'Query', allCategories: Array<{ __typename?: 'Category', id: number, title: string, project: Array<{ __typename?: 'Project', id: number, thumbnail_image: string, title: string, votes_count: number }> }>, newProjects: Array<{ __typename?: 'Project', id: number, title: string, thumbnail_image: string, votes_count: number, category: { __typename?: 'Category', title: string, id: number } }> };
export type HottestProjectsQueryVariables = Exact<{ [key: string]: never; }>;
export type HottestProjectsQuery = { __typename?: 'Query', hottestProjects: Array<{ __typename?: 'Project', id: number, thumbnail_image: string, title: string, votes_count: number, category: { __typename?: 'Category', title: string, id: number } }> };
export type ProjectDetailsQueryVariables = Exact<{
projectId: Scalars['Int'];
}>;
export type ProjectDetailsQuery = { __typename?: 'Query', getProject: { __typename?: 'Project', id: number, title: string, description: string, cover_image: string, thumbnail_image: string, screenshots: Array<string>, website: string, lightning_address: string | null | undefined, lnurl_callback_url: string | null | undefined, votes_count: number, category: { __typename?: 'Category', id: number, title: string }, awards: Array<{ __typename?: 'Award', title: string, image: string, url: string, id: number }>, tags: Array<{ __typename?: 'Tag', id: number, title: string }> } };
export type VoteMutationVariables = Exact<{
projectId: Scalars['Int'];
amountInSat: Scalars['Int'];
}>;
export type VoteMutation = { __typename?: 'Mutation', vote: { __typename?: 'Vote', id: number, amount_in_sat: number, payment_request: string, payment_hash: string, paid: boolean } };
export type ConfirmVoteMutationVariables = Exact<{
paymentRequest: Scalars['String'];
preimage: Scalars['String'];
}>;
export type ConfirmVoteMutation = { __typename?: 'Mutation', confirmVote: { __typename?: 'Vote', id: number, amount_in_sat: number, payment_request: string, payment_hash: string, paid: boolean, project: { __typename?: 'Project', id: number, votes_count: number } } };
export const NavCategoriesDocument = gql`
query NavCategories {
allCategories {
id
title
icon
votes_sum
}
}
`;
/**
* __useNavCategoriesQuery__
*
* To run a query within a React component, call `useNavCategoriesQuery` and pass it any options that fit your needs.
* When your component renders, `useNavCategoriesQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useNavCategoriesQuery({
* variables: {
* },
* });
*/
export function useNavCategoriesQuery(baseOptions?: Apollo.QueryHookOptions<NavCategoriesQuery, NavCategoriesQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<NavCategoriesQuery, NavCategoriesQueryVariables>(NavCategoriesDocument, options);
}
export function useNavCategoriesLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<NavCategoriesQuery, NavCategoriesQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<NavCategoriesQuery, NavCategoriesQueryVariables>(NavCategoriesDocument, options);
}
export type NavCategoriesQueryHookResult = ReturnType<typeof useNavCategoriesQuery>;
export type NavCategoriesLazyQueryHookResult = ReturnType<typeof useNavCategoriesLazyQuery>;
export type NavCategoriesQueryResult = Apollo.QueryResult<NavCategoriesQuery, NavCategoriesQueryVariables>;
export const SearchProjectsDocument = gql`
query SearchProjects($search: String!) {
searchProjects(search: $search) {
id
thumbnail_image
title
category {
title
id
}
}
}
`;
/**
* __useSearchProjectsQuery__
*
* To run a query within a React component, call `useSearchProjectsQuery` and pass it any options that fit your needs.
* When your component renders, `useSearchProjectsQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useSearchProjectsQuery({
* variables: {
* search: // value for 'search'
* },
* });
*/
export function useSearchProjectsQuery(baseOptions: Apollo.QueryHookOptions<SearchProjectsQuery, SearchProjectsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<SearchProjectsQuery, SearchProjectsQueryVariables>(SearchProjectsDocument, options);
}
export function useSearchProjectsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<SearchProjectsQuery, SearchProjectsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<SearchProjectsQuery, SearchProjectsQueryVariables>(SearchProjectsDocument, options);
}
export type SearchProjectsQueryHookResult = ReturnType<typeof useSearchProjectsQuery>;
export type SearchProjectsLazyQueryHookResult = ReturnType<typeof useSearchProjectsLazyQuery>;
export type SearchProjectsQueryResult = Apollo.QueryResult<SearchProjectsQuery, SearchProjectsQueryVariables>;
export const CategoryPageDocument = gql`
query CategoryPage($categoryId: Int!) {
projectsByCategory(category_id: $categoryId) {
id
thumbnail_image
title
votes_count
category {
title
id
}
}
getCategory(id: $categoryId) {
id
title
cover_image
apps_count
}
}
`;
/**
* __useCategoryPageQuery__
*
* To run a query within a React component, call `useCategoryPageQuery` and pass it any options that fit your needs.
* When your component renders, `useCategoryPageQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useCategoryPageQuery({
* variables: {
* categoryId: // value for 'categoryId'
* },
* });
*/
export function useCategoryPageQuery(baseOptions: Apollo.QueryHookOptions<CategoryPageQuery, CategoryPageQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<CategoryPageQuery, CategoryPageQueryVariables>(CategoryPageDocument, options);
}
export function useCategoryPageLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<CategoryPageQuery, CategoryPageQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<CategoryPageQuery, CategoryPageQueryVariables>(CategoryPageDocument, options);
}
export type CategoryPageQueryHookResult = ReturnType<typeof useCategoryPageQuery>;
export type CategoryPageLazyQueryHookResult = ReturnType<typeof useCategoryPageLazyQuery>;
export type CategoryPageQueryResult = Apollo.QueryResult<CategoryPageQuery, CategoryPageQueryVariables>;
export const AllCategoriesDocument = gql`
query AllCategories {
allCategories {
id
title
}
}
`;
/**
* __useAllCategoriesQuery__
*
* To run a query within a React component, call `useAllCategoriesQuery` and pass it any options that fit your needs.
* When your component renders, `useAllCategoriesQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useAllCategoriesQuery({
* variables: {
* },
* });
*/
export function useAllCategoriesQuery(baseOptions?: Apollo.QueryHookOptions<AllCategoriesQuery, AllCategoriesQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<AllCategoriesQuery, AllCategoriesQueryVariables>(AllCategoriesDocument, options);
}
export function useAllCategoriesLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<AllCategoriesQuery, AllCategoriesQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<AllCategoriesQuery, AllCategoriesQueryVariables>(AllCategoriesDocument, options);
}
export type AllCategoriesQueryHookResult = ReturnType<typeof useAllCategoriesQuery>;
export type AllCategoriesLazyQueryHookResult = ReturnType<typeof useAllCategoriesLazyQuery>;
export type AllCategoriesQueryResult = Apollo.QueryResult<AllCategoriesQuery, AllCategoriesQueryVariables>;
export const ExploreProjectsDocument = gql`
query ExploreProjects {
allCategories {
id
title
project {
id
thumbnail_image
title
votes_count
}
}
newProjects {
id
title
thumbnail_image
votes_count
category {
title
id
}
}
}
`;
/**
* __useExploreProjectsQuery__
*
* To run a query within a React component, call `useExploreProjectsQuery` and pass it any options that fit your needs.
* When your component renders, `useExploreProjectsQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useExploreProjectsQuery({
* variables: {
* },
* });
*/
export function useExploreProjectsQuery(baseOptions?: Apollo.QueryHookOptions<ExploreProjectsQuery, ExploreProjectsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<ExploreProjectsQuery, ExploreProjectsQueryVariables>(ExploreProjectsDocument, options);
}
export function useExploreProjectsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ExploreProjectsQuery, ExploreProjectsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<ExploreProjectsQuery, ExploreProjectsQueryVariables>(ExploreProjectsDocument, options);
}
export type ExploreProjectsQueryHookResult = ReturnType<typeof useExploreProjectsQuery>;
export type ExploreProjectsLazyQueryHookResult = ReturnType<typeof useExploreProjectsLazyQuery>;
export type ExploreProjectsQueryResult = Apollo.QueryResult<ExploreProjectsQuery, ExploreProjectsQueryVariables>;
export const HottestProjectsDocument = gql`
query HottestProjects {
hottestProjects {
id
thumbnail_image
title
votes_count
category {
title
id
}
}
}
`;
/**
* __useHottestProjectsQuery__
*
* To run a query within a React component, call `useHottestProjectsQuery` and pass it any options that fit your needs.
* When your component renders, `useHottestProjectsQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useHottestProjectsQuery({
* variables: {
* },
* });
*/
export function useHottestProjectsQuery(baseOptions?: Apollo.QueryHookOptions<HottestProjectsQuery, HottestProjectsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<HottestProjectsQuery, HottestProjectsQueryVariables>(HottestProjectsDocument, options);
}
export function useHottestProjectsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<HottestProjectsQuery, HottestProjectsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<HottestProjectsQuery, HottestProjectsQueryVariables>(HottestProjectsDocument, options);
}
export type HottestProjectsQueryHookResult = ReturnType<typeof useHottestProjectsQuery>;
export type HottestProjectsLazyQueryHookResult = ReturnType<typeof useHottestProjectsLazyQuery>;
export type HottestProjectsQueryResult = Apollo.QueryResult<HottestProjectsQuery, HottestProjectsQueryVariables>;
export const ProjectDetailsDocument = gql`
query ProjectDetails($projectId: Int!) {
getProject(id: $projectId) {
id
title
description
cover_image
thumbnail_image
screenshots
website
lightning_address
lnurl_callback_url
votes_count
category {
id
title
}
awards {
title
image
url
id
}
tags {
id
title
}
}
}
`;
/**
* __useProjectDetailsQuery__
*
* To run a query within a React component, call `useProjectDetailsQuery` and pass it any options that fit your needs.
* When your component renders, `useProjectDetailsQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useProjectDetailsQuery({
* variables: {
* projectId: // value for 'projectId'
* },
* });
*/
export function useProjectDetailsQuery(baseOptions: Apollo.QueryHookOptions<ProjectDetailsQuery, ProjectDetailsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<ProjectDetailsQuery, ProjectDetailsQueryVariables>(ProjectDetailsDocument, options);
}
export function useProjectDetailsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ProjectDetailsQuery, ProjectDetailsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<ProjectDetailsQuery, ProjectDetailsQueryVariables>(ProjectDetailsDocument, options);
}
export type ProjectDetailsQueryHookResult = ReturnType<typeof useProjectDetailsQuery>;
export type ProjectDetailsLazyQueryHookResult = ReturnType<typeof useProjectDetailsLazyQuery>;
export type ProjectDetailsQueryResult = Apollo.QueryResult<ProjectDetailsQuery, ProjectDetailsQueryVariables>;
export const VoteDocument = gql`
mutation Vote($projectId: Int!, $amountInSat: Int!) {
vote(project_id: $projectId, amount_in_sat: $amountInSat) {
id
amount_in_sat
payment_request
payment_hash
paid
}
}
`;
export type VoteMutationFn = Apollo.MutationFunction<VoteMutation, VoteMutationVariables>;
/**
* __useVoteMutation__
*
* To run a mutation, you first call `useVoteMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useVoteMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [voteMutation, { data, loading, error }] = useVoteMutation({
* variables: {
* projectId: // value for 'projectId'
* amountInSat: // value for 'amountInSat'
* },
* });
*/
export function useVoteMutation(baseOptions?: Apollo.MutationHookOptions<VoteMutation, VoteMutationVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useMutation<VoteMutation, VoteMutationVariables>(VoteDocument, options);
}
export type VoteMutationHookResult = ReturnType<typeof useVoteMutation>;
export type VoteMutationResult = Apollo.MutationResult<VoteMutation>;
export type VoteMutationOptions = Apollo.BaseMutationOptions<VoteMutation, VoteMutationVariables>;
export const ConfirmVoteDocument = gql`
mutation ConfirmVote($paymentRequest: String!, $preimage: String!) {
confirmVote(payment_request: $paymentRequest, preimage: $preimage) {
id
amount_in_sat
payment_request
payment_hash
paid
project {
id
votes_count
}
}
}
`;
export type ConfirmVoteMutationFn = Apollo.MutationFunction<ConfirmVoteMutation, ConfirmVoteMutationVariables>;
/**
* __useConfirmVoteMutation__
*
* To run a mutation, you first call `useConfirmVoteMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useConfirmVoteMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [confirmVoteMutation, { data, loading, error }] = useConfirmVoteMutation({
* variables: {
* paymentRequest: // value for 'paymentRequest'
* preimage: // value for 'preimage'
* },
* });
*/
export function useConfirmVoteMutation(baseOptions?: Apollo.MutationHookOptions<ConfirmVoteMutation, ConfirmVoteMutationVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useMutation<ConfirmVoteMutation, ConfirmVoteMutationVariables>(ConfirmVoteDocument, options);
}
export type ConfirmVoteMutationHookResult = ReturnType<typeof useConfirmVoteMutation>;
export type ConfirmVoteMutationResult = Apollo.MutationResult<ConfirmVoteMutation>;
export type ConfirmVoteMutationOptions = Apollo.BaseMutationOptions<ConfirmVoteMutation, ConfirmVoteMutationVariables>;

View File

@@ -1,16 +1,15 @@
import { useQuery } from '@apollo/client';
import { useParams, Navigate } from 'react-router-dom'
import ErrorMessage from 'src/Components/ErrorMessage/ErrorMessage';
import { useCategoryPageQuery } from 'src/graphql';
import HeaderImage from './HeaderImage/HeaderImage';
import ProjectsGrid from './ProjectsGrid/ProjectsGrid';
import { PROJECTS_IN_CATEGORY_QUERY, PROJECTS_IN_CATEGORY_QUERY_RES_TYPE, PROJECTS_IN_CATEGORY_QUERY_VARS } from './query';
export default function CategoryPage() {
const { id } = useParams();
const { data, loading, error } = useQuery<PROJECTS_IN_CATEGORY_QUERY_RES_TYPE, PROJECTS_IN_CATEGORY_QUERY_VARS>(PROJECTS_IN_CATEGORY_QUERY, {
const { data, loading, error } = useCategoryPageQuery({
skip: !id,
variables: {
categoryId: Number(id)

View File

@@ -0,0 +1,19 @@
query CategoryPage($categoryId: Int!) {
projectsByCategory(category_id: $categoryId) {
id
thumbnail_image
title
votes_count
category {
title
id
}
}
getCategory(id: $categoryId) {
id
title
cover_image
apps_count
}
}

View File

@@ -1,40 +0,0 @@
import { gql } from "@apollo/client";
import { ProjectCard, ProjectCategory } from "src/utils/interfaces";
export const PROJECTS_IN_CATEGORY_QUERY = gql`
query PROJECTS_IN_CATEGORY_QUERY($categoryId: Int!) {
projectsByCategory(category_id: $categoryId) {
id
thumbnail_image
title
votes_count
category {
title
id
}
}
getCategory(id: $categoryId) {
id
title
cover_image
apps_count
}
}
`
export type PROJECTS_IN_CATEGORY_QUERY_VARS = {
categoryId: number;
}
export type PROJECTS_IN_CATEGORY_QUERY_RES_TYPE = {
projectsByCategory: ProjectCard[],
getCategory: {
id: ProjectCategory['id']
title: ProjectCategory['title']
cover_image: ProjectCategory['cover_image']
apps_count: ProjectCategory['apps_count']
}
}

View File

@@ -1,13 +1,13 @@
import { useQuery } from '@apollo/client';
import { ALL_CATEGORIES_QUERY, ALL_CATEGORIES_QUERY_RES } from './query';
import Badge from 'src/Components/Badge/Badge'
import Slider from 'src/Components/Slider/Slider'
import { useNavigate } from 'react-router-dom';
import { useAllCategoriesQuery } from 'src/graphql';
export default function Categories() {
const { data, loading } = useQuery<ALL_CATEGORIES_QUERY_RES>(ALL_CATEGORIES_QUERY);
const { data, loading } = useAllCategoriesQuery();
const navigate = useNavigate();
if (loading || !data)

View File

@@ -0,0 +1,6 @@
query AllCategories {
allCategories {
id
title
}
}

View File

@@ -1,15 +0,0 @@
import { gql } from "@apollo/client";
import { ProjectCategory } from "src/utils/interfaces";
export const ALL_CATEGORIES_QUERY = gql`
query AllCategories {
allCategories {
id
title
}
}
`;
export type ALL_CATEGORIES_QUERY_RES = {
allCategories: ProjectCategory[];
};

View File

@@ -1,15 +1,13 @@
import ProjectsRow from "../ProjectsRow/ProjectsRow";
import ProjectsRowSkeleton from "../ProjectsRow/ProjectsRow.Skeleton";
import { MdLocalFireDepartment } from "react-icons/md";
import { useQuery } from "@apollo/client";
import { ALL_CATEGORIES_PROJECTS_QUERY, ALL_CATEGORIES_PROJECTS_RES } from "./query";
import { useExploreProjectsQuery } from "src/graphql";
export default function ProjectsSection() {
const { data, loading } = useQuery<ALL_CATEGORIES_PROJECTS_RES>(ALL_CATEGORIES_PROJECTS_QUERY);
const { data, loading } = useExploreProjectsQuery();
if (loading || !data) return <div className='mt-32 lg:mt-48'>

View File

@@ -0,0 +1,22 @@
query ExploreProjects {
allCategories {
id
title
project {
id
thumbnail_image
title
votes_count
}
}
newProjects {
id
title
thumbnail_image
votes_count
category {
title
id
}
}
}

View File

@@ -1,37 +0,0 @@
import { gql } from "@apollo/client";
import { ProjectCard, } from "src/utils/interfaces";
export const ALL_CATEGORIES_PROJECTS_QUERY = gql`
query AllCategoriesProjects {
allCategories {
id
title
project {
id
thumbnail_image
title
votes_count
}
}
newProjects {
id
title
thumbnail_image
votes_count
category {
title
id
}
}
}
`;
export type ALL_CATEGORIES_PROJECTS_RES = {
newProjects: ProjectCard[],
allCategories: {
id: number;
title: string;
project: ProjectCard[];
}[];
};

View File

@@ -1,18 +1,13 @@
import { useQuery } from '@apollo/client';
import ASSETS from 'src/assets';
import ErrorMessage from 'src/Components/ErrorMessage/ErrorMessage';
import HeaderImage from 'src/pages/CategoryPage/HeaderImage/HeaderImage';
import ProjectsGrid from 'src/pages/CategoryPage/ProjectsGrid/ProjectsGrid';
import { HOTTEST_PROJECTS_QUERY, HOTTEST_PROJECTS_QUERY_RES_TYPE } from './query';
import { useHottestProjectsQuery } from 'src/graphql'
export default function HottestPage() {
const { data, loading, error } = useQuery<HOTTEST_PROJECTS_QUERY_RES_TYPE>(HOTTEST_PROJECTS_QUERY);
const { data, loading, error } = useHottestProjectsQuery();
if (error) {
return <div className="p-32">

View File

@@ -0,0 +1,12 @@
query HottestProjects {
hottestProjects {
id
thumbnail_image
title
votes_count
category {
title
id
}
}
}

View File

@@ -1,25 +0,0 @@
import { gql } from "@apollo/client";
import { ProjectCard } from "src/utils/interfaces";
export const HOTTEST_PROJECTS_QUERY = gql`
query HOTTEST_PROJECTS {
hottestProjects {
id
thumbnail_image
title
votes_count
category {
title
id
}
}
}
`
export type HOTTEST_PROJECTS_QUERY_VARS = {
}
export type HOTTEST_PROJECTS_QUERY_RES_TYPE = {
hottestProjects: ProjectCard[]
}

View File

@@ -0,0 +1,28 @@
query ProjectDetails($projectId: Int!) {
getProject(id: $projectId) {
id
title
description
cover_image
thumbnail_image
screenshots
website
lightning_address
lnurl_callback_url
votes_count
category {
id
title
}
awards {
title
image
url
id
}
tags {
id
title
}
}
}

View File

@@ -1,16 +1,15 @@
import { BsJoystick } from 'react-icons/bs'
import { MdClose, MdLocalFireDepartment } from 'react-icons/md';
import { ModalCard } from 'src/Components/Modals/ModalsContainer/ModalsContainer';
import { useQuery } from "@apollo/client";
import { useAppDispatch, useAppSelector } from 'src/utils/hooks';
import { openModal, scheduleModal } from 'src/redux/features/modals.slice';
import { setProject } from 'src/redux/features/project.slice';
import Button from 'src/Components/Button/Button';
import { PROJECT_BY_ID_QUERY, PROJECT_BY_ID_RES, PROJECT_BY_ID_VARS } from './query'
import { AiFillThunderbolt } from 'react-icons/ai';
import ProjectCardSkeleton from './ProjectDetailsCard.Skeleton'
import VoteButton from 'src/pages/ProjectPage/VoteButton/VoteButton';
import { Wallet_Service } from 'src/services'
import { useProjectDetailsQuery } from 'src/graphql';
interface Props extends ModalCard {
@@ -21,15 +20,16 @@ export default function ProjectDetailsCard({ onClose, direction, projectId, ...p
const dispatch = useAppDispatch();
const { loading } = useQuery<PROJECT_BY_ID_RES, PROJECT_BY_ID_VARS>(
PROJECT_BY_ID_QUERY,
{
variables: { projectId: projectId },
onCompleted: data => {
dispatch(setProject(data.getProject))
},
}
);
const { loading } =useProjectDetailsQuery({
variables: { projectId: projectId },
onCompleted: data => {
dispatch(setProject(data.getProject))
},
});
const { isWalletConnected, project, isMobileScreen } = useAppSelector(state => ({
isWalletConnected: state.wallet.isConnected,

View File

@@ -1,29 +0,0 @@
import { gql } from "@apollo/client";
import { Project } from "src/utils/interfaces";
export const PROJECT_BY_ID_QUERY = gql`
query Project($projectId: Int!) {
getProject(id: $projectId) {
id
cover_image
thumbnail_image
title
description
website
votes_count
screenshots
category {
title
id
}
}
}
`;
export interface PROJECT_BY_ID_RES {
getProject: Project;
}
export interface PROJECT_BY_ID_VARS {
projectId: number;
}

View File

@@ -8,8 +8,8 @@ import { gql, useMutation, useApolloClient } from "@apollo/client";
import Confetti from "react-confetti";
import { Wallet_Service } from 'src/services';
import styles from './style.module.css'
import { CONFIRM_VOTE_QUERY, CONFIRM_VOTE_QUERY_RES_TYPE, VOTE_QUERY, VOTE_QUERY_RES_TYPE } from './query';
import { useWindowSize } from '@react-hookz/web';
import { useConfirmVoteMutation, useVoteMutation } from 'src/graphql';
const defaultOptions = [
{ text: '100 sat', value: 100 },
@@ -46,7 +46,7 @@ export default function VoteCard({ onClose, direction, initVotes, projectId, ...
const [voteAmount, setVoteAmount] = useState<number>(initVotes ?? 10);
const [paymentStatus, setPaymentStatus] = useState<PaymentStatus>(PaymentStatus.DEFAULT);
const [vote, { data }] = useMutation<VOTE_QUERY_RES_TYPE>(VOTE_QUERY, {
const [vote, { data }] = useVoteMutation({
onCompleted: async (votingData) => {
try {
setPaymentStatus(PaymentStatus.AWAITING_PAYMENT);
@@ -75,11 +75,7 @@ export default function VoteCard({ onClose, direction, initVotes, projectId, ...
}
});
const [confirmVote, { data: confirmedVoteData }] = useMutation<CONFIRM_VOTE_QUERY_RES_TYPE>(CONFIRM_VOTE_QUERY, {
refetchQueries: [
'Project',
'AllCategoriesProjects'
],
const [confirmVote, { data: confirmedVoteData }] = useConfirmVoteMutation({
onCompleted: (votingData) => {
setPaymentStatus(PaymentStatus.PAYMENT_CONFIRMED);
setTimeout(() => {

View File

@@ -1,45 +0,0 @@
import { gql } from "@apollo/client";
export const VOTE_QUERY = gql`
mutation Vote($projectId: Int!, $amountInSat: Int!) {
vote(project_id: $projectId, amount_in_sat: $amountInSat) {
id
amount_in_sat
payment_request
payment_hash
paid
}
}
`;
export type VOTE_QUERY_RES_TYPE = {
vote: {
id: number;
amount_in_sat: number;
payment_request: string;
payment_hash: string;
paid: boolean;
}
}
export const CONFIRM_VOTE_QUERY = gql`
mutation ConfirmVote($paymentRequest: String!, $preimage: String!) {
confirmVote(payment_request: $paymentRequest, preimage: $preimage) {
id
amount_in_sat
paid
payment_hash
payment_request
}
}
`;
export type CONFIRM_VOTE_QUERY_RES_TYPE = {
confirmVote: {
id: number;
amount_in_sat: number;
paid: boolean;
payment_hash: string;
payment_request: string;
}
}

View File

@@ -0,0 +1,23 @@
mutation Vote($projectId: Int!, $amountInSat: Int!) {
vote(project_id: $projectId, amount_in_sat: $amountInSat) {
id
amount_in_sat
payment_request
payment_hash
paid
}
}
mutation ConfirmVote($paymentRequest: String!, $preimage: String!) {
confirmVote(payment_request: $paymentRequest, preimage: $preimage) {
id
amount_in_sat
payment_request
payment_hash
paid
project {
id
votes_count
}
}
}

View File

@@ -1,8 +1,4 @@
export interface Tag {
id: string;
title: string;
}
export type Image = string;

View File

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