Skip to content

Commit

Permalink
Merge pull request #53 from Beside-Potenday/seungbeom
Browse files Browse the repository at this point in the history
feat: 모달 수정
  • Loading branch information
seung365 authored Aug 2, 2024
2 parents 11cfda5 + 0396e4a commit 8d1f80f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/git-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
40 changes: 29 additions & 11 deletions src/components/Mail/MailModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const MailModal = ({ isOpen, onClose }: MailModalProps) => {

const handleOptionClick = (value: string) => {
setFirstInput(value);
console.log(firstInput);
};

const { mutate } = usePostUniv();
Expand Down Expand Up @@ -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);
Expand All @@ -148,13 +155,19 @@ export const MailModal = ({ isOpen, onClose }: MailModalProps) => {
};

const handleKeyDown = async (event: React.KeyboardEvent<HTMLInputElement>) => {
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;
}
};

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -256,7 +274,7 @@ export const MailModal = ({ isOpen, onClose }: MailModalProps) => {
{!isHide && (
<CustomModalFooter>
{currentIndex < inputNames.length - 1 ? (
<ArrowButton onClick={handleNextClick} />
<ArrowButton onClick={() => handleNextClick('')} />
) : (
<StyledButton onClick={handleSubmit(onSubmit)} disabled={!isValid}>
<PenIcon />
Expand Down

0 comments on commit 8d1f80f

Please sign in to comment.