Skip to content

Commit

Permalink
Merge pull request #333 from TripInfoWeb/dev_informations
Browse files Browse the repository at this point in the history
Feat: 정보/모임 세종특별자치시 표시 기능
  • Loading branch information
HyunJinNo authored Sep 20, 2024
2 parents f76304a + d886f43 commit 96e1000
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 28 deletions.
6 changes: 4 additions & 2 deletions src/components/common/GatheringItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const GatheringItem = ({ data }: IGatheringItem) => {
return (
<Link
href={`/gathering/${data.gatheringId}`}
className={`flex w-full ${data.isFinish || format(new Date(data.deadline), "yyyyMMdd") < format(new Date(), "yyyyMMdd") ? "text-gray2" : "text-black"} h-full max-h-[19.6875rem] flex-col gap-[1.25rem] rounded-2xl border-0 p-5 outline outline-2 outline-offset-[-2px] outline-gray3 hover:outline-main max-[744px]:max-w-[28.75rem]`}
className={`flex w-full ${data.isFinish || format(new Date(data.deadline), "yyyyMMdd") < format(new Date(), "yyyyMMdd") ? "text-gray2" : "text-black"} h-full max-h-[19.6875rem] flex-col gap-[1.25rem] rounded-2xl border-0 p-5 outline outline-2 outline-offset-[-2px] outline-gray3 duration-300 hover:bg-[#F2FAF7] hover:outline-main max-[744px]:max-w-[28.75rem]`}
>
<div className="flex flex-col">
{/* 상태와 북마크 */}
Expand Down Expand Up @@ -102,7 +102,9 @@ const GatheringItem = ({ data }: IGatheringItem) => {
/>
</div>
<p className="overflow-hidden truncate whitespace-nowrap">
{data.zoneCategoryParentName} {","} {data.zoneCategoryChildName}
{data.zoneCategoryParentName === "세종"
? "세종특별자치시"
: `${data.zoneCategoryParentName}, ${data.zoneCategoryChildName}`}
</p>
</article>
</div>
Expand Down
4 changes: 3 additions & 1 deletion src/components/common/GatheringItemHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ const GatheringItemHome = ({ data }: IGatheringItemHome) => {
/>
</div>
<p className="overflow-hidden truncate whitespace-nowrap">
{data.zoneCategoryParentName} {","} {data.zoneCategoryChildName}
{data.zoneCategoryParentName === "세종"
? "세종특별자치시"
: `${data.zoneCategoryParentName}, ${data.zoneCategoryChildName}`}
</p>
</div>
<article className="flex flex-col-reverse gap-2">
Expand Down
4 changes: 3 additions & 1 deletion src/components/common/InformationItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ const InformationItem = ({
<div className="flex flex-row justify-between">
<div className="flex flex-row items-center gap-1 text-gray1">
<TiLocation />
<p className="text-xs font-medium">{address}</p>
<p className="text-xs font-medium">
{address.slice(0, 2) === "세종" ? "세종특별자치시" : address}
</p>
</div>
<div className="flex flex-row items-center gap-3">
<div
Expand Down
6 changes: 3 additions & 3 deletions src/components/gathering/read/detail/GatheringViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const GatheringViewer = ({
<div className="text-xs font-semibold text-black">
{data.userPostingResponse?.nickname}
</div>
<div className="whitespace-nowrap w-fit flex-shrink-0 text-xs text-gray1">
<div className="w-fit flex-shrink-0 whitespace-nowrap text-xs text-gray1">
{format(new Date(data.createdAt), "yyyy-MM-dd")}
</div>
</div>
Expand Down Expand Up @@ -112,7 +112,7 @@ const GatheringViewer = ({
/>
<div>
{data.zoneCategoryResponse.parentZoneCategory?.name == "세종"
? "세종"
? "세종특별자치시"
: `
${data.zoneCategoryResponse.parentZoneCategory?.name} ,
${data.zoneCategoryResponse.name}
Expand All @@ -135,7 +135,7 @@ const GatheringViewer = ({
>
{currentParticipants || data.nowPersonCount}
</span>
/ {data.personCount}
{" /"} {data.personCount}
</span>
<span className="text-gray2">
{"(" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const regions = [
{ id: 14, name: "충북" },
{ id: 15, name: "충남" },
{ id: 16, name: "전북" },
{ id: 245, name: "세종" },
];

const SELECTED_SCHEDULE_DATA = [
Expand Down
2 changes: 2 additions & 0 deletions src/constants/informations/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const LOCATION = [
"충북",
"충남",
"전북",
"세종",
];

type LOCATION_ID_TYPE = {
Expand All @@ -38,4 +39,5 @@ export const LOCATION_ID: LOCATION_ID_TYPE = {
충북: 14,
충남: 15,
전북: 16,
세종: 245,
};
26 changes: 17 additions & 9 deletions src/containers/gathering/createUpdate/GatheringCreateContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const GatheringCreateContainer = () => {
});

const createGatheringHandler = async () => {

const {
gatheringCategoryId,
allowedSex,
Expand All @@ -64,17 +63,26 @@ const GatheringCreateContainer = () => {
searchId: searchId,
name: placeName,
xAxis: Number(xAxis),
yAxis: Number(yAxis),
yAxis: Number(yAxis),
address: roadAddressName,
},
},
allowedSex: allowedSex.toUpperCase(),
// gatheringCategoryId: +subCategoryId,
gatheringCategoryId: gatheringCategoryId,
zoneCategoryNameParent: convertRegionToTwoLetters(roadAddressName.split(" ")[0]),
zoneCategoryNameChild: roadAddressName.split(" ")[1],
tagRegisterRequests: hashtags.length > 0 ? hashtags.map(i=>{return {name: i}}) : []

}),
zoneCategoryNameParent: convertRegionToTwoLetters(
roadAddressName.split(" ")[0],
),
zoneCategoryNameChild:
convertRegionToTwoLetters(roadAddressName.split(" ")[0]) === "세종"
? "세종"
: roadAddressName.split(" ")[1],
tagRegisterRequests:
hashtags.length > 0
? hashtags.map((i) => {
return { name: i };
})
: [],
}),
});

if (!response.ok) {
Expand All @@ -91,7 +99,7 @@ const GatheringCreateContainer = () => {
} catch (error) {
console.error("There was a problem with the fetch operation:", error);
}
}
};

return (
<FormProvider {...methods}>
Expand Down
23 changes: 13 additions & 10 deletions src/containers/gathering/createUpdate/GatheringUpdateContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import { useEffect, useState } from "react";
import { FormProvider, useForm } from "react-hook-form";

interface IGatheringUpdateContainer {
gatheringData: GatheringDetailResponseDto
gatheringData: GatheringDetailResponseDto;
}

const GatheringUpdateContainer = ({gatheringData}: IGatheringUpdateContainer) => {
const GatheringUpdateContainer = ({
gatheringData,
}: IGatheringUpdateContainer) => {
const router = useRouter();
const toastifyStore = useToastifyStore();
const [loading, setLoading] = useState<boolean>(false);
Expand Down Expand Up @@ -54,7 +56,7 @@ const GatheringUpdateContainer = ({gatheringData}: IGatheringUpdateContainer) =>
const params = useParams();

const updateGatheringHandler = async () => {
const { id } = params;
const { id } = params;
const {
gatheringCategoryId,
allowedSex,
Expand Down Expand Up @@ -88,7 +90,10 @@ const GatheringUpdateContainer = ({gatheringData}: IGatheringUpdateContainer) =>
zoneCategoryNameParent: convertRegionToTwoLetters(
roadAddressName.split(" ")[0],
),
zoneCategoryNameChild: roadAddressName.split(" ")[1],
zoneCategoryNameChild:
convertRegionToTwoLetters(roadAddressName.split(" ")[0]) === "세종"
? "세종"
: roadAddressName.split(" ")[1],
tagRegisterRequests:
hashtags.length > 0
? hashtags.map((i) => {
Expand All @@ -97,7 +102,7 @@ const GatheringUpdateContainer = ({gatheringData}: IGatheringUpdateContainer) =>
: [],
}),
});

if (!response.ok) {
setLoading(false);
toastifyStore.setToastify({
Expand All @@ -112,20 +117,18 @@ const GatheringUpdateContainer = ({gatheringData}: IGatheringUpdateContainer) =>
router.replace(`/gathering`);
router.refresh();
setLoading(false);

} catch (error) {
setLoading(false);
console.error("There was a problem with the fetch operation:", error);
}
}
};

useEffect(() => {
methods.trigger();
},[])

}, []);

return (
<FormProvider {...methods}>
<FormProvider {...methods}>
<GatheringEditor
updateGatheringHandler={updateGatheringHandler}
isEdit={true}
Expand Down
10 changes: 8 additions & 2 deletions src/containers/informations/write/PlaceModalContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ const PlaceModalContainer = ({ closeModal }: Props) => {
}) => {
const temp = placeInfo.address_name.split(" ");
formContext.setValue("province", temp[0].slice(0, 2) ?? "");
formContext.setValue("city", temp[1] ?? "");
formContext.setValue(
"city",
temp[0].slice(0, 2) === "세종" ? "세종" : temp[1] ?? "",
);
formContext.setValue("informationAddress", placeInfo.address_name);
formContext.setValue("placeId", placeInfo.id);
formContext.setValue("placeXAxis", placeInfo.x);
Expand All @@ -102,7 +105,10 @@ const PlaceModalContainer = ({ closeModal }: Props) => {
}) => {
const temp = addressInfo.address_name.split(" ");
formContext.setValue("province", temp[0].slice(0, 2) ?? "");
formContext.setValue("city", temp[1] ?? "");
formContext.setValue(
"city",
temp[0].slice(0, 2) === "세종" ? "세종" : temp[1] ?? "",
);
formContext.setValue("informationAddress", addressInfo.address_name);
formContext.setValue("placeXAxis", addressInfo.x);
formContext.setValue("placeYAxis", addressInfo.y);
Expand Down

0 comments on commit 96e1000

Please sign in to comment.