Skip to content

Commit

Permalink
fix: make sure collection name is always set
Browse files Browse the repository at this point in the history
  • Loading branch information
beeman committed Sep 10, 2023
1 parent fc91298 commit c93324d
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion api-schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ type Collection {
id: String!
imageUrl: String
metadataUrl: String
name: String
name: String!
network: NetworkType
symbol: String
updatedAt: DateTime!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class Collection {
account!: string
@Field(() => Int, { nullable: true })
assetCount!: number
@Field({ nullable: true })
@Field()
name?: string | null
@Field({ nullable: true })
imageUrl?: string | null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ export class ApiCollectionFieldResolver {
combos(@Parent() collection: Collection) {
return collection.combos ?? []
}

@ResolveField(() => String)
name(@Parent() collection: Collection) {
return collection.name ?? collection.account ?? 'Unknown'
}
}
30 changes: 15 additions & 15 deletions libs/sdk/src/generated/graphql-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export type Collection = {
id: Scalars['String']
imageUrl?: Maybe<Scalars['String']>
metadataUrl?: Maybe<Scalars['String']>
name?: Maybe<Scalars['String']>
name: Scalars['String']
network?: Maybe<NetworkType>
symbol?: Maybe<Scalars['String']>
updatedAt: Scalars['DateTime']
Expand Down Expand Up @@ -1111,7 +1111,7 @@ export type UserFindManyAssetQuery = {
createdAt: Date
account?: string | null
id: string
name?: string | null
name: string
imageUrl?: string | null
metadataUrl?: string | null
description?: string | null
Expand Down Expand Up @@ -1211,7 +1211,7 @@ export type UserFindOneAssetQuery = {
createdAt: Date
account?: string | null
id: string
name?: string | null
name: string
imageUrl?: string | null
metadataUrl?: string | null
description?: string | null
Expand Down Expand Up @@ -1582,7 +1582,7 @@ export type CollectionDetailsFragment = {
createdAt: Date
account?: string | null
id: string
name?: string | null
name: string
imageUrl?: string | null
metadataUrl?: string | null
description?: string | null
Expand Down Expand Up @@ -1624,7 +1624,7 @@ export type AdminFindManyCollectionQuery = {
createdAt: Date
account?: string | null
id: string
name?: string | null
name: string
imageUrl?: string | null
metadataUrl?: string | null
description?: string | null
Expand Down Expand Up @@ -1676,7 +1676,7 @@ export type AdminFindOneCollectionQuery = {
createdAt: Date
account?: string | null
id: string
name?: string | null
name: string
imageUrl?: string | null
metadataUrl?: string | null
description?: string | null
Expand Down Expand Up @@ -1726,7 +1726,7 @@ export type AdminCreateCollectionMutation = {
createdAt: Date
account?: string | null
id: string
name?: string | null
name: string
imageUrl?: string | null
metadataUrl?: string | null
description?: string | null
Expand Down Expand Up @@ -1768,7 +1768,7 @@ export type AdminUpdateCollectionMutation = {
createdAt: Date
account?: string | null
id: string
name?: string | null
name: string
imageUrl?: string | null
metadataUrl?: string | null
description?: string | null
Expand Down Expand Up @@ -1827,7 +1827,7 @@ export type UserFindManyCollectionQuery = {
createdAt: Date
account?: string | null
id: string
name?: string | null
name: string
imageUrl?: string | null
metadataUrl?: string | null
description?: string | null
Expand Down Expand Up @@ -1879,7 +1879,7 @@ export type UserFindOneCollectionQuery = {
createdAt: Date
account?: string | null
id: string
name?: string | null
name: string
imageUrl?: string | null
metadataUrl?: string | null
description?: string | null
Expand Down Expand Up @@ -1967,7 +1967,7 @@ export type DiscordRoleConditionDetailsFragment = {
createdAt: Date
account?: string | null
id: string
name?: string | null
name: string
imageUrl?: string | null
metadataUrl?: string | null
description?: string | null
Expand Down Expand Up @@ -2036,7 +2036,7 @@ export type DiscordRoleDetailsFragment = {
createdAt: Date
account?: string | null
id: string
name?: string | null
name: string
imageUrl?: string | null
metadataUrl?: string | null
description?: string | null
Expand Down Expand Up @@ -2169,7 +2169,7 @@ export type AdminFindOneDiscordServerQuery = {
createdAt: Date
account?: string | null
id: string
name?: string | null
name: string
imageUrl?: string | null
metadataUrl?: string | null
description?: string | null
Expand Down Expand Up @@ -2334,7 +2334,7 @@ export type UserFindManyDiscordServerQuery = {
createdAt: Date
account?: string | null
id: string
name?: string | null
name: string
imageUrl?: string | null
metadataUrl?: string | null
description?: string | null
Expand Down Expand Up @@ -2710,7 +2710,7 @@ export type AdminFindOneNetworkQuery = {
createdAt: Date
account?: string | null
id: string
name?: string | null
name: string
imageUrl?: string | null
metadataUrl?: string | null
description?: string | null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ export function useUserFindManyAsset(
const total = query.data?.paging.meta.totalCount ?? 0
const items = query.data?.paging.data ?? []
const collections: AssetGroup[] = useMemo(
() =>
groupAssetsByCollection(items).sort((a, b) => (a.collection.name ?? '').localeCompare(b.collection?.name ?? '')),
() => groupAssetsByCollection(items).sort((a, b) => a.collection.name.localeCompare(b.collection.name)),
[items],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function useAdminFindManyCollection() {
return {
items,
collectionOptions: items.map((item) => ({
label: `${item.name ?? item.account}`,
label: item.name,
value: item.account ?? '',
})),
query,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function WebCollectionUiDashboard() {
))
) : (
<WebProfileUiAssetAttributes
name={collection.name ?? 'Unknown'}
name={collection.name}
network={collection.network as NetworkType}
collectionAccount={collection.account ?? ''}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function DiscordUiRoleAddCollection({
() =>
items
// Map to option
.map((item) => ({ value: item.id, label: `${item.name ?? item.account}` })),
.map((item) => ({ value: item.id, label: item.name })),
// Filter out already added collections
// .filter((item) => !condition.collections?.find((collection) => collection.id === item.value)),
[items, condition.collections],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function DiscordUiViewRoleConditions({ role }: { role: DiscordRole }) {
? condition.collections.map((coll) => (
<UiStack key={coll.id}>
<WebProfileUiAssetAttributes
name={coll.name ?? 'Unknown'}
name={coll.name}
network={coll.network as NetworkType}
collectionAccount={coll.account ?? ''}
/>
Expand Down

0 comments on commit c93324d

Please sign in to comment.