-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add processes pagination filter by status And updated the sidebar links to point to these new filters * Remove unused method * Minor varname change * Review fixes
- Loading branch information
1 parent
0c2767d
commit 8b50bb2
Showing
6 changed files
with
104 additions
and
107 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,21 @@ | ||
import { useQuery } from '@tanstack/react-query' | ||
import { useClient } from '@vocdoni/react-providers' | ||
import { AccountData, FetchElectionsParameters, VocdoniSDKClient } from '@vocdoni/sdk' | ||
|
||
export const useLatestElections = (limit = 5) => { | ||
const { client, account } = useClient() | ||
|
||
return useQuery({ | ||
enabled: !!account?.address, | ||
queryKey: ['organization', 'elections', account?.address, 0], | ||
queryFn: async () => client.fetchElections({ organizationId: account?.address, page: 0, limit }), | ||
select: (data) => data.elections, | ||
retry: false, | ||
}) | ||
type PaginatedElectionsParams = { | ||
page?: number | ||
status?: FetchElectionsParameters['status'] | ||
} | ||
|
||
export const usePaginatedElections = (page: number) => { | ||
const { client, account } = useClient() | ||
|
||
return useQuery({ | ||
enabled: !!account?.address, | ||
queryKey: ['organization', 'elections', account?.address, page], | ||
queryFn: async () => client.fetchElections({ organizationId: account?.address, page }), | ||
}) | ||
} | ||
export const paginatedElectionsQuery = ( | ||
account: AccountData, | ||
client: VocdoniSDKClient, | ||
params: PaginatedElectionsParams | ||
) => ({ | ||
enabled: !!account?.address, | ||
queryKey: ['organization', 'elections', account?.address, params], | ||
queryFn: async () => | ||
client.fetchElections({ | ||
organizationId: account?.address, | ||
page: params.page ? Number(params.page) - 1 : 0, | ||
status: params.status?.toUpperCase() as FetchElectionsParameters['status'], | ||
}), | ||
}) |
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
8b50bb2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π Published on https://vocdoni-app-dev.netlify.app as production
π Deployed on https://6735d4dce375824dc4f4cabd--vocdoni-app-dev.netlify.app
8b50bb2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π Published on https://vocdoni-app-stg.netlify.app as production
π Deployed on https://6735d4e2e375824d08f4c5dd--vocdoni-app-stg.netlify.app