Skip to content

Commit

Permalink
feat: ✨ (website/use-case) relateFingerprintWithUserUseCase use-case を作成
Browse files Browse the repository at this point in the history
  • Loading branch information
dino3616 committed Jan 22, 2024
1 parent 6a02204 commit 3a5fae6
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions apps/website/src/use-case/relate-fingerprint-with-user/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { User } from '#website/common/model/user';
import {
RelateFingerprintWithUserDocument,
type RelateFingerprintWithUserMutation,
type RelateFingerprintWithUserMutationVariables,
} from '#website/infra/graphql/generated/graphql';
import { urqlClient } from '#website/infra/urql';

type RelateFingerprintWithUserUseCase = (authId: User['authId'], hashedFingerprintId: string) => Promise<User>;

export const relateFingerprintWithUserUseCase: RelateFingerprintWithUserUseCase = async (authId, hashedFingerprintId) => {
const { data, error } = await urqlClient.mutation<RelateFingerprintWithUserMutation, RelateFingerprintWithUserMutationVariables>(
RelateFingerprintWithUserDocument,
{
where: {
authId,
},
hashedFingerprintId,
},
);
if (!data || error) {
throw error || new Error('Failed to relate fingerprint with user.');
}

return {
id: data.relateFingerprintWithUser.id,
authId: data.relateFingerprintWithUser.authId,
name: data.relateFingerprintWithUser.name,
email: data.relateFingerprintWithUser.email,
lostAndFoundState: data.relateFingerprintWithUser.lostAndFoundState,
avatarUrl: data.relateFingerprintWithUser.avatarUrl,
createdAt: data.relateFingerprintWithUser.createdAt,
};
};

0 comments on commit 3a5fae6

Please sign in to comment.