Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/weekly/10'
Browse files Browse the repository at this point in the history
  • Loading branch information
kanguk01 committed Nov 7, 2024
2 parents 2e9c162 + ef99c00 commit 9e54bd4
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 86 deletions.
2 changes: 1 addition & 1 deletion src/api/hooks/useCreateTeam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ const useCreateTeam = (
});
};

export default useCreateTeam;
export default useCreateTeam;
2 changes: 1 addition & 1 deletion src/api/hooks/useGetTeamPlan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ const useGetTeamPlans = (teamId: number) => {
return result;
};

export default useGetTeamPlans;
export default useGetTeamPlans;
1 change: 0 additions & 1 deletion src/api/hooks/useTeamPlanSave.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useMutation, UseMutationOptions } from "@tanstack/react-query";
import { AxiosResponse } from "axios";
import { apiClient } from "@/api/instance";
import { CalendarEvent } from "@/components/features/CustomCalendar/CustomCalendar";

interface SavePlanParams {
teamId: number;
Expand Down
35 changes: 15 additions & 20 deletions src/components/features/CustomCalendar/CustomCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ interface CustomCalendarProps {
onDeletePlan?: (planId: string) => void;
isPreviewMode?: boolean;
previewDeviceId?: string; // Preview mode deviceId
previewGroupId?: string; // Preview mode groupId
previewGroupId?: string; // Preview mode groupId
}

const VIEW_MODES = {
Expand All @@ -67,7 +67,7 @@ const renderEventContent = (
eventInfo: EventContentArg,
handleDelete: (id: string) => void,
handleEdit: (event: CalendarEvent) => void,
isReadOnly: boolean
isReadOnly: boolean,
) => {
const { event, timeText } = eventInfo;
const description = event.extendedProps?.description || "";
Expand Down Expand Up @@ -172,7 +172,7 @@ const CustomCalendar: React.FC<CustomCalendarProps> = ({
exact: true,
});
},
}
},
);
} else {
// Regular delete
Expand All @@ -188,7 +188,7 @@ const CustomCalendar: React.FC<CustomCalendarProps> = ({
previewGroupId,
queryClient,
onDeletePlan,
]
],
);

// Handle edit (open modal)
Expand Down Expand Up @@ -219,19 +219,19 @@ const CustomCalendar: React.FC<CustomCalendarProps> = ({
const updatedPlans = plans.map((plan) =>
plan.id === id
? { ...plan, title: title!, description: description! }
: plan
: plan,
);
onPlanChange(updatedPlans);
} else {
// Regular update
updatePlan({
updatePlan({
planId: Number(id),
planData: {
title: title!,
description: description!,
startDate: start!.toISOString(),
startDate: start!.toISOString(),
endDate: end!.toISOString(),
accessibility: currentEditPlan.accessibility ?? false,
accessibility: currentEditPlan.accessibility ?? false,
isCompleted: currentEditPlan.complete ?? false,
},
});
Expand All @@ -248,7 +248,7 @@ const CustomCalendar: React.FC<CustomCalendarProps> = ({
const calendarApi = calendarRef.current?.getApi();
if (calendarApi) {
calendarApi.changeView(
currentMobile ? VIEW_MODES.THREEDAY : VIEW_MODES.WEEK
currentMobile ? VIEW_MODES.THREEDAY : VIEW_MODES.WEEK,
);
}
}, []);
Expand All @@ -274,7 +274,7 @@ const CustomCalendar: React.FC<CustomCalendarProps> = ({
complete: plan.complete,
},
})),
[plans]
[plans],
);

// Handle event change (drag and drop)
Expand All @@ -287,11 +287,11 @@ const CustomCalendar: React.FC<CustomCalendarProps> = ({
start: info.event.start,
end: info.event.end,
}
: plan
: plan,
);
onPlanChange?.(updatedPlans);
},
[onPlanChange, plans]
[onPlanChange, plans],
);

return (
Expand Down Expand Up @@ -335,12 +335,7 @@ const CustomCalendar: React.FC<CustomCalendarProps> = ({
eventDrop={isReadOnly ? undefined : handleEventChange}
eventResize={handleEventChange}
eventContent={(eventInfo) =>
renderEventContent(
eventInfo,
handleDelete,
handleEdit,
isReadOnly
)
renderEventContent(eventInfo, handleDelete, handleEdit, isReadOnly)
}
selectable={false}
selectMirror={false}
Expand All @@ -366,7 +361,7 @@ const CustomCalendar: React.FC<CustomCalendarProps> = ({
value={currentEditPlan.title || ""}
onChange={(e) =>
setCurrentEditPlan((prev) =>
prev ? { ...prev, title: e.target.value } : prev
prev ? { ...prev, title: e.target.value } : prev,
)
}
/>
Expand All @@ -375,7 +370,7 @@ const CustomCalendar: React.FC<CustomCalendarProps> = ({
value={currentEditPlan.description || ""}
onChange={(e) =>
setCurrentEditPlan((prev) =>
prev ? { ...prev, description: e.target.value } : prev
prev ? { ...prev, description: e.target.value } : prev,
)
}
/>
Expand Down
15 changes: 0 additions & 15 deletions src/components/features/CustomCalendar/PlanModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,6 @@ const ModalContent = styled.div`
gap: 10px;
`;

const ModalButton = styled.button`
padding: 10px;
border: none;
background-color: #007bff;
color: white;
font-size: 1rem;
font-weight: bold;
border-radius: 4px;
cursor: pointer;
margin-top: 20px;
&:hover {
background-color: #0056b3;
}
`;

const Modal: React.FC<ModalProps> = ({ onClose, children }) => {
return (
<Overlay onClick={onClose}>
Expand Down
22 changes: 7 additions & 15 deletions src/components/features/Introduce/Introduce.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import { useNavigate } from "react-router-dom";
import circleSVG from "@/assets/circle (1).svg"; // 원형 이미지
import mockSVG from "@/assets/mock2.svg"; // 목업 이미지
import effectSVG from "@/assets/effect.svg";
import kakao from "@/assets/Login.svg";
import Button from "@/components/common/Button/Button";
import breakpoints from "@/variants/breakpoints"
import kakao_symbol from "@/assets/kakao_symbol.svg"
import breakpoints from "@/variants/breakpoints";
import kakao_symbol from "@/assets/kakao_symbol.svg";

const LandingContainer = styled.div`
max-width: 1280px;
Expand Down Expand Up @@ -103,15 +102,6 @@ const ButtonContainer = styled.div`
}
`;

const KakaoLoginButton = styled.img`
cursor: pointer;
width: 200px;
${breakpoints.tablet} {
width: 160px;
}
`;

const MockupImageWrapper = styled.div`
width: 50%;
display: flex;
Expand All @@ -134,7 +124,7 @@ const SymbolImage = styled.img`
width: 20px;
height: 20px;
padding-right: 3px;
`
`;

const Introduce = () => {
const navigate = useNavigate();
Expand All @@ -160,10 +150,12 @@ const Introduce = () => {
</AdditionalText>
<ButtonContainer>
<Button theme="kakao" size="long" onClick={handleLoginClick}>
<SymbolImage src={kakao_symbol} alt="Login"/>
<SymbolImage src={kakao_symbol} alt="Login" />
카카오 로그인
</Button>
<Button onClick={handleStartClick} size="long">시작하기</Button>
<Button onClick={handleStartClick} size="long">
시작하기
</Button>
</ButtonContainer>
</TextWrapper>
<MockupImageWrapper>
Expand Down
1 change: 1 addition & 0 deletions src/pages/Friend/FriendPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ export default function FriendListPage() {
css={searchButtonStyles}
onClick={handleSearch}
role="button"
tabIndex={0}
onKeyPress={(e) => {
if (e.key === "Enter") handleSearch();
}}
Expand Down
1 change: 0 additions & 1 deletion src/pages/TeamPlan/TeamPlan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
useLeaveTeam,
useRespondToInvitation,
useFetchInvitations,
useFetchSentInvitations,
} from "@/api/hooks/useTeam";
import useUserData from "@/api/hooks/useUserData";
import Button from "@/components/common/Button/Button";
Expand Down
4 changes: 2 additions & 2 deletions src/pages/TeamPlan/TeamPlanChange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import CustomCalendar, {
CalendarEvent,
} from "@/components/features/CustomCalendar/CustomCalendar";
import useSaveTeamPlan from "@/api/hooks/useTeamPlanSave";
import useUpdateTeamPlan from "@/api/hooks/useUpdateTeamPlan";
import useUpdateTeamPlan from "@/api/hooks/useUpdateTeamPlan";
import Button from "@/components/common/Button/Button";
import Modal from "@/components/common/Modal/Modal";
import useDeleteTeamPlan from "@/api/hooks/useDeleteTeamPlan";
import useDeleteTeamPlan from "@/api/hooks/useDeleteTeamPlan";

const PageContainer = styled.div`
max-width: 1200px;
Expand Down
10 changes: 2 additions & 8 deletions src/pages/TeamPlan/TeamPlanMaking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,9 @@ import { useNavigate } from "react-router-dom";
// import MicrophoneButton from "@/components/features/MicrophoneButton/MicrophoneButton"; // 사용되지 않으므로 주석 처리
import Button from "@/components/common/Button/Button";
import RouterPath from "@/router/RouterPath";
import {
ParticipantsContainer,
Participant,
ParticipantName,
} from "./TeamPlanDetail";
import breakpoints from "@/variants/breakpoints";
import useVoiceHook from "@/hooks/useVoiceHook";
import useGenerateDeviceId from "@/api/hooks/useGenerateDeviceId";
import { useInviteUserToTeam } from "@/api/hooks/useTeam";
// import useGenerateDeviceId from "@/api/hooks/useGenerateDeviceId";

const PlanPageContainer = styled.div`
width: 60%;
Expand Down Expand Up @@ -79,7 +73,7 @@ function MessageSilderWithAnimation() {
}

const TeamPlanMakingPage: React.FC = () => {
const { data: deviceId } = useGenerateDeviceId();
// const { data: deviceId } = useGenerateDeviceId();
const {
transcript,
setTranscript,
Expand Down
30 changes: 16 additions & 14 deletions src/pages/TeamPlan/TeamPlanSelectPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,15 @@ const TeamPlanSelectPage: React.FC = () => {
return; // 이미 캐싱된 값이 있을 경우 요청 생략
}
setIsLoading(true);
const fetchFn =
level === "light"
? fetchLightPlans
: level === "moderate"
? fetchModeratePlans
: fetchStrongPlans;

let fetchFn;
if (level === "light") {
fetchFn = fetchLightPlans;
} else if (level === "moderate") {
fetchFn = fetchModeratePlans;
} else {
fetchFn = fetchStrongPlans;
}

fetchFn(
{ deviceId, text: transcript || "기본 추천 텍스트" },
Expand Down Expand Up @@ -101,16 +104,15 @@ const TeamPlanSelectPage: React.FC = () => {
return (
<PageContainer>
<ButtonContainer>
<button onClick={() => handleFetchPlans("light")}>1 (Light)</button>
<button onClick={() => handleFetchPlans("moderate")}>
<button type="button" onClick={() => handleFetchPlans("light")}>
1 (Light)
</button>
<button type="button" onClick={() => handleFetchPlans("moderate")}>
2 (Moderate)
</button>
<button onClick={() => handleFetchPlans("strong")}>3 (Strong)</button>
<button
onClick={() =>
console.log("현재 플랜 데이터:", planCache[selectedLevel])
}
/>
<button type="button" onClick={() => handleFetchPlans("strong")}>
3 (Strong)
</button>
</ButtonContainer>

{isLoading ? (
Expand Down
24 changes: 17 additions & 7 deletions src/pages/TeamPlan/TeamPlanUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const PlanUpdate = () => {
"일정을 옮기고 크기를 조정하여 원하는대로 플랜을 수정해보세요",
];
const { state } = useLocation();
const { plans } = state || {}; // 이전 페이지에서 전달된 plans
const { plans: initialPlans } = state || {}; // 이전 페이지에서 전달된 plans
// 메시지 애니메이션과 인덱스 상태
const [currentMessageIndex, setCurrentMessageIndex] = useState(0);
const [animate, setAnimate] = useState(false);
Expand All @@ -104,7 +104,7 @@ const PlanUpdate = () => {
const [teamName, setTeamName] = useState("");
// 초기 modifiedPlans에 전달된 plans 데이터 설정
const [modifiedPlans, setModifiedPlans] = useState<CalendarEvent[]>(
plans || [],
initialPlans || [],
);
const createTeamMutation = useCreateTeam();
const savePlanMutation = useSaveTeamPlan();
Expand Down Expand Up @@ -143,13 +143,23 @@ const PlanUpdate = () => {
const teamResponse = await createTeamMutation.mutateAsync(teamName);
const teamId = teamResponse.data.id;

// 플랜들을 순차적으로 저장
for (const plan of modifiedPlans) {
await savePlanMutation.mutateAsync({
// 모든 플랜을 저장하는 비동기 작업 생성
const savePlanPromises = modifiedPlans.map((plan) =>
savePlanMutation.mutateAsync({
teamId,
plan: convertToSavePlanFormat(plan), // 변환 후 전달
});
}
}),
);

// 모든 비동기 작업을 병렬로 실행
await Promise.all(savePlanPromises);

// for (const plan of modifiedPlans) {
// await savePlanMutation.mutateAsync({
// teamId,
// plan: convertToSavePlanFormat(plan), // 변환 후 전달
// });
// }

alert("저장이 완료되었습니다!");
navigate(RouterPath.TEAM_PLAN_INVITE, { state: { teamId } });
Expand Down
2 changes: 1 addition & 1 deletion src/provider/AuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface AuthContextProps {

const AuthContext = createContext<AuthContextProps | undefined>(undefined);

export const AuthProvider = ({ children }: PropsWithChildren<{}>) => {
export const AuthProvider = ({ children }: PropsWithChildren<object>) => {
const [authState, setAuthState] = useState<AuthState>({
isAuthenticated: false,
accessToken: null,
Expand Down

0 comments on commit 9e54bd4

Please sign in to comment.