-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into feat-1500-project-update-admin
- Loading branch information
Showing
31 changed files
with
222 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...marketplace/src/components/templates/ProjectFormTemplate/ProjectFormTemplate.constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const CREATE_PROJECT_URL_REGEX = /\/project-pages\/([a-z0-9-]+)\/(.*)/g; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
web-marketplace/src/lib/normalizers/creditClass/normalizeCreditClassItems.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { getClassImageWithGreenDefault } from 'utils/image/classImage'; | ||
|
||
import { AllCreditClassesQuery } from 'generated/graphql'; | ||
import { IndexerClassesByIssuerQuery, Maybe } from 'generated/indexer-graphql'; | ||
import { AllCreditClassQuery } from 'generated/sanity-graphql'; | ||
import { CreditClassMetadataLD } from 'lib/db/types/json-ld'; | ||
|
||
import { CreditClassItem } from './normalizeCreditClassItems.types'; | ||
|
||
type Params = { | ||
classesByIssuer?: Maybe<IndexerClassesByIssuerQuery>; | ||
classesMetadata?: (CreditClassMetadataLD | undefined)[]; | ||
sanityCreditClasses?: AllCreditClassQuery; | ||
offChainCreditClasses?: AllCreditClassesQuery; | ||
}; | ||
|
||
export const normalizeCreditClassItems = ({ | ||
classesByIssuer, | ||
classesMetadata, | ||
sanityCreditClasses, | ||
offChainCreditClasses, | ||
}: Params): CreditClassItem[] => { | ||
return ( | ||
classesByIssuer?.allClassIssuers?.nodes.map((creditClass, index) => { | ||
const metadata = classesMetadata?.[index]; | ||
const creditClassOnChainId = creditClass?.classId; | ||
const sanityCreditClass = sanityCreditClasses?.allCreditClass.find( | ||
sanityCreditClass => sanityCreditClass.path === sanityCreditClass, | ||
); | ||
const offChainCreditClass = | ||
offChainCreditClasses?.allCreditClasses?.nodes.find( | ||
creditClass => creditClass?.onChainId === creditClassOnChainId, | ||
); | ||
|
||
const name = metadata?.['schema:name']; | ||
const title = name | ||
? `${name} (${creditClassOnChainId})` | ||
: creditClassOnChainId; | ||
|
||
return { | ||
id: offChainCreditClass?.id ?? '', | ||
imageSrc: getClassImageWithGreenDefault({ | ||
metadata, | ||
sanityClass: sanityCreditClass, | ||
}), | ||
onChainId: creditClassOnChainId ?? '', | ||
title: title ?? '', | ||
description: metadata?.['schema:description'], | ||
}; | ||
}) ?? [] | ||
); | ||
}; |
8 changes: 8 additions & 0 deletions
8
web-marketplace/src/lib/normalizers/creditClass/normalizeCreditClassItems.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export interface CreditClassItem { | ||
id: string; | ||
onChainId: string; | ||
imageSrc: string; | ||
title: string; | ||
description?: string; | ||
disabled?: boolean; | ||
} |
1 change: 1 addition & 0 deletions
1
...ry/registry-server/graphql/getAllCreditClassesQuery/getAllCreditClassesQuery.constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const ALL_CREDIT_CLASSES_KEY = 'AllCreditClassesQuery'; |
25 changes: 25 additions & 0 deletions
25
.../react-query/registry-server/graphql/getAllCreditClassesQuery/getAllCreditClassesQuery.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { | ||
AllCreditClassesDocument, | ||
AllCreditClassesQuery, | ||
} from 'generated/graphql'; | ||
|
||
import { ALL_CREDIT_CLASSES_KEY } from './getAllCreditClassesQuery.constants'; | ||
import { | ||
ReactQueryGetAllCreditClassesParams, | ||
ReactQueryGetAllCreditClassesResponse, | ||
} from './getAllCreditClassesQuery.types'; | ||
|
||
export const getAllCreditClassesQuery = ({ | ||
client, | ||
...params | ||
}: ReactQueryGetAllCreditClassesParams): ReactQueryGetAllCreditClassesResponse => ({ | ||
queryKey: [ALL_CREDIT_CLASSES_KEY], | ||
queryFn: async () => { | ||
const { data } = await client.query<AllCreditClassesQuery>({ | ||
query: AllCreditClassesDocument, | ||
}); | ||
|
||
return data; | ||
}, | ||
...params, | ||
}); |
13 changes: 13 additions & 0 deletions
13
...-query/registry-server/graphql/getAllCreditClassesQuery/getAllCreditClassesQuery.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { ApolloClient, NormalizedCacheObject } from '@apollo/client'; | ||
import { QueryObserverOptions } from '@tanstack/react-query'; | ||
|
||
import { AllCreditClassesQuery } from 'generated/graphql'; | ||
|
||
import { ReactQueryBuilderResponse } from '../../../types/react-query.types'; | ||
|
||
export type ReactQueryGetAllCreditClassesResponse = | ||
QueryObserverOptions<AllCreditClassesQuery>; | ||
|
||
export type ReactQueryGetAllCreditClassesParams = { | ||
client: ApolloClient<NormalizedCacheObject>; | ||
} & ReactQueryBuilderResponse<ReactQueryGetAllCreditClassesResponse>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.