Skip to content

Commit

Permalink
chore: resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
corinthionia committed Aug 5, 2023
2 parents 9836db0 + 73881b6 commit 4ffd061
Show file tree
Hide file tree
Showing 43 changed files with 489 additions and 476 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"react-copy-to-clipboard": "^5.1.0",
"react-dom": "^18.2.0",
"react-multi-date-picker": "^3.3.4",
"react-query": "^3.39.3",
"react-router-dom": "^6.8.1",
"react-scripts": "5.0.1",
"react-scrollable-picker": "^1.0.2",
Expand Down
11 changes: 11 additions & 0 deletions src/api/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { PostAuthParamsType } from '../types/auth';
import { instance } from './instance';

export const postUserInfo = async ({ roomUUID, form }: PostAuthParamsType) => {
const { data } = await instance.post(
`/api/room/${roomUUID}/login`,
JSON.stringify(form)
);

return data;
};
33 changes: 33 additions & 0 deletions src/api/availableTimes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { instance } from './instance';
import { PutAvailableTimesParamsType } from '../types/addTime';

export const putAvailableTimes = async ({
roomUUID,
payload,
}: PutAvailableTimesParamsType) => {
const { data } = await instance.put(
`/api/room/${roomUUID}/available-time`,
JSON.stringify(payload)
);

return data;
};

export const getAvailableTimesByOne = async (
roomUUID: string,
userName: string
) => {
const { data } = await instance.get(
`/api/room/${roomUUID}/available-time?name=${userName}`
);

return data;
};

export const getAvailableTimesByGroup = async (roomUUID: string) => {
const { data } = await instance.get(
`/api/room/${roomUUID}/available-time/group`
);

return data;
};
3 changes: 2 additions & 1 deletion src/utils/API.ts โ†’ src/api/instance.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import axios from 'axios';

export const API = axios.create({
export const instance = axios.create({
baseURL: process.env.REACT_APP_API_PATH,
headers: {
'Content-Type': 'application/json',
withCredentials: true,
},
});
13 changes: 13 additions & 0 deletions src/api/result.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { instance } from './instance';

export const getCandidateTimesInfo = async (
roomUUID: string,
sort: string,
name: string
) => {
const { data } = await instance.get(
`/api/room/${roomUUID}/adjustment-result?sorted=${sort}&${name}`
);

return data;
};
14 changes: 14 additions & 0 deletions src/api/room.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { instance } from './instance';
import { PostRoomTypes } from '../types/roomInfo';

export const getRoomInfo = async (roomUUID: string) => {
const { data } = await instance.get(`/api/room/${roomUUID}`);

return data;
};

export const createRoom = async (payload: PostRoomTypes) => {
const { data } = await instance.post(`/api/room`, JSON.stringify(payload));

return data;
};
8 changes: 8 additions & 0 deletions src/assets/data/initialCreateRoomData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const initialCreateRoomData = {
headCount: null,
dates: [],
startTime: null,
endTime: null,
timer: null,
title: '',
};
9 changes: 9 additions & 0 deletions src/assets/data/initialRoomInfoData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const initialRoomInfoData = {
title: '',
headCount: 0,
participants: [],
deadLine: null,
dates: [],
startTime: null,
endTime: null,
};
6 changes: 0 additions & 6 deletions src/atoms/availableBottomSheet.ts

This file was deleted.

16 changes: 16 additions & 0 deletions src/atoms/createRoomAtoms.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { atom, selector } from 'recoil';
import { PostRoomTypes } from '../types/roomInfo';
import { initialCreateRoomData } from '../assets/data/initialCreateRoomData';

export const createRoomAtoms = atom<PostRoomTypes>({
key: 'recoilRoomAtoms',
default: initialCreateRoomData,
});

export const createRoomInfoState = selector({
key: 'recoilRoomInfoState', // ๊ณ ์œ ํ•œ ํ‚ค ๊ฐ’
get: ({ get }) => {
const roomInfo = get(createRoomAtoms);
return roomInfo;
},
});
14 changes: 0 additions & 14 deletions src/atoms/recoilRoomAtoms.ts

This file was deleted.

14 changes: 0 additions & 14 deletions src/atoms/recoilUuidAtoms.ts

This file was deleted.

46 changes: 17 additions & 29 deletions src/components/addCalendar/AddCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ import {
} from './AddCalendar.styles';
import BottomButton from '../bottomButton/BottomButton';

import { API } from '../../utils/API';
import { useGetAvailableTimesByOne } from '../../queries/availableTimes/useGetAvailableTimesByOne';
import { usePutAvailableTimes } from '../../queries/availableTimes/usePutAvailableTimes';

const AddCalendar = ({
dates,
selected,
setSelected,
selectedMethod,
}: AddCalendarType) => {
const { roomUUID } = useParams();
const { roomUUID } = useParams() as { roomUUID: string };
const navigate = useNavigate();
const userName = localStorage.getItem('userName') || '';

Expand Down Expand Up @@ -67,16 +68,14 @@ const AddCalendar = ({
}
}, [date]);

const { data } = useGetAvailableTimesByOne(roomUUID, userName);
const { mutate, isSuccess } = usePutAvailableTimes();

useEffect(() => {
const getPreviousSelectedTimes = async () => {
const { data } = await API.get(
`/api/room/${roomUUID}/available-time?name=${userName}`
);
if (data) {
setSelected(data.availableDateTimes);
};

getPreviousSelectedTimes();
}, []);
}
}, [data]);

useEffect(() => {
setSelected([]);
Expand All @@ -86,23 +85,6 @@ const AddCalendar = ({
navigate(`/current/${roomUUID}`);
};

const putAvailableTime = async (payload: {
name: string;
hasTime: boolean;
availableDateTimes: string[];
}) => {
const response = await API.put(
`/api/room/${roomUUID}/available-time`,
JSON.stringify(payload)
);

if (response.status === 200) {
goToCurrent();
} else {
alert('์ฒ˜๋ฆฌ ์ค‘ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค!');
}
};

const handleApplyClick = () => {
if (selectedMethod === 'possible') {
const payload = {
Expand All @@ -111,7 +93,7 @@ const AddCalendar = ({
availableDateTimes: [...selected],
};

putAvailableTime(payload);
mutate({ roomUUID, payload });
}

if (selectedMethod === 'impossible') {
Expand All @@ -124,10 +106,16 @@ const AddCalendar = ({
availableDateTimes: filteredTime,
};

putAvailableTime(payload);
mutate({ roomUUID, payload });
}
};

useEffect(() => {
if (isSuccess) {
goToCurrent();
}
}, [isSuccess]);

return (
<>
<Wrapper>
Expand Down
Loading

0 comments on commit 4ffd061

Please sign in to comment.