Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENG-4049 fix(portal): Update list filtering by user position & bump API #841

Merged
merged 1 commit into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion apps/portal/app/lib/services/lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,16 @@ export async function getListIdentities({
request,
objectId,
creator,
userWithPosition,
searchParams,
userAssetsForPresent = null,
}: {
request: Request
objectId: string
creator?: string
userWithPosition?: string
searchParams: URLSearchParams
userAssetsForPresent?: boolean | null
}) {
const { page, limit, sortBy, direction } = getStandardPageParams({
searchParams,
Expand All @@ -141,6 +145,8 @@ export async function getListIdentities({
object: objectId,
displayName,
creator,
userWithPosition,
userAssetsForPresent,
},
})

Expand All @@ -157,7 +163,6 @@ export async function getListIdentities({
currentPage: Number(page),
limit: Number(limit),
totalEntries: listIdentities.total,

totalPages,
},
}
Expand All @@ -167,19 +172,25 @@ export async function getListIdentitiesCount({
request,
objectId,
creator,
userWithPosition,
userAssetsForPresent = null,
}: {
request: Request
objectId: string
creator?: string
userWithPosition?: string
userAssetsForPresent?: boolean | null
}) {
const listIdentities = await fetchWrapper(request, {
method: ClaimsService.searchClaims,
args: {
predicate: getSpecialPredicate(CURRENT_ENV).tagPredicate.id,
object: objectId,
creator,
userWithPosition,
page: 1,
limit: 1,
userAssetsPresent: userAssetsForPresent,
},
})

Expand Down
27 changes: 15 additions & 12 deletions apps/portal/app/routes/app+/list+/$id+/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ import { useAtom, useSetAtom } from 'jotai'

export async function loader({ request, params }: LoaderFunctionArgs) {
const id = params.id

invariant(id, NO_PARAM_ID_ERROR)

const wallet = await requireUserWallet(request)
Expand Down Expand Up @@ -87,7 +86,6 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
method: ClaimsService.getClaimById,
args: { id },
})

invariant(claim.object?.id, NO_PARAM_ID_ERROR)

const totalGlobalIdentitiesCount = getListIdentitiesCount({
Expand All @@ -98,9 +96,18 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const totalUserIdentitiesCount = getListIdentitiesCount({
request,
objectId: claim.object.id,
creator: wallet,
userWithPosition: userObject.id,
userAssetsForPresent: true,
})

const totalAdditionalUserIdentitiesCount = paramWallet
? getListIdentitiesCount({
request,
objectId: claim.object.id,
userWithPosition: additionalUserObject?.id,
userAssetsForPresent: true,
})
: 0
return defer({
wallet,
userObject,
Expand All @@ -112,26 +119,22 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
userListIdentities: getListIdentities({
request,
objectId: claim.object.id,
creator: wallet,
searchParams,
userWithPosition: userObject.id,
userAssetsForPresent: true,
}),
additionalUserListIdentities: paramWallet
? getListIdentities({
request,
objectId: claim.object.id,
creator: paramWallet,
searchParams,
userWithPosition: additionalUserObject?.id,
userAssetsForPresent: true,
})
: null,
totalGlobalIdentitiesCount,
totalUserIdentitiesCount,
additionalTotalUserIdentitiesCount: paramWallet
? getListIdentitiesCount({
request,
objectId: claim.object.id,
creator: paramWallet,
})
: [],
additionalTotalUserIdentitiesCount: totalAdditionalUserIdentitiesCount,
additionalUserObject,
})
}
Expand Down
22 changes: 12 additions & 10 deletions apps/portal/app/routes/readonly+/list+/$id+/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import { IdentityListType, VaultDetailsType } from 'app/types'

export async function loader({ request, params }: LoaderFunctionArgs) {
const id = params.id

invariant(id, NO_PARAM_ID_ERROR)

const url = new URL(request.url)
Expand All @@ -63,14 +62,22 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
method: ClaimsService.getClaimById,
args: { id },
})

invariant(claim.object?.id, NO_PARAM_ID_ERROR)

const totalGlobalIdentitiesCount = getListIdentitiesCount({
request,
objectId: claim.object.id,
})

const totalAdditionalUserIdentitiesCount = paramWallet
? getListIdentitiesCount({
request,
objectId: claim.object.id,
userWithPosition: additionalUserObject?.id,
userAssetsForPresent: true,
})
: 0

return defer({
globalListIdentities: getListIdentities({
request,
Expand All @@ -86,18 +93,13 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
? getListIdentities({
request,
objectId: claim.object.id,
creator: paramWallet,
searchParams,
userWithPosition: additionalUserObject?.id,
userAssetsForPresent: true,
})
: null,
totalGlobalIdentitiesCount,
additionalTotalUserIdentitiesCount: paramWallet
? getListIdentitiesCount({
request,
objectId: claim.object.id,
creator: paramWallet,
})
: [],
totalAdditionalUserIdentitiesCount,
additionalUserObject,
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/api-client/core/OpenAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const OpenAPI: OpenAPIConfig = {
PASSWORD: undefined,
TOKEN: undefined,
USERNAME: undefined,
VERSION: '0.63.0',
VERSION: '0.67.0',
WITH_CREDENTIALS: false,
interceptors: {
request: new Interceptors(),
Expand Down
28 changes: 28 additions & 0 deletions packages/api/src/api-client/services.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,13 @@ export class ClaimsService {
* @param data.displayName
* @param data.counterVault
* @param data.status
* @param data.userWithPosition
* @param data.userAssetsFor
* @param data.userAssetsForPresent
* @param data.userAssetsAgainst
* @param data.userAssetsAgainstPresent
* @param data.userAssets
* @param data.userAssetsPresent
* @returns unknown Search claims in paginated list
* @throws ApiError
*/
Expand All @@ -530,6 +537,13 @@ export class ClaimsService {
displayName: data.displayName,
counterVault: data.counterVault,
status: data.status,
userWithPosition: data.userWithPosition,
userAssetsFor: data.userAssetsFor,
userAssetsForPresent: data.userAssetsForPresent,
userAssetsAgainst: data.userAssetsAgainst,
userAssetsAgainstPresent: data.userAssetsAgainstPresent,
userAssets: data.userAssets,
userAssetsPresent: data.userAssetsPresent,
},
})
}
Expand All @@ -550,6 +564,13 @@ export class ClaimsService {
* @param data.displayName
* @param data.counterVault
* @param data.status
* @param data.userWithPosition
* @param data.userAssetsFor
* @param data.userAssetsForPresent
* @param data.userAssetsAgainst
* @param data.userAssetsAgainstPresent
* @param data.userAssets
* @param data.userAssetsPresent
* @returns unknown Summary of claim values based on query
* @throws ApiError
*/
Expand All @@ -574,6 +595,13 @@ export class ClaimsService {
displayName: data.displayName,
counterVault: data.counterVault,
status: data.status,
userWithPosition: data.userWithPosition,
userAssetsFor: data.userAssetsFor,
userAssetsForPresent: data.userAssetsForPresent,
userAssetsAgainst: data.userAssetsAgainst,
userAssetsAgainstPresent: data.userAssetsAgainstPresent,
userAssets: data.userAssets,
userAssetsPresent: data.userAssetsPresent,
},
})
}
Expand Down
30 changes: 30 additions & 0 deletions packages/api/src/api-client/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,7 @@ export type QuestCondition =
| 'create_tag_claim'
| 'stake_claim'
| 'stake_identity'
| 'unimplemented'

/**
* This enum represents the conditions that we can handle for quests
Expand All @@ -941,6 +942,7 @@ export const QuestCondition = {
CREATE_TAG_CLAIM: 'create_tag_claim',
STAKE_CLAIM: 'stake_claim',
STAKE_IDENTITY: 'stake_identity',
UNIMPLEMENTED: 'unimplemented',
} as const

/**
Expand Down Expand Up @@ -1789,6 +1791,13 @@ export type SearchClaimsData = {
sortBy?: ClaimSortColumn | null
status?: Status | null
subject?: Identifier | null
userAssets?: number | null
userAssetsAgainst?: number | null
userAssetsAgainstPresent?: boolean | null
userAssetsFor?: number | null
userAssetsForPresent?: boolean | null
userAssetsPresent?: boolean | null
userWithPosition?: string | null
vault?: Identifier | null
}

Expand All @@ -1813,6 +1822,13 @@ export type ClaimSummaryData = {
sortBy?: ClaimSortColumn | null
status?: Status | null
subject?: Identifier | null
userAssets?: number | null
userAssetsAgainst?: number | null
userAssetsAgainstPresent?: boolean | null
userAssetsFor?: number | null
userAssetsForPresent?: boolean | null
userAssetsPresent?: boolean | null
userWithPosition?: string | null
vault?: Identifier | null
}

Expand Down Expand Up @@ -3695,6 +3711,13 @@ export type $OpenApiTs = {
sortBy?: ClaimSortColumn | null
status?: Status | null
subject?: Identifier | null
userAssets?: number | null
userAssetsAgainst?: number | null
userAssetsAgainstPresent?: boolean | null
userAssetsFor?: number | null
userAssetsForPresent?: boolean | null
userAssetsPresent?: boolean | null
userWithPosition?: string | null
vault?: Identifier | null
}
res: {
Expand Down Expand Up @@ -3726,6 +3749,13 @@ export type $OpenApiTs = {
sortBy?: ClaimSortColumn | null
status?: Status | null
subject?: Identifier | null
userAssets?: number | null
userAssetsAgainst?: number | null
userAssetsAgainstPresent?: boolean | null
userAssetsFor?: number | null
userAssetsForPresent?: boolean | null
userAssetsPresent?: boolean | null
userWithPosition?: string | null
vault?: Identifier | null
}
res: {
Expand Down
Loading