Skip to content

Commit

Permalink
Merge pull request #156 from Team-inglo/fix/IGW-64/127-고용주필수입력사항적용
Browse files Browse the repository at this point in the history
Fix/igw 64/127 고용주필수입력사항적용
  • Loading branch information
MrMirror21 authored Jan 20, 2025
2 parents f7ae9a2 + 0ee5d46 commit 17911e8
Show file tree
Hide file tree
Showing 13 changed files with 144 additions and 132 deletions.
18 changes: 16 additions & 2 deletions src/components/Common/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type InputProps = {
placeholder: string; // 플레이스홀더 텍스트
value: string | null; // 입력 필드의 현재 값
onChange: (value: string) => void; // 입력값 변경 시 호출될 함수
onBlur?: (value: string) => boolean; // 입력 필드에서 포커스가 빠져나갈 때 호출될 함수 (선택적)
canDelete: boolean; // 삭제 버튼 표시 여부
clearInvalid?: () => void; // 토글 시 invalid 상태를 해제할 함수 (선택적)
isInvalid?: boolean; // 유효하지 않은 입력 상태 여부 (선택적)
Expand Down Expand Up @@ -45,6 +46,7 @@ const Input = ({
inputType,
placeholder,
onChange,
onBlur,
canDelete,
onDelete,
clearInvalid,
Expand Down Expand Up @@ -83,6 +85,14 @@ const Input = ({
setCurrentStatus(INPUT_STATUS.DISABLED);
};

const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {
if (onBlur && onBlur(e.target.value) === true) {
setCurrentStatus(INPUT_STATUS.INVALID);
return;
}
setCurrentStatus(INPUT_STATUS.DISABLED);
};

return (
<div
className={`w-full flex gap-2 whitespace-nowrap items-center justify-between text-left body-2 border rounded-xl ${inputStyler(currentStatus)} bg-white py-[10px] pl-4 pr-[14px]`}
Expand All @@ -96,7 +106,7 @@ const Input = ({
value={value ?? ''}
className={'w-full outline-none placeholder:text-[var(--input-color)]'}
onClick={() => handleFocus('click')}
onBlur={() => handleFocus('blur')}
onBlur={handleBlur}
onChange={handleInputChange}
type={
inputType === 'PASSWORD'
Expand All @@ -114,7 +124,11 @@ const Input = ({
{/* 입력값 삭제 가능한 경우 삭제 아이콘을 표시합니다. */}
{canDelete && <CloseIcon onClick={onDelete} />}
{/* 단위가 존재할 경우 표시합니다. */}
{isUnit && <div className="text-right w-full body-2 text-[#464646]"><div className='w-full'>{unit}</div></div>}
{isUnit && (
<div className="text-right w-full body-2 text-[#464646]">
<div className="w-full">{unit}</div>
</div>
)}
</div>
);
};
Expand Down
17 changes: 1 addition & 16 deletions src/components/Document/DocumentCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ const ConfirmationCard = ({
<div className="relative head-3">{title}</div>
</div>
<div className="overflow-hidden flex items-center justify-center p-2">
{!documentInfo.hwp_url && !documentInfo.word_url ? (
{!documentInfo.word_url ? (
<WriteIcon />
) : (
<CheckIconGreen />
Expand Down Expand Up @@ -322,21 +322,6 @@ const ConfirmationCard = ({
</div>
</div>
)}
{documentInfo.hwp_url && (
<div className="w-full rounded-3xl bg-[#f4f4f9] flex items-center justify-between border border-[#dcdcdc] px-4 py-2 pl-2.5">
<div className="flex items-center justify-start gap-2">
<div className="w-[1.375rem] h-[1.375rem] flex items-center justify-center rounded-full bg-[#1e1926]">
<FolderIcon />
</div>
<div className="relative body-3 opacity-75">
smth file download
</div>
</div>
<div onClick={() => onDownload(documentInfo.hwp_url as string)}>
<DownloadIcon />
</div>
</div>
)}
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const IntegratedApplicationPreview = ({
</div>
</div>
</InputLayout>
{/* 사업등록번호 입력 */}
{/* 사업자 등록번호 입력 */}
<InputLayout
title="Business Registration No. Of New Workplace"
isEssential
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { EmployDocumentInfo } from '@/types/api/document';
import {
DocumentType,
EmployDocumentInfo,
EmployerInformation,
LaborContractEmployerInfo,
} from '@/types/api/document';
import Button from '@/components/Common/Button';
import ArrowrightIcon from '@/assets/icons/Chevron.svg?react';
import TalkBallonIcon from '@/assets/icons/TalkBalloon.svg?react';
Expand All @@ -9,8 +14,13 @@ import CheckIconGreen from '@/assets/icons/CheckIconGreen.svg?react';
import WriteIcon from '@/assets/icons/WriteIcon.svg?react';
import { useNavigate } from 'react-router-dom';
import { DocumentStatusEmployer } from '@/constants/documents';
import { usePatchStatusSubmissionEmployer } from '@/hooks/api/useDocument';
import {
useGetPartTimeEmployPermit,
useGetStandardLaborContract,
usePatchStatusSubmissionEmployer,
} from '@/hooks/api/useDocument';
import { useCurrentDocumentIdStore } from '@/store/url';
import { useEffect, useState } from 'react';

type DocumentCardProps = {
documentInfo: EmployDocumentInfo;
Expand Down Expand Up @@ -61,15 +71,27 @@ const NullCard = ({ title }: { title: string }) => {

const TemporarySaveCard = ({
title,
onNext,
onCheck,
onSubmit,
onEdit,
onPreview,
}: {
title: string;
onNext: () => void;
onCheck: () => Promise<
EmployerInformation | LaborContractEmployerInfo | null
>;
onSubmit: () => void;
onEdit: () => void;
onPreview: () => void;
}) => {
const [isEmployerWrote, setIsEmployerWrote] = useState<boolean | null>(null);
useEffect(() => {
const checkDocuments = async () => {
const result = await onCheck();
setIsEmployerWrote(result !== null);
};
checkDocuments();
}, []);
return (
<div className="w-full relative rounded-[1.125rem] bg-white border border-[#dcdcdc] flex flex-col items-center justify-center gap-2 caption-2 text-left text-[#1e1926]">
<div className="self-stretch rounded-t-[1.125rem] bg-[#fef387] h-7 flex items-center justify-between px-4 pl-6 py-2 relative">
Expand Down Expand Up @@ -110,68 +132,29 @@ const TemporarySaveCard = ({
<div className="flex self-stretch items-center justify-center p-4 gap-1 text-[#464646]">
<Button
type="large"
bgColor="bg-[#f4f4f9]"
bgColor={isEmployerWrote ? 'bg-[#f4f4f9]' : 'bg-[#fef387]'}
fontColor="text-[#222]"
isBorder={false}
title="수정"
title={isEmployerWrote ? '수정' : '작성'}
onClick={onEdit}
/>
<Button
type="large"
bgColor="bg-[#fef387]"
bgColor={isEmployerWrote ? 'bg-[#fef387]' : 'bg-[#f4f4f9]'}
fontColor="text-[#222]"
isBorder={false}
title="제출"
onClick={onNext}
onClick={() => {
if (isEmployerWrote) {
onSubmit();
}
}}
/>
</div>
</div>
);
};

{
/*
const BeforeConfirmationCard = ({ title }: { title: string }) => {
return (
<div className="w-full relative rounded-[1.125rem] bg-white border border-[#dcdcdc] flex flex-col items-center justify-center gap-2 caption-2 text-left text-[#1e1926]">
<div className="self-stretch rounded-t-[1.125rem] bg-[#1e1926] h-7 flex items-center justify-between px-4 pl-6 py-2 relative">
<div className="flex items-center justify-start relative text-[#f4f4f9]">
대기 ...
</div>
</div>
<div className="self-stretch flex flex-col items-start px-4 gap-4 body-1">
<div className="self-stretch border-b border-[#dcdcdc] h-10 flex items-center justify-center pl-2 pb-2 gap-4">
<div className="flex-1 flex items-center justify-start">
<div className="relative head-3">{title}</div>
</div>
<div className="overflow-hidden flex items-center justify-center p-2">
<TalkBallonIcon />
</div>
</div>
<div className="self-stretch flex items-center justify-center px-3 text-[#656565] caption-1">
<div className="flex-1 relative">
<p className="m-0">유학생이 서류를 검토 중이에요.</p>
</div>
</div>
</div>
<div className="flex flex-col w-full items-start justify-start py-2 px-4 text-[#464646]">
<div className="w-full rounded-3xl bg-[#f4f4f9] flex items-center justify-start border border-[#dcdcdc] px-4 py-2 pl-2.5">
<div className="flex items-center justify-start gap-2">
<div className="w-[1.375rem] h-[1.375rem] flex items-center justify-center rounded-full bg-[#1e1926]">
<TalkBallonIconGrey />
</div>
<div className="relative body-3 opacity-75">검토 중 ...</div>
</div>
</div>
</div>
</div>
);
};
*/
}

const SubmittedCard = ({ title }: { title: string }) => {
return (
<div className="w-full relative rounded-[1.125rem] bg-white border border-[#dcdcdc] flex flex-col items-center justify-center gap-2 caption-2 text-left text-[#1e1926]">
Expand Down Expand Up @@ -213,17 +196,29 @@ const SubmittedCard = ({ title }: { title: string }) => {

const RewritingCard = ({
title,
onNext,
onCheck,
onSubmit,
onEdit,
onPreview,
reason,
}: {
title: string;
onNext: () => void;
onCheck: () => Promise<
EmployerInformation | LaborContractEmployerInfo | null
>;
onSubmit: () => void;
onEdit: () => void;
onPreview: () => void;
reason: string;
}) => {
const [isEmployerWrote, setIsEmployerWrote] = useState<boolean | null>(null);
useEffect(() => {
const checkDocuments = async () => {
const result = await onCheck();
setIsEmployerWrote(result !== null);
};
checkDocuments();
}, []);
return (
<div className="w-full relative rounded-[1.125rem] bg-white border border-[#dcdcdc] flex flex-col items-center justify-center gap-2 caption-2 text-left text-[#1e1926]">
<div className="self-stretch rounded-t-[1.125rem] bg-[#fef387] h-7 flex items-center justify-between px-4 pl-6 py-2 relative">
Expand Down Expand Up @@ -262,19 +257,23 @@ const RewritingCard = ({
<div className="flex self-stretch items-center justify-center p-4 gap-1 text-[#464646]">
<Button
type="large"
bgColor="bg-[#f4f4f9]"
bgColor={isEmployerWrote ? 'bg-[#f4f4f9]' : 'bg-[#fef387]'}
fontColor="text-[#222]"
isBorder={false}
title="수정"
title={isEmployerWrote ? '수정' : '작성'}
onClick={onEdit}
/>
<Button
type="large"
bgColor="bg-[#fef387]"
bgColor={isEmployerWrote ? 'bg-[#fef387]' : 'bg-[#f4f4f9]'}
fontColor="text-[#222]"
isBorder={false}
title="제출"
onClick={onNext}
onClick={() => {
if (isEmployerWrote) {
onSubmit();
}
}}
/>
</div>
</div>
Expand Down Expand Up @@ -304,11 +303,7 @@ const ConfirmationCard = ({
<div className="relative head-3">{title}</div>
</div>
<div className="overflow-hidden flex items-center justify-center p-2">
{!documentInfo.hwp_url && !documentInfo.word_url ? (
<WriteIcon />
) : (
<CheckIconGreen />
)}
{!documentInfo.word_url ? <WriteIcon /> : <CheckIconGreen />}
</div>
</div>

Expand All @@ -335,19 +330,6 @@ const ConfirmationCard = ({
</div>
</div>
)}
{documentInfo.hwp_url && (
<div className="w-full rounded-3xl bg-[#f4f4f9] flex items-center justify-between border border-[#dcdcdc] px-4 py-2 pl-2.5">
<div className="flex items-center justify-start gap-2">
<div className="w-[1.375rem] h-[1.375rem] flex items-center justify-center rounded-full bg-[#1e1926]">
<FolderIcon />
</div>
<div className="relative body-3 opacity-75">hwp로 다운로드</div>
</div>
<div onClick={() => onDownload(documentInfo.hwp_url as string)}>
<DownloadIcon />
</div>
</div>
)}
</div>
</div>
);
Expand All @@ -364,14 +346,13 @@ const DocumentCardDispenserEmployer = ({
const handleDownload = (url: string) => {
// 웹뷰 환경인지 체크
const isWebView = Boolean(window.ReactNativeWebView);

if (isWebView) {
// 웹뷰에서는 DocumentViewer로 이동
navigate('/document-view/123', {
state: {
url,
filename: url.split('/').pop() // URL에서 파일명 추출
}
filename: url.split('/').pop(), // URL에서 파일명 추출
},
});
} else {
// 웹 환경에서는 직접 다운로드
Expand All @@ -393,16 +374,41 @@ const DocumentCardDispenserEmployer = ({
setIsLoading(false);
},
});
const { mutateAsync: getPartTimeDocument } = useGetPartTimeEmployPermit({
onSuccess: (data) => {
return data.data.employer_information;
},
});
const { mutateAsync: getLaborContractDocument } = useGetStandardLaborContract(
{
onSuccess: (data) => {
return data.data.employer_information;
},
},
);

const checkEmployerWriteDocuments = async () => {
if (type === DocumentType.PART_TIME_PERMIT) {
const result = await getPartTimeDocument(documentInfo.id);
return result?.data.employer_information || null;
} else {
const result = await getLaborContractDocument(documentInfo.id);
return result?.data.employer_information || null;
}
};

if (!documentInfo.status) return <NullCard title={title} />;
switch (documentInfo.status) {
case DocumentStatusEmployer.TEMPORARY_SAVE:
return (
<TemporarySaveCard
title={title}
onNext={() => submitDocument(Number(documentInfo.id))} // 고용주가 서류 제출
onCheck={checkEmployerWriteDocuments}
onSubmit={() => submitDocument(Number(documentInfo.id))} // 고용주가 서류 제출
onEdit={() => {
updateCurrentDocumentId(documentInfo.id);
navigate(`/employer/write-documents/${documentInfo.id}`, {
// EmployerWriteDocumentPage.tsx
state: {
type: type,
isEdit: true,
Expand All @@ -427,7 +433,8 @@ const DocumentCardDispenserEmployer = ({
<RewritingCard
title={title}
reason={reason}
onNext={() => submitDocument(Number(documentInfo.id))} // 고용주가 서류 제출
onCheck={checkEmployerWriteDocuments}
onSubmit={() => submitDocument(Number(documentInfo.id))} // 고용주가 서류 제출
onEdit={() => {
updateCurrentDocumentId(documentInfo.id);
navigate(`/employer/write-documents/${documentInfo.id}`, {
Expand Down
Loading

0 comments on commit 17911e8

Please sign in to comment.