onDropdownClick()}
+ className={`${!orderDropdownVisible && "hidden"} absolute -left-[4.5rem] top-7 z-10 flex w-[8.625rem] flex-col items-center gap-1 rounded-xl bg-white/95 text-gray1 shadow dark:text-slate-400`}
+ onClick={() => onOrderDropdownClick()}
>
최신순
좋아요순
조회순
diff --git a/src/containers/informations/edit/InformationEditorContainer.tsx b/src/containers/informations/edit/InformationEditorContainer.tsx
index 7142616c..a20957bb 100644
--- a/src/containers/informations/edit/InformationEditorContainer.tsx
+++ b/src/containers/informations/edit/InformationEditorContainer.tsx
@@ -28,6 +28,7 @@ const InformationEditorContainer = ({ informationId, data }: Props) => {
const inputTagRef = useRef(null);
const router = useRouter();
const [loading, setLoading] = useState(false);
+ const [originalThumbnailUrl, setOriginalThumbnailUrl] = useState("");
// 장소 선택 모달창이 보이는지 여부
const [locationModal, setLocationModal] = useState(false);
@@ -95,6 +96,16 @@ const InformationEditorContainer = ({ informationId, data }: Props) => {
return;
}
+ const deletedImages = validatedFields.data.deleteImages
+ .filter((deletedImage) => !editorStore.images.includes(deletedImage))
+ .map((deletedImage) => ({
+ address: deletedImage,
+ }));
+
+ if (originalThumbnailUrl !== validatedFields.data.thumbnailImageUrl) {
+ deletedImages.push({ address: originalThumbnailUrl });
+ }
+
const data: UpdateInformationRequestDto = {
title: validatedFields.data.informationTitle,
address: validatedFields.data.informationAddress,
@@ -110,11 +121,7 @@ const InformationEditorContainer = ({ informationId, data }: Props) => {
categoryId: validatedFields.data.categoryId,
zoneCategoryNameParent: validatedFields.data.province,
zoneCategoryNameChild: validatedFields.data.city,
- deleteImages: validatedFields.data.deleteImages
- .filter((deletedImage) => !editorStore.images.includes(deletedImage))
- .map((deletedImage) => ({
- address: deletedImage,
- })),
+ deleteImages: deletedImages,
thumbNailUrl: validatedFields.data.thumbnailImageUrl,
contentImagesUrl: validatedFields.data.contentImagesUrl,
tagRegisterRequests: validatedFields.data.hashtags.map((tag) => ({
@@ -177,6 +184,11 @@ const InformationEditorContainer = ({ informationId, data }: Props) => {
tips: data.tip.split(";"),
});
+ setOriginalThumbnailUrl(
+ data.imageResponses.find((value) => value.imageStatus === "썸네일")
+ ?.address ?? "",
+ );
+
return () => {
initialize();
};
diff --git a/src/containers/informations/list/InformationSearchContainer.tsx b/src/containers/informations/list/InformationSearchContainer.tsx
index 122a300f..60ca8e84 100644
--- a/src/containers/informations/list/InformationSearchContainer.tsx
+++ b/src/containers/informations/list/InformationSearchContainer.tsx
@@ -6,23 +6,31 @@ import { useState } from "react";
const InformationSearchContainer = () => {
const [modalVisible, setModalVisible] = useState(false);
- const [dropdownVisible, setDropdownVisible] = useState(false);
+ const [orderDropdownVisible, setOrderDropdownVisible] =
+ useState(false);
const pathname = usePathname();
const searchParams = useSearchParams();
const parentCategoryId = searchParams.get("parentCategoryId")!;
const childCategoryId = searchParams.get("childCategoryId");
const place = searchParams.get("place") ?? "";
const order = searchParams.get("order") ?? "latest";
- const [tagName, setTagName] = useState("");
+ const [searchValue, setSearchValue] = useState("");
+ const [searchMethod, setSearchMethod] = useState("제목");
+ const [searchDropdownVisible, setSearchDropdownVisible] =
+ useState(false);
const router = useRouter();
- const onChangeTagName = (value: string) => {
- setTagName(value.trim().slice(0, 15));
+ const onChangeSearchValue = (value: string) => {
+ if (searchMethod === "제목") {
+ setSearchValue(value.slice(0, 50));
+ } else {
+ setSearchValue(value.trim().slice(0, 15));
+ }
};
- const searchByTagName = () => {
+ const onSearchClick = () => {
router.push(
- `${pathname}?page=1&parentCategoryId=${parentCategoryId}${childCategoryId !== null ? `&childCategoryId=${childCategoryId}` : ""}${place !== "" ? `&place=${place}` : ""}&order=${order}${tagName !== "" ? `&tagName=${tagName}` : ""}`,
+ `${pathname}?page=1&parentCategoryId=${parentCategoryId}${childCategoryId !== null ? `&childCategoryId=${childCategoryId}` : ""}${place !== "" ? `&place=${place}` : ""}&order=${order}${searchValue !== "" ? `${searchMethod === "제목" ? "&title" : "$tagName"}=${searchValue}` : ""}`,
);
};
@@ -33,14 +41,25 @@ const InformationSearchContainer = () => {
childCategoryId={childCategoryId}
place={place}
order={order}
- tagName={tagName}
+ searchMethod={searchMethod}
+ searchValue={searchValue}
modalVisible={modalVisible}
- dropdownVisible={dropdownVisible}
- onChangeTagName={onChangeTagName}
+ orderDropdownVisible={orderDropdownVisible}
+ searchDropdownVisible={searchDropdownVisible}
+ onChangeSearchValue={onChangeSearchValue}
closeModal={() => setModalVisible(false)}
openModal={() => setModalVisible(true)}
- onDropdownClick={() => setDropdownVisible(!dropdownVisible)}
- searchByTagName={searchByTagName}
+ onOrderDropdownClick={() =>
+ setOrderDropdownVisible(!orderDropdownVisible)
+ }
+ onSearchDropdownClick={() =>
+ setSearchDropdownVisible(!searchDropdownVisible)
+ }
+ onSearchClick={onSearchClick}
+ setSearchMethod={(value: string) => {
+ setSearchValue("");
+ setSearchMethod(value);
+ }}
/>
);
};