Skip to content

Commit

Permalink
feat(getInitialTravelTitle): 제목 초기값에서 사용자 닉네임 삭제
Browse files Browse the repository at this point in the history
- 사용자 닉네임을 삭제하면서 훅이 아니게되어 함수이름을 useInitialTravelTitle에서 getInitialTravelTitle로 수정하고 util 폴더로 이동 시켰습니다.
  • Loading branch information
0jenn0 committed Sep 25, 2024
1 parent c666cab commit eb6278c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import TravelogueDayAccordion from "@components/pages/travelogueRegister/Travelo

import { useTravelogueDays } from "@hooks/pages/useTravelogueDays";
import { useDragScroll } from "@hooks/useDragScroll";
import useInitialTravelTitle from "@hooks/useInitialTravelTitle";
import useLeadingDebounce from "@hooks/useLeadingDebounce";
import useTagSelection from "@hooks/useTagSelection";
import useUser from "@hooks/useUser";
Expand All @@ -32,6 +31,8 @@ import { ERROR_MESSAGE_MAP } from "@constants/errorMessage";
import { FORM_VALIDATIONS_MAP } from "@constants/formValidation";
import { ROUTE_PATHS_MAP } from "@constants/route";

import getInitialTravelTitle from "@utils/getInitialTravelTitle";

import * as S from "./TravelogueRegisterPage.styled";

const TravelogueRegisterPage = () => {
Expand Down Expand Up @@ -66,7 +67,7 @@ const TravelogueRegisterPage = () => {
onDeleteImageUrls,
} = useTravelogueDays(transformDetail?.days ?? []);

const initialTitle = useInitialTravelTitle({ days: transformDetail?.days, type: "travelogue" });
const initialTitle = getInitialTravelTitle({ days: transformDetail?.days, type: "travelogue" });

const [title, setTitle] = useState(initialTitle);

Expand Down
5 changes: 3 additions & 2 deletions frontend/src/hooks/pages/useTravelPlanForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { useState } from "react";
import { TravelTransformPlaces } from "@type/domain/travelTransform";

import { useTravelPlanDays } from "@hooks/pages/useTravelPlanDays";
import useInitialTravelTitle from "@hooks/useInitialTravelTitle";

import { FORM_VALIDATIONS_MAP } from "@constants/formValidation";

import getInitialTravelTitle from "@utils/getInitialTravelTitle";

const useTravelPlanForm = (transformDays: TravelTransformPlaces[]) => {
const [startDate, setStartDate] = useState<Date | null>(null);

Expand All @@ -26,7 +27,7 @@ const useTravelPlanForm = (transformDays: TravelTransformPlaces[]) => {
onChangeContent,
} = useTravelPlanDays(transformDays);

const initialTitle = useInitialTravelTitle({ days: travelPlanDays, type: "travelPlan" });
const initialTitle = getInitialTravelTitle({ days: travelPlanDays, type: "travelPlan" });

const [title, setTitle] = useState(initialTitle);

Expand Down
30 changes: 0 additions & 30 deletions frontend/src/hooks/useInitialTravelTitle.ts

This file was deleted.

21 changes: 21 additions & 0 deletions frontend/src/utils/getInitialTravelTitle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { TravelTransformPlaces } from "@type/domain/travelTransform";

import getDaysAndNights from "@utils/getDaysAndNights";

type TravelRecordType = "travelogue" | "travelPlan";

interface getInitialTravelTitleProps {
days: TravelTransformPlaces[] | undefined;
type: TravelRecordType;
}

const getInitialTravelTitle = ({ days, type }: getInitialTravelTitleProps) => {
const daysAndNights = getDaysAndNights(days);

const tripType = type === "travelogue" ? "여행기" : "여행 계획";

if (days && days?.length >= 1) return `${daysAndNights} ${tripType}`;
return "";
};

export default getInitialTravelTitle;

0 comments on commit eb6278c

Please sign in to comment.