Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/feature/application/application/application-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,18 @@ export const useApplicationQuery = ({
eventId,
walletAddress,
imageFile,
token,
}: {
eventId: string;
walletAddress: string;
imageFile: File;
token: string;
}) => {
return await applicationUsecase.submitApplication({
eventId,
walletAddress,
imageFile,
token,
});
},
onSuccess: (response) => {
Expand Down
5 changes: 4 additions & 1 deletion src/feature/application/usecase/application-usecase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type ApplicationUsecase = {
eventId: string;
walletAddress: string;
imageFile: File;
token: string;
}): UsecaseResponse<null>;
};

Expand Down Expand Up @@ -45,10 +46,11 @@ export const implApplicationUsecase = ({
return { type: 'error', code: err.code, message: err.message };
},

submitApplication: async ({ eventId, walletAddress, imageFile }) => {
submitApplication: async ({ eventId, walletAddress, imageFile, token }) => {
const presignedResp = await fileUsecase.getUploadPresignedUrl({
fileName: imageFile.name,
fileType: 'REVIEW',
contentType: imageFile.type,
});
if (presignedResp.type === 'error') {
return presignedResp;
Expand All @@ -64,6 +66,7 @@ export const implApplicationUsecase = ({

const { status, data } = await api['POST /api/applications']({
body: { eventId, walletAddress, imageKey: presignedResp.data.s3Key },
token,
});
if (status === 200) {
return { type: 'success', data: null };
Expand Down
5 changes: 3 additions & 2 deletions src/feature/file/usecase/file-usecase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type FileUsecase = {
getUploadPresignedUrl(params: {
fileName: string;
fileType: FileType;
contentType: string;
}): UsecaseResponse<S3UploadResponse>;
uploadFile(params: {
presignedUrl: string;
Expand All @@ -22,9 +23,9 @@ export const implFileUsecase = ({
api: Apis;
storageApi: StorageApis;
}): FileUsecase => ({
getUploadPresignedUrl: async ({ fileName, fileType }) => {
getUploadPresignedUrl: async ({ fileName, fileType, contentType }) => {
const { status, data } = await api['POST /api/s3']({
body: { fileName, fileType },
body: { fileName, fileType, contentType },
});
if (status === 200) {
return { type: 'success', data: data as S3UploadResponse };
Expand Down
11 changes: 9 additions & 2 deletions src/infrastructure/api/apis/local-server/apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,18 @@ export const getLocalServerApis = ({
path: 'api/s3',
body,
}),
'POST /api/applications': ({ body }: { body: ApplicationCreateRequest }) =>
callWithoutToken<SuccessResponse<null>>({
'POST /api/applications': ({
body,
token,
}: {
body: ApplicationCreateRequest;
token: string;
}) =>
callWithToken<SuccessResponse<null>>({
method: 'POST',
path: 'api/applications',
body,
token,
}),

// Event
Expand Down
1 change: 1 addition & 0 deletions src/infrastructure/api/apis/local-server/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export type S3FileType = 'REVIEW' | 'STORE';
export type S3UploadRequest = {
fileName: string;
fileType: S3FileType;
contentType: string;
};

export type S3UploadResponse = {
Expand Down
1 change: 1 addition & 0 deletions src/mocks/s3/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export type S3FileType = 'REVIEW' | 'STORE';
export type S3UploadRequest = {
fileName: string;
fileType: S3FileType;
contentType: string;
};

export type S3UploadResponse = {
Expand Down
8 changes: 8 additions & 0 deletions src/widgets/application/ui/submit-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useParams } from 'react-router';
import { applicationFormPresenter } from '@/feature/application/presenter/application-form-presenter';
import { applicationInputPresenter } from '@/feature/application/presenter/application-input-presenter';
import { QueryContext } from '@/feature/shared/context/query-context';
import { TokenContext } from '@/feature/shared/context/token-context';
import { useGuardContext } from '@/feature/shared/context/use-gaurd-context';
import { Button } from '@/widgets/common/ui/button';
import {
Expand Down Expand Up @@ -32,6 +33,7 @@ export const SubmitForm = () => {
}>();

const { applicationQuery } = useGuardContext(QueryContext);
const { token } = useGuardContext(TokenContext);

const { store } = applicationQuery.useGetStore({ storeId: storeId ?? '' });
const { event } = applicationQuery.useGetEvent({ eventId: eventId ?? '' });
Expand Down Expand Up @@ -133,10 +135,16 @@ export const SubmitForm = () => {
return;
}

if (token === null) {
setResponseMessage('둜그인이 ν•„μš”ν•©λ‹ˆλ‹€.');
return;
}

submitApplication({
eventId,
walletAddress: inputStates.walletAddress.value,
imageFile: inputStates.imageFile.value,
token,
});
};

Expand Down
Loading