Skip to content

Commit

Permalink
Merge pull request #70 from Teammanagers/develop
Browse files Browse the repository at this point in the history
이슈 수정
  • Loading branch information
Low-ProFiles authored Aug 23, 2024
2 parents e247fcb + 8fe9f32 commit 820dda5
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/apis/Axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import axios from 'axios';
export const Axios = axios.create({
baseURL: import.meta.env.VITE_BASE_URL,
headers: {
Authorization: `Bearer ` + import.meta.env.VITE_API_TOKEN
Authorization: `Bearer ` + localStorage.getItem('accessToken')
}
});
6 changes: 4 additions & 2 deletions src/apis/alarm/getAlarmList.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Axios } from '@apis/Axios';
import { GetTeamResponse } from 'src/types/team';

export const getAlarm = async (teamId: number): Promise<GetTeamResponse> => {
export const getAlarm = async (
teamId: number | null
): Promise<GetTeamResponse> => {
try {
const response = await Axios.get(`/api/alarm/${teamId}`, {
withCredentials: true,
Expand All @@ -12,6 +14,6 @@ export const getAlarm = async (teamId: number): Promise<GetTeamResponse> => {
});
return response.data;
} catch (error) {
throw new Error(error.response?.data?.message || 'Something went wrong');
throw new Error(error.response?.data?.message);
}
};
5 changes: 1 addition & 4 deletions src/components/alarm/alarm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const AlarmLogo: React.FC<AlarmLogoProps> = ({ type }) => {
const Alarm = ({ isAlarmOpen, toggleAlarm, setHover, data }: AlarmProps) => {
const [shouldRender, setShouldRender] = useState(isAlarmOpen);
const alarmMutation = useUpdateAlarmStatus();

const { data: team } = useQuery({
queryKey: ['team'],
queryFn: getTeamById
Expand Down Expand Up @@ -75,10 +76,6 @@ const Alarm = ({ isAlarmOpen, toggleAlarm, setHover, data }: AlarmProps) => {
alarmMutation.mutate(alarmId);
};

useEffect(() => {
alarmMutation.mutate(10);
}, []);

return (
<>
{shouldRender && (
Expand Down
12 changes: 9 additions & 3 deletions src/components/calendar/AddEventModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import { useEffect, useState } from 'react';
import { useLocation } from 'react-router-dom';
import styled from 'styled-components';
import * as Dialog from '@radix-ui/react-dialog';
Expand All @@ -13,8 +13,9 @@ import { useCalendarStore } from '@store/calendarStore';
import { useIdStore } from '@store/idStore';

const AddEventModal = ({ selectedDate, open, setOpen }: AddEventModalProps) => {
const { teamId } = useIdStore((state) => ({
teamId: state.teamId
const { teamId, setTeamId } = useIdStore((state) => ({
teamId: state.teamId,
setTeamId: state.setTeamId
}));
const location = useLocation();
const { searchMonth, setEventList, setUpcomingEventList } = useCalendarStore(
Expand Down Expand Up @@ -98,6 +99,11 @@ const AddEventModal = ({ selectedDate, open, setOpen }: AddEventModalProps) => {
});
};

useEffect(() => {
const id = localStorage.getItem('teamId');
setTeamId(Number(id));
}, [teamId]);

return (
<>
<DialogRoot open={open} onOpenChange={setOpen}>
Expand Down
9 changes: 2 additions & 7 deletions src/components/sidebar/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@ export const SideBar = () => {
const navigate = useNavigate();
const location = useLocation();

const { data, isError } = useGetAlarmList(
Number(localStorage.getItem('teamId')) || null
);
if (isError) {
return null;
}
const { result } = useGetAlarmList(Number(localStorage.getItem('teamId')));

const handleNavigate = (path: string) => {
navigate(path);
Expand Down Expand Up @@ -130,7 +125,7 @@ export const SideBar = () => {
{isAlarmOpen ? <BellClick /> : <Bell />}
{hover && <SideBarText selected={isAlarmOpen}>알림</SideBarText>}
<Alarm
data={data?.result.alarmList}
data={result?.alarmList}
isAlarmOpen={isAlarmOpen}
toggleAlarm={toggleAlarm}
setHover={setHover}
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/alarm/useGetAlarmList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getAlarm } from '@apis/alarm/getAlarmList';
import { AlarmListType } from 'src/types/alarm';

export const useGetAlarmList = (
teamId: number
teamId: number | null
): UseQueryResult<AlarmListType> => {
return useQuery({
queryKey: ['alarm', teamId],
Expand Down
4 changes: 3 additions & 1 deletion src/pages/login/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import LogoFadeIn from '@components/login/LogoFadeIn';
import { useLogoFadeIn } from '@hooks/useLogoFadeIn';
import styled from 'styled-components';
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

const Wrapper = styled.div`
height: 100vh;
Expand All @@ -11,6 +12,7 @@ const Wrapper = styled.div`
`;

export const LoginPage = () => {
const location = useLocation();
const isLogoFadeInActivate = useLogoFadeIn(3000);

useEffect(() => {
Expand All @@ -26,7 +28,7 @@ export const LoginPage = () => {

localStorage.setItem('accessToken', accessToken);
localStorage.setItem('isNewUser', isNewUser);
}, []);
}, [location]);

return (
<Wrapper>
Expand Down

0 comments on commit 820dda5

Please sign in to comment.