Skip to content

Commit

Permalink
๐Ÿ› fix: Step Indicator ๋ณ€๊ฒฝ์œผ๋กœ ์ธํ•œ ๊ณต๊ณ  ๋“ฑ๋ก/์ˆ˜์ • step indicator ๋””์ž์ธ ๊นจ์ง ์ •์ƒํ™” Teamโ€ฆ
Browse files Browse the repository at this point in the history
  • Loading branch information
naarang committed Jan 24, 2025
1 parent b548748 commit 4559b0d
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/components/Employer/PostCreate/Step2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const Step2 = ({
handleAddressSearch, // ๊ฒ€์ƒ‰ํ•  ์ฃผ์†Œ ์ž…๋ ฅ ์‹œ ์‹ค์‹œ๊ฐ„ ๊ฒ€์ƒ‰
handleAddressSelect, // ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ ์ค‘ ์›ํ•˜๋Š” ์ฃผ์†Œ๋ฅผ ์„ ํƒํ•  ์‹œ state์— ์ž…๋ ฅ
setAddressInput,
} = useAddressSearch();
} = useAddressSearch(postInfo.body.address);

const handleAddressSelection = (selectedAddressName: string) => {
const result = handleAddressSelect(selectedAddressName);
Expand Down
22 changes: 15 additions & 7 deletions src/components/Employer/PostCreate/Step4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import InputLayout from '@/components/WorkExperience/InputLayout';
import { buttonTypeKeys } from '@/constants/components';
import { phone } from '@/constants/information';
import { InputType } from '@/types/common/input';
import { Image, JobPostingForm } from '@/types/postCreate/postCreate';
import type { Image, JobPostingForm } from '@/types/postCreate/postCreate';
import { useEffect, useState } from 'react';
import AddFileIcon from '@/assets/icons/FileAddIcon.svg?react';
import {
Expand All @@ -29,11 +29,16 @@ const Step4 = ({
}) => {
// ํ˜„์žฌ step๋‚ด์—์„œ ์ž…๋ ฅ๋ฐ›๋Š” ์ •๋ณด๋ฅผ ๋”ฐ๋กœ ๊ด€๋ฆฌํ•  state, ์ถ”ํ›„ ๋‹ค์Œ step์œผ๋กœ ๋„˜์–ด๊ฐˆ ๋•Œ funnel ๊ด€๋ฆฌ ํŽ˜์ด์ง€์˜ state๋กœ ํ†ตํ•ฉ๋œ๋‹ค.
const [newPostInfo, setNewPostInfo] = useState<JobPostingForm>({
images: [],
images: postInfo.images.filter(
(image): image is File => image instanceof File,
),
body: { ...postInfo.body },
});
const [storedImageUrls, setStoredImageUrls] = useState<Image[]>(
isEdit ? (postInfo.images as Image[]) : [],
// ์ด๋ฏธ์ง€ ์ˆ˜์ • ์‹œ ๊ธฐ์กด ์ด๋ฏธ์ง€๋ฅผ ๋ถˆ๋Ÿฌ์™€ ์ €์žฅ (id, img_url์ด ์žˆ๋Š” ๊ฒฝ์šฐ ๊ธฐ์กด ์ด๋ฏธ์ง€)
isEdit
? postInfo.images.filter((image) => 'id' in image && 'img_url' in image)
: [],
);
// ์„ธ ๋ถ€๋ถ„์œผ๋กœ ๋‚˜๋ˆ„์–ด ์ž…๋ ฅ๋ฐ›๋Š” ๋ฐฉ์‹์„ ์œ„ํ•ด ์ „ํ™”๋ฒˆํ˜ธ๋งŒ ๋ณ„๋„์˜ state๋กœ ๋ถ„๋ฆฌ, ์ถ”ํ›„ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ ๋‹จ์—์„œ ํ†ตํ•ฉ
const [phoneNum, setPhoneNum] = useState({
Expand All @@ -56,10 +61,11 @@ const Step4 = ({
const { recruiter_name, recruiter_email } = newPostInfo.body;

const isFormValid =
recruiter_name !== '' &&
basicEmailRegex.test(recruiter_email) &&
isValidPhoneNumber(phoneNum) &&
newPostInfo.images.length > 0 || storedImageUrls.length > 0;
(recruiter_name !== '' &&
basicEmailRegex.test(recruiter_email) &&
isValidPhoneNumber(phoneNum) &&
newPostInfo.images.length > 0) ||
storedImageUrls.length > 0;
setIsInvalid(!isFormValid);
}, [newPostInfo, phoneNum]);

Expand Down Expand Up @@ -153,6 +159,7 @@ const Step4 = ({
/>
</label>
)}
{/* ๊ธฐ์กด ์ด๋ฏธ์ง€๋“ค(cdn ๋งํฌ๋ฅผ ๋ฐ˜ํ™˜ ๋ฐ›์œผ๋ฏ€๋กœ ์‹ ๊ทœ๋กœ ์ถ”๊ฐ€ํ•œ ์ด๋ฏธ์ง€์™€ ๋ถ„๋ฆฌํ•ด ์ฒ˜๋ฆฌ) */}
{storedImageUrls[0] &&
storedImageUrls.map((image, idx) => (
<div className="w-[7.5rem] h-[7.5rem] relative rounded-lg flex flex-row items-center justify-center bg-no-repeat bg-top text-left text-gray-400">
Expand Down Expand Up @@ -239,6 +246,7 @@ const Step4 = ({
...newPostInfo.body,
recruiter_phone_number: formatPhoneNumber(phoneNum),
},
images: [...newPostInfo.images, ...storedImageUrls],
})
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,12 @@ const EmployerLaborContractForm = ({
setAddressInput,
} = useAddressSearch();

const [isLoading, setIsLoading] = useState(false);
const [isInvalid, setIsInvalid] = useState(false);
// ๊ทผ๋ฌด์‹œ๊ฐ„, ์š”์ผ ์„ ํƒ ๋ชจ๋‹ฌ ํ™œ์„ฑํ™” ํ”Œ๋ž˜๊ทธ
const [isModal, setIsModal] = useState(false);
// ์ž…๋ ฅ ์™„๋ฃŒ ์‹œ ์ œ์ถœ
const { mutate: putDocument } = usePutLaborContractEmployer(
const { mutate: putDocument, isPending } = usePutLaborContractEmployer(
Number(currentDocumentId),
{
onMutate: () => {
setIsLoading(true);
},
onSettled: () => {
setIsLoading(false);
},
},
);
useEffect(() => {
if (isEdit && document?.employer_information) {
Expand Down Expand Up @@ -162,7 +153,7 @@ const EmployerLaborContractForm = ({

return (
<>
{isLoading && (
{isPending && (
<div
className="fixed inset-0 z-50 flex items-center justify-center bg-white bg-opacity-50 overflow-hidden"
style={{ touchAction: 'none' }}
Expand All @@ -172,7 +163,7 @@ const EmployerLaborContractForm = ({
</div>
)}
<div
className={`w-full p-6 flex flex-col ${isLoading ? 'overflow-hidden pointer-events-none' : ''}`}
className={`w-full p-6 flex flex-col ${isPending ? 'overflow-hidden pointer-events-none' : ''}`}
>
<div className="[&>*:last-child]:mb-40 flex flex-col gap-4">
{/* ํšŒ์‚ฌ/์ ํฌ๋ช… ์ž…๋ ฅ */}
Expand Down
13 changes: 9 additions & 4 deletions src/hooks/api/useAddressSearch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useSearchAddress } from '@/hooks/api/useKaKaoMap';
import { Document, AddressType, GeoPosition } from '@/types/api/map';
import { Address } from '@/types/postCreate/postCreate';
import { pick } from '@/utils/map';
import { Dispatch, SetStateAction, useCallback, useState } from 'react';

Expand Down Expand Up @@ -27,14 +28,18 @@ interface UseAddressSearchReturn {
setCurrentGeoInfo: Dispatch<SetStateAction<GeoPosition>>;
}

export const useAddressSearch = (): UseAddressSearchReturn => {
const [addressInput, setAddressInput] = useState('');
export const useAddressSearch = (
addressBeforeEdit?: Address,
): UseAddressSearchReturn => {
const [addressInput, setAddressInput] = useState(
addressBeforeEdit?.address_name || '',
);
const [addressSearchResult, setAddressSearchResult] = useState<Document[]>(
[],
);
const [currentGeoInfo, setCurrentGeoInfo] = useState({
lat: 0,
lon: 0,
lat: addressBeforeEdit?.latitude || 0,
lon: addressBeforeEdit?.longitude || 0,
});

const { searchAddress } = useSearchAddress({
Expand Down
1 change: 1 addition & 0 deletions src/pages/Employer/Post/EmployerCreatePostPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const EmployerCreatePostPage = () => {
length={5}
currentStep={currentStep}
mainColor="#1E1926"
textColor='#FFFFFF'
/>
</div>
<div className="w-full flex justify-center px-6">
Expand Down
16 changes: 12 additions & 4 deletions src/pages/Employer/Post/EmployerEditPostPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const EmployerEditPostPage = () => {
const { isEdit } = location.state || {};
const { id } = useParams();
const { currentPostId } = useCurrentPostIdStore();
console.log(currentPostId)
console.log(currentPostId);
const [currentStep, setCurrentStep] = useState(1);
const [postInfo, setPostInfo] = useState<JobPostingForm>(
initialJobPostingState,
Expand Down Expand Up @@ -56,8 +56,15 @@ const EmployerEditPostPage = () => {
work_period: serverData.working_conditions.work_period,
hourly_rate: serverData.working_conditions.hourly_rate,
employment_type: serverData.working_conditions.employment_type,
address: {...postInfo.body.address, address_name: serverData.company_information.company_address},
recruitment_dead_line: serverData.recruitment_conditions.recruitment_deadline,
address: {
...postInfo.body.address,
address_name: serverData.workplace_information.main_address,
latitude: serverData.workplace_information.latitude,
longitude: serverData.workplace_information.longitude,
address_detail: serverData.workplace_information.detailed_address,
},
recruitment_dead_line:
serverData.recruitment_conditions.recruitment_deadline,
recruitment_number: serverData.recruitment_conditions.number_of_recruits,
gender: serverData.recruitment_conditions.gender,
age_restriction: initialJobPostingState.body.age_restriction,
Expand Down Expand Up @@ -90,7 +97,7 @@ const EmployerEditPostPage = () => {
hasBackButton
onClickBackButton={() => navigate(-1)}
hasMenuButton={false}
title="๊ณต๊ณ ๋“ฑ๋ก"
title="๊ณต๊ณ ์ˆ˜์ •"
/>
{devIsModal ? (
<CompleteModal
Expand All @@ -107,6 +114,7 @@ const EmployerEditPostPage = () => {
length={5}
currentStep={currentStep}
mainColor="#1E1926"
textColor="#FFFFFF"
/>
</div>
<div className="w-full flex justify-center px-6">
Expand Down
2 changes: 1 addition & 1 deletion src/types/postCreate/postCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export type Image = {
}

export type JobPostingForm = {
images: File[] | Image[];
images: (File | Image)[];
body: {
title: string;
job_category: JobCategory | string;
Expand Down

0 comments on commit 4559b0d

Please sign in to comment.