diff --git a/.github/workflows/git-push.yml b/.github/workflows/git-push.yml index 4b6bab3..a54e90b 100644 --- a/.github/workflows/git-push.yml +++ b/.github/workflows/git-push.yml @@ -14,17 +14,24 @@ jobs: run: apk add ruby && gem install mustache - name: creates output run: sh ./build.sh + + - name: Get commit message + id: get_commit_message + run: echo "::set-output name=commit_message::$(git log --format=%B -n 1 ${{ github.sha }})" + - name: Pushes to another repository id: push_directory uses: cpina/github-action-push-to-another-repository@main env: API_TOKEN_GITHUB: ${{ secrets.AUTO_KEY }} + COMMIT_MESSAGE: ${{ steps.get_commit_message.outputs.commit_message }} with: source-directory: 'output' destination-github-username: 'seung365' destination-repository-name: 'alphamail-frontend' user-email: ${{ secrets.OFFICIAL_ACCOUNT_EMAIL}} - commit-message: ${{ github.event.commits[0].message }} + commit-message: ${{ env.COMMIT_MESSAGE }} target-branch: main + - name: Test get variable exported by push-to-another-repository run: echo $DESTINATION_CLONED_DIRECTORY diff --git a/src/components/Mail/MailModal.tsx b/src/components/Mail/MailModal.tsx index 5fad899..e7e28e9 100644 --- a/src/components/Mail/MailModal.tsx +++ b/src/components/Mail/MailModal.tsx @@ -89,6 +89,7 @@ export const MailModal = ({ isOpen, onClose }: MailModalProps) => { const handleOptionClick = (value: string) => { setFirstInput(value); + console.log(firstInput); }; const { mutate } = usePostUniv(); @@ -130,8 +131,14 @@ export const MailModal = ({ isOpen, onClose }: MailModalProps) => { setIsHide(!isHide); }; - const handleNextClick = async () => { + const handleNextClick = async (inputValue: string) => { const isValid = await trigger(inputNames[currentIndex]); + console.log('fuck'); + + if (currentIndex === 0 && firstInput && !inputValue) { + setValue(inputNames[currentIndex], firstInput, { shouldValidate: true }); + } + if (isValid) { if (currentIndex < inputNames.length - 1) { setCurrentIndex(currentIndex + 1); @@ -148,13 +155,19 @@ export const MailModal = ({ isOpen, onClose }: MailModalProps) => { }; const handleKeyDown = async (event: React.KeyboardEvent) => { - if (event.key === 'Enter' && content) { - event.preventDefault(); + if (event.key === 'Enter' && event.nativeEvent.isComposing === false) { const inputValue = (event.target as HTMLInputElement).value; - const combinedValue = `${firstInput} ${inputValue}`.trim(); - await setValue(inputNames[currentIndex], combinedValue, { shouldValidate: true }); - console.log(combinedValue); - await handleNextClick(); + if (currentIndex === 0 && firstInput) { + event.preventDefault(); + const combinedValue = `${firstInput} : ${inputValue}`.trim(); + await setValue(inputNames[currentIndex], combinedValue, { shouldValidate: true }); + console.log(combinedValue); + } else { + await setValue(inputNames[currentIndex], inputValue, { shouldValidate: true }); + console.log(inputValue); + } + await handleNextClick(inputValue); + return; } }; @@ -216,11 +229,16 @@ export const MailModal = ({ isOpen, onClose }: MailModalProps) => { name={inputNames[currentIndex]} control={control} rules={{ - required: currentIndex === 0 ? '필수 입력 항목입니다.' : false, validate: (value) => { - if (currentIndex === 0 && (value.length < 5 || value.length > 300)) { - return warningTexts.content[1]; + if (currentIndex === 0) { + if (!value && !firstInput) { + return warningTexts.content[0]; + } + if (value.length < 5 || value.length > 300) { + return warningTexts.content[1]; + } } + if (currentIndex === 3 && (!/^\d+$/.test(value) || '')) { return warningTexts.studentId; } @@ -256,7 +274,7 @@ export const MailModal = ({ isOpen, onClose }: MailModalProps) => { {!isHide && ( {currentIndex < inputNames.length - 1 ? ( - + handleNextClick('')} /> ) : (