diff --git a/dashboard/src/app/(inside)/client/page.tsx b/dashboard/src/app/(inside)/client/page.tsx index 439fd3e..0d3f5a3 100644 --- a/dashboard/src/app/(inside)/client/page.tsx +++ b/dashboard/src/app/(inside)/client/page.tsx @@ -1,5 +1,4 @@ import { getOAuth2Api } from '@/ory/sdk/server'; -import { parseTokens } from '@/app/(inside)/user/page'; import { ClientDataTable } from '@/app/(inside)/client/data-table'; export interface FetchClientPageProps { @@ -7,6 +6,26 @@ export interface FetchClientPageProps { pageToken: string; } +function parseTokens(link: string) { + + const parsed = link.split(',').map((it) => { + const startRel = it.lastIndexOf('rel="'); + const endRel = it.lastIndexOf('"'); + const rel = it.slice(startRel, endRel); + + const startToken = it.lastIndexOf('page_token='); + const endToken = it.lastIndexOf('&'); + const token = it.slice(startToken, endToken); + + return [rel, token]; + }); + + return new Map(parsed.map(obj => [ + obj[0].replace('rel="', ''), + obj[1].replace('page_token=', ''), + ])); +} + async function fetchClientPage({ pageSize, pageToken }: FetchClientPageProps) { 'use server';