Skip to content

Commit

Permalink
Merge pull request #196 from space-401/feat/login
Browse files Browse the repository at this point in the history
📝fix : 방장 넘겨주는 버그 수정, 달력 리셋 버튼 추가
  • Loading branch information
ooherin authored Dec 5, 2023
2 parents cbdacbd + 376a132 commit cfc1bc5
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/components/Main/Comments/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const DetailComments = (props: DetailCommentType) => {
}
setIsReply({ open: true, refId: refId, id: id });
};

return (
<>
<S.Wrapper isOpen={isOpen}>
Expand Down
3 changes: 0 additions & 3 deletions src/components/Main/MainBody/MainBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,9 @@ export const MainBody = (props: PostListPropType) => {

const { postList, total, page: curPage, itemLength } = spacePostList!;

useEffect(() => {}, [spaceId]);

useEffect(() => {
setSearchParams(objectHelperWithNotUndefined(query));
refetch();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [refetch, query]);

const detailModalOpen = useDetailModalOpen();
Expand Down
9 changes: 4 additions & 5 deletions src/components/Main/Setting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,15 @@ export const SettingComponent = React.forwardRef(
const changeAdminAction = (userId: number) => {
onClose();
const formData = new FormData();
const spaceUserDTO = {
const DTO = {
spaceId: spaceId,
userId,
isAdmin: true,
};
const image = new Blob([], {
type: 'image/jpeg',
const spaceUserDTO = new Blob([JSON.stringify(DTO)], {
type: 'application/json',
});
formData.append('image', image, 'image');
formData.append('spaceUserDTO', JSON.stringify(spaceUserDTO));
formData.append('spaceUserDTO', spaceUserDTO);
userUpdateAction(formData);
};

Expand Down
29 changes: 27 additions & 2 deletions src/components/common/Calender/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import { ko } from 'date-fns/esm/locale';
import getYear from 'date-fns/getYear';
import { useEffect, useState } from 'react';
import 'react-datepicker/dist/react-datepicker.css';
import { useSearchParams } from 'react-router-dom';
import { ReactComponent as CalenderIcon } from '@/assets/svg/calenderIcon.svg';
import { ReactComponent as DownIcon } from '@/assets/svg/chevron/chevron_down.svg';
import { ReactComponent as UpIcon } from '@/assets/svg/chevron/chevron_up.svg';
import { ReactComponent as MainCalenderIcon } from '@/assets/svg/mainCalender.svg';
import { BasicButton } from '..';
import './calender.css';
import { S } from './style';
import { MONTHS, YEARS } from './util';
Expand All @@ -32,6 +34,7 @@ export const Calender = ({
dateInfo,
fontSize,
}: CalenderPropsType) => {
const [searchParams, setSearchParams] = useSearchParams();
const [startDate, setStartDate] = useState<Date | null>(
dateInfo?.startDate ? new Date(dateInfo.startDate!) : null
);
Expand All @@ -42,7 +45,6 @@ export const Calender = ({
useEffect(() => {
dateInfo?.startDate && setStartDate(new Date(dateInfo.startDate));
dateInfo?.endDate && setEndDate(new Date(dateInfo.endDate));
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const [isDropdownOpen, setIsDropdownOpen] = useState([false, false]);
Expand Down Expand Up @@ -80,9 +82,24 @@ export const Calender = ({
}
setDateInfo(newDateStr);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [startDate, endDate]);

//날짜 리셋
const onResetDate = () => {
setStartDate(null);
setEndDate(null);
removeQueryParam('startDate');
removeQueryParam('endDate');
location.reload();
};

const removeQueryParam = (keyToRemove: string) => {
if (searchParams.has(keyToRemove)) {
searchParams.delete(keyToRemove); // 기존의 searchParams를 직접 수정
setSearchParams(new URLSearchParams(searchParams)); // 새로운 인스턴스로 업데이트
}
};

return (
<div
className="custom-react-datepicker__wrapper"
Expand Down Expand Up @@ -200,6 +217,14 @@ export const Calender = ({
))}
</select>
)}
<BasicButton
width={40}
color={'white'}
height={10}
onClick={onResetDate}
>
reset
</BasicButton>
</div>
</div>
</div>
Expand Down
10 changes: 7 additions & 3 deletions src/constants/api.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
export const Dev = process.env.NODE_ENV === 'development';
export const Dev = process.env.NODE_ENV !== 'development';

export const NETWORK = {
RETRY_COUNT: 2,
TIMEOUT: 10000,
};

export const BASE_URL = import.meta.env.VITE_BASE_URL;
// export const BASE_URL = Dev
// ? 'http://localhost:3000'
// : import.meta.env.VITE_BASE_URL;

export const BASE_URL = 'http://localhost:3000';

export const AXIOS_BASE_URL = import.meta.env.VITE_BACK_URL;

export const END_POINTS = {
export const END_POINTS = {
USER: '/user',
TOKEN: '/user/refreshToken',
MY_POST_LIST: `/user/mypost`,
Expand Down
2 changes: 1 addition & 1 deletion src/modal/Detail/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ const BackClickBlock = styled.div<{ isOpen: boolean }>`
`;

const MenuGroup = styled.div<{ isOpen: boolean; width?: number; top?: number }>`
right: -140px;
right: -100px;
top: ${({ top }) => (top ? top : 20)}px;
position: absolute;
width: ${({ width }) => (width ? width : 102)}px;
Expand Down
3 changes: 1 addition & 2 deletions src/pages/CreatePost/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const CreatePost = () => {
navigate(PATH.SPACE);
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [postId]);

const { createPostAction, postCreateSuccess } = usePostCreateMutation();
Expand Down Expand Up @@ -214,7 +213,7 @@ const CreatePost = () => {
postId,
};

if (imageArr.convertedImages) {
if (imageArr.convertedImages.length) {
imageArr.convertedImages.forEach((image) => {
const blobImg = new Blob([image], {
type: 'image/jpeg',
Expand Down

0 comments on commit cfc1bc5

Please sign in to comment.