diff --git a/src/components/account/recommendations-section.tsx b/src/components/account/recommendations-section.tsx index 519cca7cd..b057389bc 100644 --- a/src/components/account/recommendations-section.tsx +++ b/src/components/account/recommendations-section.tsx @@ -23,8 +23,8 @@ import { Recommendation, RecommendationStatus, RecommendationType, -} from 'src/dto/recommendation.dto'; -import useRecommendation from 'src/hooks/recommendation.hook'; + useRecommendation, +} from '@dfx.swiss/react'; import { blankedAddress, formatSwissDate, partition, url } from 'src/util/utils'; interface RecommendationFormData { @@ -116,7 +116,7 @@ export function RecommendationsSection({ const action = confirm ? confirmRecommendation : rejectRecommendation; - action(recommendation) + action(recommendation.id) .then(() => loadRecommendations()) .catch((error: ApiError) => setRecommendationError(error.message ?? 'Unknown error')) .finally(() => { diff --git a/src/dto/recommendation.dto.ts b/src/dto/recommendation.dto.ts deleted file mode 100644 index a11b749bc..000000000 --- a/src/dto/recommendation.dto.ts +++ /dev/null @@ -1,35 +0,0 @@ -export enum RecommendationStatus { - CREATED = 'Created', - PENDING = 'Pending', - EXPIRED = 'Expired', - REJECTED = 'Rejected', - COMPLETED = 'Completed', -} - -export enum RecommendationType { - INVITATION = 'Invitation', - REQUEST = 'Request', -} - -export enum RecommendationMethod { - REF_CODE = 'RefCode', - MAIL = 'Mail', - RECOMMENDATION_CODE = 'RecommendationCode', -} - -export interface Recommendation { - id: number; - code?: string; - status: RecommendationStatus; - type: RecommendationType; - method: RecommendationMethod; - name?: string; - mail?: string; - confirmationDate?: Date; - expirationDate: Date; -} - -export interface CreateRecommendation { - recommendedMail?: string; - recommendedAlias: string; -} diff --git a/src/hooks/recommendation.hook.ts b/src/hooks/recommendation.hook.ts deleted file mode 100644 index 5f4f3b8c7..000000000 --- a/src/hooks/recommendation.hook.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { useApi } from '@dfx.swiss/react'; -import { useMemo } from 'react'; -import { CreateRecommendation, Recommendation } from 'src/dto/recommendation.dto'; - -interface RecommendationInterface { - getRecommendations: () => Promise; - createRecommendation: (data: CreateRecommendation) => Promise; - confirmRecommendation: (recommendation: Recommendation) => Promise; - rejectRecommendation: (recommendation: Recommendation) => Promise; -} - -export default function useRecommendation(): RecommendationInterface { - const { call } = useApi(); - - async function getRecommendations(): Promise { - return call({ - url: 'recommendation', - method: 'GET', - }); - } - - async function createRecommendation(data: CreateRecommendation): Promise { - return call({ - url: 'recommendation', - method: 'POST', - data, - }); - } - - async function confirmRecommendation(recommendation: Recommendation): Promise { - return call({ - url: `recommendation/${recommendation.id}/confirm`, - method: 'PUT', - }); - } - - async function rejectRecommendation(recommendation: Recommendation): Promise { - return call({ - url: `recommendation/${recommendation.id}/reject`, - method: 'PUT', - }); - } - - return useMemo( - () => ({ getRecommendations, createRecommendation, confirmRecommendation, rejectRecommendation }), - [call], - ); -}