Skip to content

Commit

Permalink
๐Ÿ› fix: ๊ณ ์šฉ์ฃผ๊ฐ€ ํ•„์ˆ˜ ์ž…๋ ฅ ์‚ฌํ•ญ์„ ์ž…๋ ฅํ•ด์•ผ ์ œ์ถœ ๊ฐ€๋Šฅํ•˜๋„๋ก ์ˆ˜์ • #127
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMirror21 committed Jan 13, 2025
1 parent 46cdf19 commit 441e6a0
Showing 1 changed file with 66 additions and 59 deletions.
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,7 +14,11 @@ 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';

type DocumentCardProps = {
Expand Down Expand Up @@ -61,12 +70,16 @@ 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;
}) => {
Expand Down Expand Up @@ -118,60 +131,21 @@ const TemporarySaveCard = ({
/>
<Button
type="large"
bgColor="bg-[#fef387]"
bgColor={onCheck() !== null ? 'bg-[#fef387]' : 'bg-[#f4f4f9]'}
fontColor="text-[#222]"
isBorder={false}
title="์ œ์ถœ"
onClick={onNext}
onClick={() => {
if (onCheck() !== null) {
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,13 +187,17 @@ 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;
Expand Down Expand Up @@ -265,16 +243,20 @@ const RewritingCard = ({
bgColor="bg-[#f4f4f9]"
fontColor="text-[#222]"
isBorder={false}
title="์ˆ˜์ •"
title={onCheck() !== null ? '์ˆ˜์ •' : '์ž‘์„ฑ'}
onClick={onEdit}
/>
<Button
type="large"
bgColor="bg-[#fef387]"
bgColor={onCheck() !== null ? 'bg-[#fef387]' : 'bg-[#f4f4f9]'}
fontColor="text-[#222]"
isBorder={false}
title="์ œ์ถœ"
onClick={onNext}
onClick={() => {
if (onCheck() !== null) {
onSubmit();
}
}}
/>
</div>
</div>
Expand Down Expand Up @@ -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 () => {
const isEmployerWrote =
type === DocumentType.PART_TIME_PERMIT
? (await getPartTimeDocument(Number(documentInfo.id))).data
.employer_information
: (await getLaborContractDocument(Number(documentInfo.id))).data
.employer_information;
return isEmployerWrote;
};

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

0 comments on commit 441e6a0

Please sign in to comment.