From 0aca70b9fd650b0dd9d156808da3fde295089b42 Mon Sep 17 00:00:00 2001 From: Kwon770 Date: Mon, 23 Sep 2024 21:14:24 +0900 Subject: [PATCH 1/6] chore: Addm missing git pull command in dev-deploy.ymal --- .github/workflows/dev-deploy.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/dev-deploy.yaml b/.github/workflows/dev-deploy.yaml index a963f7a..f0a3b0d 100644 --- a/.github/workflows/dev-deploy.yaml +++ b/.github/workflows/dev-deploy.yaml @@ -25,6 +25,7 @@ jobs: port: ${{ secrets.DEV_SSH_PORT }} script: | cd ~/jnu-parking/Parking-Ticket-FE + git pull origin dev pnpm install --frozen-lockfile --strict-peerp-dependencies --ignore-scripts pnpm build:apply @@ -116,6 +117,7 @@ jobs: port: ${{ secrets.DEV_SSH_PORT }} script: | cd ~/jnu-parking/Parking-Ticket-FE + git pull origin dev pnpm install --frozen-lockfile --strict-peerp-dependencies --ignore-scripts pnpm build:manager From 3e5ebb04714d8cf203e4cf57ae75b53a2b6fdc0b Mon Sep 17 00:00:00 2001 From: 2yunseong Date: Wed, 2 Oct 2024 21:50:08 +0900 Subject: [PATCH 2/6] =?UTF-8?q?fix:=20workflow=20=EC=98=A4=ED=83=80=20?= =?UTF-8?q?=EC=A0=95=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev-deploy.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/dev-deploy.yaml b/.github/workflows/dev-deploy.yaml index f0a3b0d..8839264 100644 --- a/.github/workflows/dev-deploy.yaml +++ b/.github/workflows/dev-deploy.yaml @@ -13,9 +13,9 @@ jobs: steps: - uses: actions/checkout@v3 -#################################################################################################### -# APPLY MODULE -#################################################################################################### + #################################################################################################### + # APPLY MODULE + #################################################################################################### - name: Apply 모듈 배포 스크립트 실행 uses: appleboy/ssh-action@master with: @@ -26,7 +26,7 @@ jobs: script: | cd ~/jnu-parking/Parking-Ticket-FE git pull origin dev - pnpm install --frozen-lockfile --strict-peerp-dependencies --ignore-scripts + pnpm install --frozen-lockfile --strict-peer-dependencies --ignore-scripts pnpm build:apply - name: Apply 모듈 Slack 성공 알림 @@ -105,9 +105,9 @@ jobs: env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEPLOY_WEBHOOK_URL }} -#################################################################################################### -# MANAGER MODULE -#################################################################################################### + #################################################################################################### + # MANAGER MODULE + #################################################################################################### - name: Manager 모듈 배포 스크립트 실행 uses: appleboy/ssh-action@master with: @@ -118,7 +118,7 @@ jobs: script: | cd ~/jnu-parking/Parking-Ticket-FE git pull origin dev - pnpm install --frozen-lockfile --strict-peerp-dependencies --ignore-scripts + pnpm install --frozen-lockfile --strict-peer-dependencies --ignore-scripts pnpm build:manager - name: Manager 모듈 Slack 성공 알림 From 14920d491ba9ec36aac0b814af1229b7c954989b Mon Sep 17 00:00:00 2001 From: 2yunseong Date: Sat, 19 Oct 2024 16:20:08 +0900 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=97=85=EB=A1=9C=EB=93=9C=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service-manager/src/apis/image.apis.ts | 34 +++++++++++++++++++ .../announcement/AnnouncementCreate.tsx | 26 ++++++++++++-- .../announcement/AnnouncementUpdate.tsx | 26 ++++++++++++-- 3 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 service-manager/src/apis/image.apis.ts diff --git a/service-manager/src/apis/image.apis.ts b/service-manager/src/apis/image.apis.ts new file mode 100644 index 0000000..a5450a8 --- /dev/null +++ b/service-manager/src/apis/image.apis.ts @@ -0,0 +1,34 @@ +export const getPresignedUrl = async (extension: string) => { + const response = await fetch( + new URL( + '/api/frontend-image-upload-lambda', + import.meta.env.VITE_IMAGE_UPLOAD_LAMBDA_URL, + ), + { + method: 'GET', + headers: { + 'Content-Type': `application/${extension}`, + 'x-extension': extension, + }, + mode: 'cors', + }, + ); + + const requestBody = await response.json(); + + return requestBody as { presignedUrl: string }; +}; + +export const putImageToS3 = async ( + presignedUrl: string, + file: File, + extension: string, +) => { + const response = await fetch(presignedUrl, { + method: 'PUT', + headers: { + 'Content-Type': `application/${extension}`, + }, + body: file, + }); +}; diff --git a/service-manager/src/components/announcement/AnnouncementCreate.tsx b/service-manager/src/components/announcement/AnnouncementCreate.tsx index 3b2146e..b5393fe 100644 --- a/service-manager/src/components/announcement/AnnouncementCreate.tsx +++ b/service-manager/src/components/announcement/AnnouncementCreate.tsx @@ -1,8 +1,9 @@ import { Button, InputText } from '@quokka/design-system'; import { Editor } from '@toast-ui/react-editor'; -import { useRef, lazy, Suspense, useState, useEffect } from 'react'; +import { useRef, lazy, Suspense, useState } from 'react'; import { useCreateAnnouncement } from '../../hooks/react-query/useAnnounceForm'; import ErrorBoundary from '../common/ErrorBoundary'; +import { getPresignedUrl, putImageToS3 } from '../../apis/image.apis'; const ToastEditor = lazy(() => import('@toast-ui/react-editor').then((module) => ({ @@ -33,7 +34,28 @@ export const AnnouncementCreate = () => { }; const onAddImageBlobHook = (blob: Blob, callback: (url: string) => void) => { - alert('이미지를 올릴 수 없습니다.'); + const extension = blob.name.split('.')[1]; + + getPresignedUrl(extension) + .then((res) => { + putImageToS3(res.presignedUrl, new File([blob], blob.name), extension) + .then(() => { + const url = new URL(res.presignedUrl); + const fileName = url.pathname.slice(1); + callback( + new URL(fileName, import.meta.env.VITE_IMAGE_BASE_URL).toString(), + ); + }) + .catch(() => { + alert('이미지 업로드에 실패했습니다.'); + }); + }) + .catch(() => { + alert( + '이미지 업로드를 위한 URL 발급에 실패했습니다. 파일은 <파일명.확장자> 형식으로 업로드 되어야 합니다.', + ); + }); + return; }; diff --git a/service-manager/src/components/announcement/AnnouncementUpdate.tsx b/service-manager/src/components/announcement/AnnouncementUpdate.tsx index 6b20d1f..77e9853 100644 --- a/service-manager/src/components/announcement/AnnouncementUpdate.tsx +++ b/service-manager/src/components/announcement/AnnouncementUpdate.tsx @@ -1,9 +1,10 @@ import { Button } from '@quokka/design-system'; import { Editor } from '@toast-ui/react-editor'; -import { useRef, lazy, Suspense, FormEvent, useState } from 'react'; +import { useRef, lazy, Suspense, useState } from 'react'; import { useAnnounceUpdate } from '../../hooks/react-query/useAnnounceForm'; import { useAnnounceDetailQuery } from '../../hooks/react-query/useAnnounce'; import ErrorBoundary from '../common/ErrorBoundary'; +import { getPresignedUrl, putImageToS3 } from '../../apis/image.apis'; interface AnnouncementUpdateProps { announceId: number; @@ -38,7 +39,28 @@ export const AnnouncementUpdate = ({ announceId }: AnnouncementUpdateProps) => { }; const onAddImageBlobHook = (blob: Blob, callback: (url: string) => void) => { - alert('이미지를 올릴 수 없습니다.'); + const extension = blob.name.split('.')[1]; + + getPresignedUrl(extension) + .then((res) => { + putImageToS3(res.presignedUrl, new File([blob], blob.name), extension) + .then(() => { + const url = new URL(res.presignedUrl); + const fileName = url.pathname.slice(1); + callback( + new URL(fileName, import.meta.env.VITE_IMAGE_BASE_URL).toString(), + ); + }) + .catch(() => { + alert('이미지 업로드에 실패했습니다.'); + }); + }) + .catch(() => { + alert( + '이미지 업로드를 위한 URL 발급에 실패했습니다. 파일은 <파일명.확장자> 형식으로 업로드 되어야 합니다.', + ); + }); + return; }; From f7c4a2e2fda1f44162eeebebe3b0d9e44b4a3767 Mon Sep 17 00:00:00 2001 From: 2yunseong Date: Sat, 19 Oct 2024 17:02:42 +0900 Subject: [PATCH 4/6] =?UTF-8?q?chore:=20=EB=B9=8C=EB=93=9C=EC=8A=A4?= =?UTF-8?q?=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/prod-deploy.yaml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/prod-deploy.yaml b/.github/workflows/prod-deploy.yaml index 1704eeb..86e99c7 100644 --- a/.github/workflows/prod-deploy.yaml +++ b/.github/workflows/prod-deploy.yaml @@ -6,7 +6,7 @@ on: env: ENVIRONMENT: prod - + jobs: build: runs-on: ubuntu-latest @@ -31,12 +31,13 @@ jobs: touch .env echo VITE_REACT_APP_GA_KEY=${{ secrets.VITE_REACT_APP_GA_KEY }} >> .env echo VITE_PUBLIC_API_URL=${{ secrets.VITE_PUBLIC_API_URL }} >> .env + echo VITE_IMAGE_UPLOAD_LAMBDA_URL=${{secrets.VITE_IMAGE_UPLOAD_LAMBDA_URL}} >> .env + echo VITE_IMAGE_BASE_URL=${{secrets.VITE_IMAGE_BASE_URL}} >> .env cat .env - -#################################################################################################### -# APPLY MODULE -#################################################################################################### + #################################################################################################### + # APPLY MODULE + #################################################################################################### - name: Apply 모듈 pnpm 빌드 run: | pnpm build:apply @@ -125,9 +126,9 @@ jobs: env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEPLOY_WEBHOOK_URL }} -#################################################################################################### -# MANAGER MODULE -#################################################################################################### + #################################################################################################### + # MANAGER MODULE + #################################################################################################### - name: Manager 모듈 pnpm 빌드 run: | pnpm build:manager From 907b97493bc510c75f67f24da3e32b7ba3a8af3e Mon Sep 17 00:00:00 2001 From: minbo Date: Thu, 24 Oct 2024 20:58:38 +0900 Subject: [PATCH 5/6] =?UTF-8?q?refactor:=20=EC=A4=91=EB=B3=B5=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/hooks/react-query/useNoticeForm.tsx | 30 ------------------- 1 file changed, 30 deletions(-) delete mode 100644 service-manager/src/hooks/react-query/useNoticeForm.tsx diff --git a/service-manager/src/hooks/react-query/useNoticeForm.tsx b/service-manager/src/hooks/react-query/useNoticeForm.tsx deleted file mode 100644 index d4d90af..0000000 --- a/service-manager/src/hooks/react-query/useNoticeForm.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { useNoticeMutate } from '../react-query/useNotice'; -import { useNavigate } from 'react-router-dom'; -import { useState } from 'react'; - -interface NoticeFormProps { - noticeContent: string; -} - -export const useNoticeForm = () => { - const [content] = useState(''); - const { putNotice } = useNoticeMutate(); - const navigate = useNavigate(); - - const onUpdate = ({ noticeContent: content }: NoticeFormProps) => { - putNotice( - { noticeContent: content }, - { - onError: (error) => { - alert(error.message); - }, - onSuccess: (data) => { - if (!data) throw new Error('data is undefined'); - alert('수정되었습니다.'); - navigate('/notice'); - }, - }, - ); - }; - return { content, onUpdate }; -}; From ad6f89718a5ec2fc995713e5a77bf0aad6d50f0d Mon Sep 17 00:00:00 2001 From: minbo Date: Thu, 24 Oct 2024 21:01:21 +0900 Subject: [PATCH 6/6] =?UTF-8?q?refactor:=20=EC=9D=98=EB=AF=B8=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EC=BD=94=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service-manager/src/hooks/useNoticeForm.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/service-manager/src/hooks/useNoticeForm.tsx b/service-manager/src/hooks/useNoticeForm.tsx index 2eebcdc..87b2a35 100644 --- a/service-manager/src/hooks/useNoticeForm.tsx +++ b/service-manager/src/hooks/useNoticeForm.tsx @@ -7,7 +7,6 @@ export interface NoticeFormProps { } export const useNoticeForm = () => { - const [content] = useState(''); const { putNotice } = useNoticeMutate(); const navigate = useNavigate(); @@ -26,5 +25,5 @@ export const useNoticeForm = () => { }, ); }; - return { content, onUpdate }; + return { onUpdate }; };