diff --git a/src/webapp/api-client/ApiClient.ts b/src/webapp/api-client/ApiClient.ts index b4bf96e4..8cebe888 100644 --- a/src/webapp/api-client/ApiClient.ts +++ b/src/webapp/api-client/ApiClient.ts @@ -48,14 +48,14 @@ import type { GetUrlMetadataResponse, GetUrlCardViewResponse, GetLibrariesForCardResponse, - GetMyProfileResponse, GetCollectionPageResponse, GetGlobalFeedResponse, GetCollectionsResponse, GetCollectionsParams, GetUrlCardsParams, GetUrlCardsResponse, - GetUserProfileParams, + GetProfileResponse, + GetProfileParams, } from './types'; // Main API Client class using composition @@ -116,12 +116,12 @@ export class ApiClient { return this.queryClient.getLibrariesForCard(cardId); } - async getMyProfile(): Promise { + async getMyProfile(): Promise { this.requireAuthentication('getMyProfile'); return this.queryClient.getMyProfile(); } - async getUserProfile(params: GetUserProfileParams): Promise { + async getProfile(params: GetProfileParams): Promise { return this.queryClient.getUserProfile(params); } diff --git a/src/webapp/api-client/clients/QueryClient.ts b/src/webapp/api-client/clients/QueryClient.ts index f00f4411..f2a21974 100644 --- a/src/webapp/api-client/clients/QueryClient.ts +++ b/src/webapp/api-client/clients/QueryClient.ts @@ -1,18 +1,18 @@ import { BaseClient } from './BaseClient'; import { GetUrlMetadataResponse, - GetMyUrlCardsResponse, + GetUrlCardsResponse, GetUrlCardViewResponse, GetLibrariesForCardResponse, - GetMyProfileResponse, + GetProfileResponse, GetCollectionPageResponse, - GetMyCollectionsResponse, + GetCollectionsResponse, GetMyUrlCardsParams, - GetUserUrlCardsParams, + GetUrlCardsParams, GetCollectionPageParams, GetMyCollectionsParams, - GetUserCollectionsParams, - GetUserProfileParams, + GetCollectionsParams, + GetProfileParams, } from '../types'; export class QueryClient extends BaseClient { @@ -26,7 +26,7 @@ export class QueryClient extends BaseClient { async getMyUrlCards( params?: GetMyUrlCardsParams, - ): Promise { + ): Promise { const searchParams = new URLSearchParams(); if (params?.page) searchParams.set('page', params.page.toString()); if (params?.limit) searchParams.set('limit', params.limit.toString()); @@ -38,12 +38,12 @@ export class QueryClient extends BaseClient { ? `/api/cards/my?${queryString}` : '/api/cards/my'; - return this.request('GET', endpoint); + return this.request('GET', endpoint); } async getUserUrlCards( - params: GetUserUrlCardsParams, - ): Promise { + params: GetUrlCardsParams, + ): Promise { const searchParams = new URLSearchParams(); if (params.page) searchParams.set('page', params.page.toString()); if (params.limit) searchParams.set('limit', params.limit.toString()); @@ -55,7 +55,7 @@ export class QueryClient extends BaseClient { ? `/api/cards/user/${params.did}?${queryString}` : `/api/cards/user/${params.did}`; - return this.request('GET', endpoint); + return this.request('GET', endpoint); } async getUrlCardView(cardId: string): Promise { @@ -71,12 +71,12 @@ export class QueryClient extends BaseClient { ); } - async getMyProfile(): Promise { - return this.request('GET', '/api/users/me'); + async getMyProfile(): Promise { + return this.request('GET', '/api/users/me'); } - async getUserProfile(params: GetUserProfileParams): Promise { - return this.request('GET', `/api/users/${params.did}`); + async getUserProfile(params: GetProfileParams): Promise { + return this.request('GET', `/api/users/${params.did}`); } async getCollectionPage( @@ -99,7 +99,7 @@ export class QueryClient extends BaseClient { async getMyCollections( params?: GetMyCollectionsParams, - ): Promise { + ): Promise { const searchParams = new URLSearchParams(); if (params?.page) searchParams.set('page', params.page.toString()); if (params?.limit) searchParams.set('limit', params.limit.toString()); @@ -112,12 +112,12 @@ export class QueryClient extends BaseClient { ? `/api/collections?${queryString}` : '/api/collections'; - return this.request('GET', endpoint); + return this.request('GET', endpoint); } async getUserCollections( - params: GetUserCollectionsParams, - ): Promise { + params: GetCollectionsParams, + ): Promise { const searchParams = new URLSearchParams(); if (params.page) searchParams.set('page', params.page.toString()); if (params.limit) searchParams.set('limit', params.limit.toString()); @@ -127,9 +127,9 @@ export class QueryClient extends BaseClient { const queryString = searchParams.toString(); const endpoint = queryString - ? `/api/collections/user/${params.handle}?${queryString}` - : `/api/collections/user/${params.handle}`; + ? `/api/collections/user/${params.did}?${queryString}` + : `/api/collections/user/${params.did}`; - return this.request('GET', endpoint); + return this.request('GET', endpoint); } } diff --git a/src/webapp/api-client/types/requests.ts b/src/webapp/api-client/types/requests.ts index 97b5fd67..8ec2f50e 100644 --- a/src/webapp/api-client/types/requests.ts +++ b/src/webapp/api-client/types/requests.ts @@ -115,6 +115,6 @@ export interface GenerateExtensionTokensRequest { // No additional parameters needed - user is authenticated via middleware } -export interface GetUserProfileParams { +export interface GetProfileParams { did: string; } diff --git a/src/webapp/api-client/types/responses.ts b/src/webapp/api-client/types/responses.ts index 8e987efc..1f88ca9f 100644 --- a/src/webapp/api-client/types/responses.ts +++ b/src/webapp/api-client/types/responses.ts @@ -106,7 +106,7 @@ export interface UserProfile { avatarUrl?: string; } -export interface GetMyProfileResponse extends UserProfile {} +export interface GetProfileResponse extends UserProfile {} export interface UrlCardListItem { id: string; diff --git a/src/webapp/features/cards/components/addCardToModal/CardToBeAddedPreview.tsx b/src/webapp/features/cards/components/addCardToModal/CardToBeAddedPreview.tsx index ccab82dd..9ef53060 100644 --- a/src/webapp/features/cards/components/addCardToModal/CardToBeAddedPreview.tsx +++ b/src/webapp/features/cards/components/addCardToModal/CardToBeAddedPreview.tsx @@ -11,7 +11,7 @@ import { Anchor, } from '@mantine/core'; import Link from 'next/link'; -import { GetMyCollectionsResponse, UrlCardView } from '@/api-client/types'; +import { GetCollectionsResponse, UrlCardView } from '@/api-client/types'; import { BiCollection } from 'react-icons/bi'; import { LuLibrary } from 'react-icons/lu'; import { getDomain } from '@/lib/utils/link'; @@ -20,7 +20,7 @@ import useMyProfile from '@/features/profile/lib/queries/useMyProfile'; interface Props { cardId: string; cardContent: UrlCardView['cardContent']; - collectionsWithCard: GetMyCollectionsResponse['collections']; + collectionsWithCard: GetCollectionsResponse['collections']; isInLibrary: boolean; } diff --git a/src/webapp/features/collections/components/addToCollectionModal/CardToBeAddedPreview.tsx b/src/webapp/features/collections/components/addToCollectionModal/CardToBeAddedPreview.tsx index e51c8566..8f23933e 100644 --- a/src/webapp/features/collections/components/addToCollectionModal/CardToBeAddedPreview.tsx +++ b/src/webapp/features/collections/components/addToCollectionModal/CardToBeAddedPreview.tsx @@ -10,14 +10,14 @@ import { ScrollArea, Anchor, } from '@mantine/core'; -import { GetMyCollectionsResponse, UrlCardView } from '@/api-client/types'; +import { GetCollectionsResponse, UrlCardView } from '@/api-client/types'; import Link from 'next/link'; import { getDomain } from '@/lib/utils/link'; import { BiSolidChevronDownCircle } from 'react-icons/bi'; interface Props { cardContent: UrlCardView['cardContent']; - collectionsWithCard: GetMyCollectionsResponse['collections']; + collectionsWithCard: GetCollectionsResponse['collections']; } export default function CardToBeAddedPreview(props: Props) { diff --git a/src/webapp/hooks/useCollectionSearch.ts b/src/webapp/hooks/useCollectionSearch.ts index 75004458..da7615a1 100644 --- a/src/webapp/hooks/useCollectionSearch.ts +++ b/src/webapp/hooks/useCollectionSearch.ts @@ -1,6 +1,6 @@ import { useState, useEffect, useCallback, useMemo, useRef } from 'react'; import { ApiClient } from '@/api-client/ApiClient'; -import type { GetMyCollectionsResponse } from '@/api-client/types'; +import type { GetCollectionsResponse } from '@/api-client/types'; interface UseCollectionSearchProps { apiClient: ApiClient; @@ -14,7 +14,7 @@ export function useCollectionSearch({ debounceMs = 300, }: UseCollectionSearchProps) { const [collections, setCollections] = useState< - GetMyCollectionsResponse['collections'] + GetCollectionsResponse['collections'] >([]); const [loading, setLoading] = useState(false); const [searchText, setSearchText] = useState('');