Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Sprint 생성시, 날짜가 앞당겨지는 문제 해결 #218

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions apps/client/src/features/project/board/useBoardStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ const handleTaskUpdated = (sections: TSection[], event: TaskEvent): TSection[] =
};

const handleTitleInserted = (sections: TSection[], event: TaskEvent): TSection[] => {
// 실제 task 내의 title 의 특정 부분에 event에 발생한 것을 추가해야 함
return sections.map((section) => {
const task = section.tasks.find((t) => t.id === event.task.id);

Expand All @@ -203,7 +202,6 @@ const handleTitleInserted = (sections: TSection[], event: TaskEvent): TSection[]
};

const handleTitleDeleted = (sections: TSection[], event: TaskEvent): TSection[] => {
// 실제 task 내의 title 의 특정 부분에 event에 발생한 것을 삭제해야 함
return sections.map((section) => {
const task = section.tasks.find((t) => t.id === event.task.id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,18 @@ export function CreateSprint({ createMutation }: CreateProjectSprintProps) {
mutate(
{
name: data.name.trim(),
startDate: data.dateRange.from.toISOString().split('T')[0],
endDate: data.dateRange.to.toISOString().split('T')[0],
startDate: dateToYYYYMMDD(data.dateRange.from),
endDate: dateToYYYYMMDD(data.dateRange.to),
},
{ onSuccess, onError }
);
};

const dateToYYYYMMDD = (date: Date) => {
const [year, month, day] = date.toLocaleDateString().replace(/\./g, '').split(' ');
return `${year}-${month}-${day}`;
};

const onSuccess = () => {
toast.success('Sprint created successfully');
setValue('name', '');
Expand Down
16 changes: 14 additions & 2 deletions apps/client/src/lib/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,30 @@ axiosInstance.interceptors.request.use(
);

/* eslint no-underscore-dangle: 0 */
let isRefreshing = false;

axiosInstance.interceptors.response.use(
(response) => Promise.resolve(response),
async (error) => {
if (error.response?.status !== 401 || error.config.url === '/auth/refresh') {
if (error.response?.status !== 401 || error.config.url === '/auth/refresh' || isRefreshing) {
return Promise.reject(error);
}

try {
isRefreshing = true;
const response = await axiosInstance.post('/auth/refresh');

if (response.status !== 200) {
throw new Error('Refresh token failed');
}

const { username, accessToken, profileImage } = response.data.result;
const authStorage: AuthState = { accessToken, isAuthenticated: true, username, profileImage };
const authStorage: AuthState = {
accessToken,
isAuthenticated: true,
username,
profileImage,
};

localStorage.setItem(AUTH_STORAGE_KEY, JSON.stringify(authStorage));

Expand All @@ -57,7 +66,10 @@ axiosInstance.interceptors.response.use(
return axiosInstance(newConfig);
} catch {
localStorage.removeItem(AUTH_STORAGE_KEY);
window.location.href = '/login'; // 로그인 페이지로 리다이렉트
return Promise.reject(error);
} finally {
isRefreshing = false;
}
}
);