Skip to content

Commit

Permalink
feat: 구인글 등록 페이지 확인 모달 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
YIMSEBIN committed Nov 14, 2024
1 parent 65cf440 commit 208d719
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/assets/translator/PostNotice/postNoticeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const postNoticeData = {
ELIGIBILITY_CRITERIA: '비자 자격 요건을 입력해주세요.',
PREFERRED_CONDITIONS: '우대사항을 입력해주세요.',
},
SUBMIT_CHECK: '구인글을 등록하시겠습니까?',
SUBMIT: '등록하기',
},
[Languages.VE]: {
Expand Down Expand Up @@ -67,6 +68,7 @@ export const postNoticeData = {
ELIGIBILITY_CRITERIA: 'Vui lòng nhập yêu cầu về điều kiện visa.',
PREFERRED_CONDITIONS: 'Vui lòng nhập điều kiện ưu tiên.',
},
SUBMIT_CHECK: 'Bạn có muốn đăng bài tuyển dụng không?',
SUBMIT: 'Đăng ký',
},
};
33 changes: 28 additions & 5 deletions src/features/postNotice/components/PostNoticeForm.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { usePostNotice } from '@/apis/postNotice/hooks/usePostNotice';
import { Button, Input } from '@/components/common';
import { Button, Input, Modal } from '@/components/common';
import useToggle from '@/hooks/useToggle';
import ROUTE_PATH from '@/routes/path';
import { NoticeRequestData } from '@/types';
import styled from '@emotion/styled';
Expand Down Expand Up @@ -33,6 +34,8 @@ export default function PostNoticeForm() {

const [inputs, setInputs] = useState({ ...default_inputs });
const [errors, setErrors] = useState<{ [key: string]: string }>({});
const [isToggle, toggle] = useToggle();
inputs.companyId = Number(curCompanyId);

const {
title,
Expand Down Expand Up @@ -74,7 +77,7 @@ export default function PostNoticeForm() {
});
};

const handlePostNotice = () => {
const onClickSubmitButton = () => {
const newErrors: { [key: string]: string } = {};

if (!title) newErrors.title = t('postNotice.ERROR.NOTICE_TITLE');
Expand All @@ -94,9 +97,10 @@ export default function PostNoticeForm() {

setErrors(newErrors);
if (Object.keys(newErrors).length > 0) return;
toggle();
};

inputs.companyId = Number(curCompanyId);

const onPostNotice = () => {
mutation.mutate(inputs, {
onSuccess: () => {
navigate(ROUTE_PATH.HOME);
Expand Down Expand Up @@ -264,9 +268,16 @@ export default function PostNoticeForm() {
/>
{errors.preferredConditions && <ErrorText>{errors.preferredConditions}</ErrorText>}
</InputContainer>
<Button onClick={handlePostNotice} design="default" style={{ marginTop: '52px' }}>
<Button onClick={onClickSubmitButton} design="default" style={{ marginTop: '52px' }}>
{t('postNotice.SUBMIT')}
</Button>
{isToggle && (
<Modal
textChildren={<ModalContainer>{t('postNotice.SUBMIT_CHECK')}</ModalContainer>}
buttonChildren={<CustomBtn onClick={onPostNotice}>{t('postNotice.SUBMIT')}</CustomBtn>}
onClose={toggle}
/>
)}
</>
);
}
Expand All @@ -288,3 +299,15 @@ const ErrorText = styled.span`
font-size: 12px;
margin-top: 5px;
`;

const CustomBtn = styled(Button)`
background: #0a65cc;
color: white;
border: 1px solid #e4e5e8;
align-self: center;
`;

const ModalContainer = styled.div`
font-size: 24px;
margin: 30px 30px;
`;

0 comments on commit 208d719

Please sign in to comment.