diff --git a/src/components/map/MapInfoPanel/MapBasicInfo/MapBasicInfoContainer/MapBasicInfoContainer.module.scss b/src/components/map/MapInfoPanel/MapBasicInfo/MapBasicInfoContainer/MapBasicInfoContainer.module.scss
index c372981..82b43e5 100644
--- a/src/components/map/MapInfoPanel/MapBasicInfo/MapBasicInfoContainer/MapBasicInfoContainer.module.scss
+++ b/src/components/map/MapInfoPanel/MapBasicInfo/MapBasicInfoContainer/MapBasicInfoContainer.module.scss
@@ -8,3 +8,65 @@
padding: 16px;
border-bottom: 1px solid var(--gray_50);
}
+
+.mapInfoInputContainer {
+ width: 100%;
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ padding-bottom: 16px;
+ border-bottom: 1px solid var(--gray_50);
+}
+
+.titleContainer {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+}
+#mapTitle {
+ width: calc(100% - 24px);
+ border: none;
+ font-size: 20px;
+ font-weight: 600;
+}
+#mapTitle:disabled,
+#mapDescription:disabled {
+ background: none;
+}
+
+#mapDescription {
+ border: none;
+ resize: none;
+ font-size: 14px;
+ overflow: hidden;
+ width: 100%;
+ field-sizing: content;
+}
+#mapDescription:focus {
+ outline: none;
+}
+#mapTitle::-webkit-input-placeholder,
+#mapDescription::-webkit-input-placeholder {
+ color: var(--gray_400);
+}
+
+.bookmarkBtn:hover {
+ cursor: pointer;
+}
+
+.locationInfoContainer {
+ display: flex;
+ flex-direction: column;
+ gap: 16px;
+}
+
+.locationInfo {
+ display: flex;
+ justify-content: space-between;
+ span {
+ font-size: 14px;
+ }
+}
+.location__title {
+ color: var(--gray_400);
+}
diff --git a/src/components/map/MapInfoPanel/MapBasicInfo/MapBasicInfoContainer/MapBasicInfoContainer.tsx b/src/components/map/MapInfoPanel/MapBasicInfo/MapBasicInfoContainer/MapBasicInfoContainer.tsx
index e2b5c23..00e3072 100644
--- a/src/components/map/MapInfoPanel/MapBasicInfo/MapBasicInfoContainer/MapBasicInfoContainer.tsx
+++ b/src/components/map/MapInfoPanel/MapBasicInfo/MapBasicInfoContainer/MapBasicInfoContainer.tsx
@@ -1,17 +1,119 @@
+import { useEffect, useState } from 'react';
import styles from './MapBasicInfoContainer.module.scss';
-import MapTitleAndDescriptionInputContainer from './MapTitleAndDescriptionInputContainer';
-import LocationInfoContainer from './MapLocationInfoContainer';
+import { useMapBasicInfoQuery } from '../../../../../apis/Map/fetchMapBasicInfo';
+import useRegisterStore from '../../../../../stores/registerStore';
import { MapMode } from '../../../../../types/enum/MapMode';
+import { RegisterStatus } from '../../../../../types/enum/RegisterStatus';
+import BookmarkDefault from '../../../../../assets/btn_bookmark_default.svg';
+import BookmarkSelected from '../../../../../assets/btn_bookmark_selected.svg';
interface Props {
mode: MapMode;
+ mapId: number;
}
-const MapBasicInfoContainer: React.FC
= ({ mode }) => {
+const MapBasicInfoContainer: React.FC = ({ mode, mapId }) => {
+ const { registerStatus, setLoginNeededStatus } = useRegisterStore();
+ const [editedTitle, setEditedTitle] = useState('');
+ const [editedDescription, setEditedDescription] = useState('');
+
+ const { mapBasicInfo, isMapBasicInfoLoading } = useMapBasicInfoQuery(
+ mapId,
+ mode,
+ );
+
+ useEffect(() => {
+ if (!isMapBasicInfoLoading) {
+ const mapBasicInfoResult = mapBasicInfo!.result;
+ setEditedTitle(mapBasicInfoResult.title);
+ setEditedDescription(mapBasicInfoResult.description);
+ }
+ }, [isMapBasicInfoLoading]);
+
+ const handleTitleOnChange = (e: React.ChangeEvent) => {
+ setEditedTitle(e.currentTarget.value);
+ };
+
+ const handleDescriptionOnChange = (
+ e: React.ChangeEvent,
+ ) => {
+ setEditedDescription(e.currentTarget.value);
+ };
+
+ const handleFocusOutTitle = () => {
+ //TODO: 지도 제목 저장 api 호출
+ };
+
+ const handleFocusOutDescription = () => {
+ //TODO: 지도 설명 저장 api 호출
+ };
+
+ const handleSwitchIsBookmarked = () => {
+ if (registerStatus !== RegisterStatus.LOG_IN) {
+ setLoginNeededStatus(true);
+ } else {
+ //TODO: 북마크 설정 api 호출
+ }
+ };
return (
-
-
+
+
+
+ {mapBasicInfo !== undefined &&
+ !mapBasicInfo.result.mine &&
+ (mapBasicInfo.result.bookmarked ? (
+
+ ) : (
+
+ ))}
+
+
+
+
+
+ 위치
+
+ {mapBasicInfo !== undefined && mapBasicInfo!.result.address}
+
+
+ {/* TODO: 날씨, 미세/초미세 추후 목표로 보류 */}
+ {/*
+ 날씨
+ 날씨 api 호출 결과
+
+
+ 미세/초미세
+ 미세먼지 api 호출 결과
+
*/}
+
);
};
diff --git a/src/components/map/MapInfoPanel/MapBasicInfo/MapBasicInfoContainer/MapLocationInfoContainer.module.scss b/src/components/map/MapInfoPanel/MapBasicInfo/MapBasicInfoContainer/MapLocationInfoContainer.module.scss
deleted file mode 100644
index 38c4079..0000000
--- a/src/components/map/MapInfoPanel/MapBasicInfo/MapBasicInfoContainer/MapLocationInfoContainer.module.scss
+++ /dev/null
@@ -1,16 +0,0 @@
-.locationInfoContainer {
- display: flex;
- flex-direction: column;
- gap: 16px;
-}
-
-.locationInfo {
- display: flex;
- justify-content: space-between;
- span {
- font-size: 14px;
- }
-}
-.location__title {
- color: var(--gray_400);
-}
diff --git a/src/components/map/MapInfoPanel/MapBasicInfo/MapBasicInfoContainer/MapLocationInfoContainer.tsx b/src/components/map/MapInfoPanel/MapBasicInfo/MapBasicInfoContainer/MapLocationInfoContainer.tsx
deleted file mode 100644
index 4a41c80..0000000
--- a/src/components/map/MapInfoPanel/MapBasicInfo/MapBasicInfoContainer/MapLocationInfoContainer.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-import styles from './MapLocationInfoContainer.module.scss';
-import useMapInfoStore from '../../../../../stores/mapInfoStore';
-
-const MapLocationInfoContainer = () => {
- const { mapInfo } = useMapInfoStore();
-
- return (
-
-
- 위치
- {mapInfo.location}
-
- {/* TODO: 날씨, 미세/초미세 추후 목표로 보류 */}
- {/*
- 날씨
- 날씨 api 호출 결과
-
-
- 미세/초미세
- 미세먼지 api 호출 결과
-
*/}
-
- );
-};
-
-export default MapLocationInfoContainer;
diff --git a/src/components/map/MapInfoPanel/MapBasicInfo/MapBasicInfoContainer/MapTitleAndDescriptionInputContainer.module.scss b/src/components/map/MapInfoPanel/MapBasicInfo/MapBasicInfoContainer/MapTitleAndDescriptionInputContainer.module.scss
deleted file mode 100644
index c86f596..0000000
--- a/src/components/map/MapInfoPanel/MapBasicInfo/MapBasicInfoContainer/MapTitleAndDescriptionInputContainer.module.scss
+++ /dev/null
@@ -1,44 +0,0 @@
-.mapInfoInputContainer {
- width: 100%;
- display: flex;
- flex-direction: column;
- gap: 12px;
- padding-bottom: 16px;
- border-bottom: 1px solid var(--gray_50);
-}
-
-.titleContainer {
- display: flex;
- justify-content: space-between;
- align-items: center;
-}
-#mapTitle {
- width: calc(100% - 24px);
- border: none;
- font-size: 20px;
- font-weight: 600;
-}
-#mapTitle:disabled,
-#mapDescription:disabled {
- background: none;
-}
-
-#mapDescription {
- border: none;
- resize: none;
- font-size: 14px;
- overflow: hidden;
- width: 100%;
- field-sizing: content;
-}
-#mapDescription:focus {
- outline: none;
-}
-#mapTitle::-webkit-input-placeholder,
-#mapDescription::-webkit-input-placeholder {
- color: var(--gray_400);
-}
-
-.bookmarkBtn:hover {
- cursor: pointer;
-}
diff --git a/src/components/map/MapInfoPanel/MapBasicInfo/MapBasicInfoContainer/MapTitleAndDescriptionInputContainer.tsx b/src/components/map/MapInfoPanel/MapBasicInfo/MapBasicInfoContainer/MapTitleAndDescriptionInputContainer.tsx
deleted file mode 100644
index 8b1568c..0000000
--- a/src/components/map/MapInfoPanel/MapBasicInfo/MapBasicInfoContainer/MapTitleAndDescriptionInputContainer.tsx
+++ /dev/null
@@ -1,101 +0,0 @@
-import { useEffect, useState } from 'react';
-import { useNavigate } from 'react-router-dom';
-import styles from './MapTitleAndDescriptionInputContainer.module.scss';
-import useMapInfoStore from '../../../../../stores/mapInfoStore';
-import BookmarkDefault from '../../../../../assets/btn_bookmark_default.svg';
-import BookmarkSelected from '../../../../../assets/btn_bookmark_selected.svg';
-import useRegisterStore from '../../../../../stores/registerStore';
-import { RegisterStatus } from '../../../../../types/enum/RegisterStatus';
-import { MapMode } from '../../../../../types/enum/MapMode';
-
-interface Props {
- mode: MapMode;
-}
-
-const MapTitleAndDescriptionInputContainer: React.FC = ({ mode }) => {
- const { mapInfo } = useMapInfoStore();
- const { registerStatus, setLoginNeededStatus } = useRegisterStore();
- const [editedTitle, setEditedTitle] = useState('');
- const [editedDescription, setEditedDescription] = useState('');
-
- const navigate = useNavigate();
-
- useEffect(() => {
- setEditedTitle(mapInfo.title);
- setEditedDescription(mapInfo.description);
- }, []);
-
- const handleTitleOnChange = (e: React.ChangeEvent) => {
- setEditedTitle(e.currentTarget.value);
- };
-
- const handleDescriptionOnChange = (
- e: React.ChangeEvent,
- ) => {
- setEditedDescription(e.currentTarget.value);
- };
-
- const handleFocusOutTitle = () => {
- //TODO: 지도 제목 저장 api 호출, 응답으로 받은 지도 제목 사용
- // setTitle(editedTitle);
- navigate(`/map/${editedTitle.replaceAll(' ', '-')}/${mode}`);
- };
-
- const handleFocusOutDescription = () => {
- //TODO: 지도 설명 저장 api 호출
- // setDescription(editedDescription);
- };
-
- const handleSwitchIsBookmarked = () => {
- if (registerStatus !== RegisterStatus.LOG_IN) {
- setLoginNeededStatus(true);
- } else {
- //TODO: 북마크 설정 api 호출
- // switchIsBookmarked();
- }
- };
-
- return (
-
-
-
- {!mapInfo.isMine &&
- (mapInfo.isBookmarked ? (
-
- ) : (
-
- ))}
-
-
-
- );
-};
-
-export default MapTitleAndDescriptionInputContainer;
diff --git a/src/components/map/MapInfoPanel/MapBasicInfo/MapProducerContainer/MapProducerContainer.tsx b/src/components/map/MapInfoPanel/MapBasicInfo/MapProducerContainer/MapProducerContainer.tsx
index 9e5d1a0..31412c5 100644
--- a/src/components/map/MapInfoPanel/MapBasicInfo/MapProducerContainer/MapProducerContainer.tsx
+++ b/src/components/map/MapInfoPanel/MapBasicInfo/MapProducerContainer/MapProducerContainer.tsx
@@ -1,35 +1,38 @@
-import { useState } from 'react';
import styles from './MapProducerContainer.module.scss';
-import { MapProducerInfo } from '../../../../../types/map/MapProducerInfo';
+import { useMapBasicInfoQuery } from '../../../../../apis/Map/fetchMapBasicInfo';
import useRegisterStore from '../../../../../stores/registerStore';
import { RegisterStatus } from '../../../../../types/enum/RegisterStatus';
+import { MapMode } from '../../../../../types/enum/MapMode';
+import { UserType } from '../../../../../types/UserType';
+import UserDefaultProfile from '../../../../../assets/img_user_default_profile.svg';
-const MapProducerConatiner = () => {
- const [mockData, setMockData] = useState({
- profileId: 'mockUser',
- profileImgUrl: 'http://placehold.co/32x32',
- nickname: 'producer',
- amIFollowing: false,
- });
+interface Props {
+ mode: MapMode;
+ mapId: number;
+}
+
+const MapProducerConatiner: React.FC = ({ mode, mapId }) => {
+ const owner: UserType = useMapBasicInfoQuery(mapId, mode).mapBasicInfo!.result
+ .owner;
const { registerStatus, setLoginNeededStatus } = useRegisterStore();
const handleFollowBtn = () => {
if (registerStatus !== RegisterStatus.LOG_IN) setLoginNeededStatus(true);
else {
//TODO: 팔로우 api
- setMockData((state) => {
- return { ...state, amIFollowing: true };
- });
}
};
return (
-
-
{mockData.nickname}
+
+
{owner !== undefined && owner.nickName!}
- {mockData.amIFollowing ? (
+ {owner !== undefined && owner.amIFollowing ? (
diff --git a/src/components/map/MapInfoPanel/MapInfoPanel.tsx b/src/components/map/MapInfoPanel/MapInfoPanel.tsx
index 542c829..571cfcb 100644
--- a/src/components/map/MapInfoPanel/MapInfoPanel.tsx
+++ b/src/components/map/MapInfoPanel/MapInfoPanel.tsx
@@ -1,30 +1,23 @@
-import { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import styles from './MapInfoPanel.module.scss';
import MapProducerConatiner from './MapBasicInfo/MapProducerContainer/MapProducerContainer';
import MapBasicInfoContainer from './MapBasicInfo/MapBasicInfoContainer/MapBasicInfoContainer';
-import useMapInfoStore from '../../../stores/mapInfoStore';
import ObjectList from './ObjectOutlineList/ObjectList';
import { MapMode } from '../../../types/enum/MapMode';
import BlackBackBtn from '../../../assets/btn_arrow_left_black.svg';
import useRegisterStore from '../../../stores/registerStore';
+import { useMapBasicInfoQuery } from '../../../apis/Map/fetchMapBasicInfo';
+import useMapInfoStore from '../../../stores/mapInfoStore';
interface Props {
mode: MapMode;
+ mapId: number;
}
-const MapInfoPanel: React.FC
= ({ mode }) => {
- const { mapInfo } = useMapInfoStore();
- const { loginNeeded } = useRegisterStore();
-
+const MapInfoPanel: React.FC = ({ mode, mapId }) => {
const navigate = useNavigate();
-
- useEffect(() => {
- //TODO: 내가 제작한 지도인지 판단
- //아니라면
- //1. 상단에 지도 제작자 프로필 표시
- //2. 팔로잉 중인지 판단
- }, []);
+ const { loginNeeded } = useRegisterStore();
+ const { mapBasicInfo } = useMapBasicInfoQuery(mapId, mode);
const handleGoBack = () => {
navigate(-1);
@@ -43,9 +36,9 @@ const MapInfoPanel: React.FC = ({ mode }) => {
/>
-
-
-
+
+
+
);
@@ -62,9 +55,11 @@ const MapInfoPanel: React.FC = ({ mode }) => {
/>
- {!mapInfo.isMine &&
}
-
- {!loginNeeded &&
}
+ {mapBasicInfo !== undefined && !mapBasicInfo.result.mine && (
+
+ )}
+
+ {!loginNeeded &&
}
);
diff --git a/src/components/map/MapInfoPanel/ObjectOutlineList/ObjectList.tsx b/src/components/map/MapInfoPanel/ObjectOutlineList/ObjectList.tsx
index 1296973..e1f706c 100644
--- a/src/components/map/MapInfoPanel/ObjectOutlineList/ObjectList.tsx
+++ b/src/components/map/MapInfoPanel/ObjectOutlineList/ObjectList.tsx
@@ -1,9 +1,17 @@
import styles from './ObjectList.module.scss';
import ObjectOutlineBtn from './ObjectOutlineBtn';
import useMapInfoStore from '../../../../stores/mapInfoStore';
+import { useMapBasicInfoQuery } from '../../../../apis/Map/fetchMapBasicInfo';
+import { MapMode } from '../../../../types/enum/MapMode';
-const ObjectList = () => {
- const { mapInfo, innerData } = useMapInfoStore();
+interface Props {
+ mode: MapMode;
+ mapId: number;
+}
+
+const ObjectList: React.FC
= ({ mode, mapId }) => {
+ const { innerData } = useMapInfoStore();
+ const { mapBasicInfo } = useMapBasicInfoQuery(mapId, mode);
return (
@@ -12,7 +20,7 @@ const ObjectList = () => {
= ({ mode }) => {
+const ObjectInfoPanel: React.FC
= ({ mode, mapId }) => {
const object = useMapInfoStore((state) => state.getSelectedObject());
return (
-
+
{mode === MapMode.EDIT && (
= ({ mode }) => {
- const { mapInfo, innerData } = useMapInfoStore();
+const PublishLinkContainer: React.FC = ({ mode, mapId }) => {
+ const { innerData } = useMapInfoStore();
+ const { mapBasicInfo } = useMapBasicInfoQuery(mapId, mode);
const handleCopyLink = async () => {
//클립보드에 공유 링크 복사
try {
- await navigator.clipboard.writeText(`${mapInfo.publicLink}`);
+ await navigator.clipboard.writeText(
+ `mapu-frontend.vercel.app/map/2/view`,
+ );
} catch (e) {
//TODO: 에러 상태로 설정
alert('공유 링크 복사에 실패하였습니다.');
@@ -24,7 +30,6 @@ const PublishLinkContainer: React.FC = ({ mode }) => {
const handleSwitchIsPublished = () => {
//TODO: 게시 여부 설정 api 호출
- // swithIsPublished();
};
//editor
@@ -33,7 +38,7 @@ const PublishLinkContainer: React.FC = ({ mode }) => {
- {mapInfo.isPublished ? (
+ {mapBasicInfo !== undefined && mapBasicInfo.result.published ? (
지도 게시 취소하기
@@ -61,7 +66,7 @@ const PublishLinkContainer: React.FC = ({ mode }) => {
)}
- {mapInfo.isPublished ? (
+ {mapBasicInfo !== undefined && mapBasicInfo.result.published ? (
);
};
diff --git a/src/stores/mapInfoStore.ts b/src/stores/mapInfoStore.ts
index 0312c71..2ba2fa9 100644
--- a/src/stores/mapInfoStore.ts
+++ b/src/stores/mapInfoStore.ts
@@ -1,11 +1,9 @@
import { create } from 'zustand';
import { persist } from 'zustand/middleware';
-import { MapInfo } from '../types/map/MapInfo';
import { MapObject, YorkieDocType } from '../types/map/object/ObjectInfo';
import { Document } from 'yorkie-js-sdk';
interface State {
- mapInfo: MapInfo;
innerData: YorkieDocType;
selectedObjectId?: string;
doc?: Document;
@@ -25,7 +23,6 @@ interface State {
const useMapInfoStore = create(
persist(
(set, get) => ({
- mapInfo: {} as MapInfo,
innerData: {
informationAttributes: [],
objects: [],
diff --git a/src/types/UserType.ts b/src/types/UserType.ts
index c73d324..03a8e34 100644
--- a/src/types/UserType.ts
+++ b/src/types/UserType.ts
@@ -1,6 +1,7 @@
export interface UserType {
- imageUrl: string | null;
+ imgUrl: string | null;
nickName: string;
profileId: string;
- userId:number;
+ userId: number;
+ amIFollowing: boolean;
}
diff --git a/src/types/follow/FollowingType.ts b/src/types/follow/FollowingType.ts
index 64f3b98..2fb4830 100644
--- a/src/types/follow/FollowingType.ts
+++ b/src/types/follow/FollowingType.ts
@@ -1,6 +1,6 @@
-import { UserType } from "../UserType"
+import { UserType } from '../UserType';
export interface FollowingType {
userId: number;
- users : UserType[];
-}
\ No newline at end of file
+ users: UserType[];
+}
diff --git a/src/types/map/MapBasicInfo.ts b/src/types/map/MapBasicInfo.ts
new file mode 100644
index 0000000..201721a
--- /dev/null
+++ b/src/types/map/MapBasicInfo.ts
@@ -0,0 +1,14 @@
+import { UserType } from '../UserType';
+
+export interface MapBasicInfo {
+ mapId: number;
+ title: string;
+ address: string;
+ description: string;
+ latitude: number;
+ longitude: number;
+ published: boolean;
+ mine: boolean;
+ bookmarked: boolean;
+ owner: UserType;
+}
diff --git a/src/types/map/MapInfo.ts b/src/types/map/MapInfo.ts
deleted file mode 100644
index 24729bc..0000000
--- a/src/types/map/MapInfo.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export interface MapInfo {
- id: number;
- title: string;
- description: string;
- location: string;
- latitude: number;
- longitude: number;
- isPublished: boolean;
- publicLink?: string;
- isMine: boolean;
- isBookmarked?: boolean;
-}
diff --git a/src/types/mapData/APIExploreMapType .ts b/src/types/mapData/APIExploreMapType .ts
index f585e0c..7768250 100644
--- a/src/types/mapData/APIExploreMapType .ts
+++ b/src/types/mapData/APIExploreMapType .ts
@@ -1,12 +1,11 @@
-import { UserType } from "../UserType";
-import { KeywordType } from "../keywords/KeywordType";
+import { UserType } from '../UserType';
export interface APIExploreMapType {
mapId: number;
imageUrl: string;
title: string;
- region : string;
+ region: string;
description: string;
- user : UserType;
- keyword:string[];
+ user: UserType;
+ keyword: string[];
}
diff --git a/src/types/mapData/ExploreMapType.ts b/src/types/mapData/ExploreMapType.ts
index 23df6f5..e6a93a5 100644
--- a/src/types/mapData/ExploreMapType.ts
+++ b/src/types/mapData/ExploreMapType.ts
@@ -1,12 +1,12 @@
-import { UserType } from "../UserType";
-import { KeywordType } from "../keywords/KeywordType";
+import { KeywordType } from '../keywords/KeywordType';
+import { UserType } from '../UserType';
export interface ExploreMapType {
mapId: number;
imageUrl: string;
title: string;
- region : string;
+ region: string;
description: string;
- user : UserType;
+ user: UserType;
keyword: KeywordType[];
}
diff --git a/src/types/mapData/FollowingMapType.ts b/src/types/mapData/FollowingMapType.ts
index 456aeb7..160527f 100644
--- a/src/types/mapData/FollowingMapType.ts
+++ b/src/types/mapData/FollowingMapType.ts
@@ -1,8 +1,8 @@
-import { MapsType } from "./MapsType";
+import { MapsType } from './MapsType';
export interface FollowingMapType {
nickname: string;
profileId: string;
userImages: string;
maps: MapsType[];
-}
\ No newline at end of file
+}