Skip to content
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
11 changes: 7 additions & 4 deletions .github/workflows/sonar-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,20 @@ jobs:
distribution: 'corretto'
java-version: 21
- name: Cache SonarCloud packages
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
restore-keys: |
${{ runner.os }}-sonar

- name: Cache Gradle packages
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
restore-keys: |
${{ runner.os }}-gradle-
- name: Build
run: ./backend/gradlew flywayClean flywayBaseline flywayMigrate build -Dflyway.baselineVersion=0
- name: Analyze
Expand Down
12 changes: 4 additions & 8 deletions frontend/src/pages/InterviewPage/InterviewSession.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import React, { useState, useRef, useEffect } from 'react';
import styled from '@emotion/styled';
import axios from 'axios';

const api = axios.create({
baseURL: 'http://localhost:8080',
});
import { client } from '../../apis';

const Container = styled.div`
display: flex;
Expand Down Expand Up @@ -200,7 +196,7 @@ const InterviewSession = ({

try {
const accessToken = localStorage.getItem('accessToken');
const response = await api.post(
const response = await client.post(
`/interviews/${session.id}/answers`,
{ answer: newMessage.content },
{
Expand All @@ -224,7 +220,7 @@ const InterviewSession = ({

try {
const accessToken = localStorage.getItem('accessToken');
const response = await api.post(
const response = await client.post(
`/interviews/${session.id}/restart`,
{},
{
Expand All @@ -244,7 +240,7 @@ const InterviewSession = ({

try {
const accessToken = localStorage.getItem('accessToken');
await api.post(
await client.post(
`/interviews/${session.id}/quit`,
{},
{
Expand Down
55 changes: 24 additions & 31 deletions frontend/src/pages/InterviewPage/InterviewSetup.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import React, { useEffect, useState } from 'react';
import styled from '@emotion/styled';
import axios from 'axios';

const api = axios.create({
baseURL: 'http://localhost:8080',
});
import { client } from '../../apis';

const Container = styled.div`
display: flex;
Expand Down Expand Up @@ -58,7 +54,7 @@ const SelectionContent = styled.div`
flex: 1;
min-height: 0;
overflow-y: auto;

&::-webkit-scrollbar {
width: 8px;
}
Expand Down Expand Up @@ -93,7 +89,7 @@ const Select = styled.select`
font-size: 1rem;
background-color: white;
cursor: pointer;

&:disabled {
background-color: #f8f9fa;
cursor: not-allowed;
Expand Down Expand Up @@ -198,7 +194,7 @@ const InterviewSetup = ({ onSessionStart, session }: InterviewSetupProps) => {
const fetchSessions = async () => {
try {
const accessToken = localStorage.getItem('accessToken');
const response = await api.get('/sessions/mine', {
const response = await client.get('/sessions/mine', {
headers: {
Authorization: `Bearer ${accessToken}`,
},
Expand All @@ -214,14 +210,10 @@ const InterviewSetup = ({ onSessionStart, session }: InterviewSetupProps) => {

useEffect(() => {
const fetchMissions = async () => {
if (!selectedSession) {
setMissions([]);
return;
}

if (!selectedSession) return;
try {
const accessToken = localStorage.getItem('accessToken');
const response = await api.get(`/missions/mine`, {
const response = await client.get(`/missions?sessionId=${selectedSession}`, {
headers: {
Authorization: `Bearer ${accessToken}`,
},
Expand All @@ -237,27 +229,23 @@ const InterviewSetup = ({ onSessionStart, session }: InterviewSetupProps) => {

useEffect(() => {
const fetchQuestions = async () => {
if (!selectedMission) {
setQuestions([]);
return;
}

if (!selectedMission) return;
try {
const accessToken = localStorage.getItem('accessToken');
const response = await api.get(`/questions?missionId=${selectedMission}`, {
const response = await client.get(`/questions?missionId=${selectedMission}`, {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
console.log('Questions API response:', response.data);

// API 응답 데이터 구조 확인 및 변환
const questionList = response.data.questions || response.data || [];
const formattedQuestions = questionList.map((q: any) => ({
id: q.id,
content: q.content || q.question || q.text || '',
}));

setQuestions(formattedQuestions);
} catch (error) {
console.error('Failed to fetch questions:', error);
Expand All @@ -269,21 +257,26 @@ const InterviewSetup = ({ onSessionStart, session }: InterviewSetupProps) => {
}, [selectedMission]);

const handleStartInterview = async () => {
if (!selectedQuestion) return;
if (!selectedSession || !selectedMission || !selectedQuestion) return;

setIsLoading(true);
try {
setIsLoading(true);
const accessToken = localStorage.getItem('accessToken');
const response = await api.post('/interviews', {
questionId: selectedQuestion,
}, {
headers: {
Authorization: `Bearer ${accessToken}`,
const response = await client.post(
'/interviews',
{
questionId: selectedQuestion,
},
});
{
headers: {
Authorization: `Bearer ${accessToken}`,
},
}
);
onSessionStart(response.data);
} catch (error) {
console.error('Failed to start interview:', error);
alert('인터뷰 시작에 실패했습니다.');
} finally {
setIsLoading(false);
}
Expand Down Expand Up @@ -398,4 +391,4 @@ const InterviewSetup = ({ onSessionStart, session }: InterviewSetupProps) => {
);
};

export default InterviewSetup;
export default InterviewSetup;
Loading