Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
FitUrRing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wss9
FitUrRing
Commits
43f6c4a3
Commit
43f6c4a3
authored
6 months ago
by
지윤 장
Browse files
Options
Downloads
Patches
Plain Diff
Fix: 데이터 없을 시 에러처리
parent
523156e6
No related branches found
No related tags found
No related merge requests found
Pipeline
#10933
failed
6 months ago
Stage: test
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
front/src/api/routineAPI.js
+8
-8
8 additions, 8 deletions
front/src/api/routineAPI.js
front/src/components/routine/List.jsx
+5
-5
5 additions, 5 deletions
front/src/components/routine/List.jsx
front/src/components/workout/VideoDetails.jsx
+11
-5
11 additions, 5 deletions
front/src/components/workout/VideoDetails.jsx
with
24 additions
and
18 deletions
front/src/api/routineAPI.js
+
8
−
8
View file @
43f6c4a3
...
@@ -21,15 +21,15 @@ async function fetchWithOptions(url, options) {
...
@@ -21,15 +21,15 @@ async function fetchWithOptions(url, options) {
}
}
}
}
// 개별 함수들을
export
// 개별 함수들을
export
const
addExerciseRecord
=
async
(
record
)
=>
{
const
addExerciseRecord
=
async
(
record
)
=>
{
return
await
fetchWithOptions
(
'
/api/routine/records
'
,
{
return
await
fetchWithOptions
(
'
/api/routine/records
'
,
{
method
:
'
POST
'
,
method
:
'
POST
'
,
body
:
JSON
.
stringify
(
record
),
body
:
JSON
.
stringify
(
record
),
});
});
};
};
export
const
getUserRoutines
=
async
()
=>
{
const
getUserRoutines
=
async
()
=>
{
try
{
try
{
const
response
=
await
fetchWithOptions
(
'
/api/routine
'
,
{
const
response
=
await
fetchWithOptions
(
'
/api/routine
'
,
{
method
:
'
GET
'
,
method
:
'
GET
'
,
...
@@ -49,7 +49,7 @@ export const getUserRoutines = async () => {
...
@@ -49,7 +49,7 @@ export const getUserRoutines = async () => {
}
}
};
};
export
const
getRoutineVideos
=
async
(
routineName
)
=>
{
const
getRoutineVideos
=
async
(
routineName
)
=>
{
try
{
try
{
const
response
=
await
fetchWithOptions
(
`/api/routine/videos?routine_name=
${
encodeURIComponent
(
routineName
)}
`
,
{
const
response
=
await
fetchWithOptions
(
`/api/routine/videos?routine_name=
${
encodeURIComponent
(
routineName
)}
`
,
{
method
:
'
GET
'
,
method
:
'
GET
'
,
...
@@ -67,14 +67,14 @@ export const getRoutineVideos = async (routineName) => {
...
@@ -67,14 +67,14 @@ export const getRoutineVideos = async (routineName) => {
}
}
};
};
export
const
createRoutine
=
async
(
routineName
)
=>
{
const
createRoutine
=
async
(
routineName
)
=>
{
return
await
fetchWithOptions
(
'
/api/routine
'
,
{
return
await
fetchWithOptions
(
'
/api/routine
'
,
{
method
:
'
POST
'
,
method
:
'
POST
'
,
body
:
JSON
.
stringify
({
routine_name
:
routineName
}),
body
:
JSON
.
stringify
({
routine_name
:
routineName
}),
});
});
};
};
export
const
deleteRoutine
=
async
(
routineName
)
=>
{
const
deleteRoutine
=
async
(
routineName
)
=>
{
return
await
fetchWithOptions
(
'
/api/routine
'
,
{
return
await
fetchWithOptions
(
'
/api/routine
'
,
{
method
:
'
DELETE
'
,
method
:
'
DELETE
'
,
body
:
JSON
.
stringify
({
routine_name
:
routineName
}),
body
:
JSON
.
stringify
({
routine_name
:
routineName
}),
...
@@ -102,4 +102,4 @@ async function addRoutineVideo(data){
...
@@ -102,4 +102,4 @@ async function addRoutineVideo(data){
}
}
export
{
addRoutineVideo
,
addExerciseRecord
,
getUserRoutines
,
getRoutineVideos
,
deleteRoutine
};
export
{
addRoutineVideo
,
addExerciseRecord
,
getUserRoutines
,
getRoutineVideos
,
createRoutine
,
deleteRoutine
};
This diff is collapsed.
Click to expand it.
front/src/components/routine/List.jsx
+
5
−
5
View file @
43f6c4a3
import
React
,
{
useState
,
useEffect
}
from
"
react
"
;
import
React
,
{
useState
,
useEffect
}
from
"
react
"
;
import
"
./List.css
"
;
import
"
./List.css
"
;
import
truncateText
from
'
./truncateText
'
;
import
truncateText
from
'
./truncateText
'
;
import
routineAPI
from
'
../../api/routineAPI
'
;
import
{
getUserRoutines
,
getRoutineVideos
,
deleteRoutine
,
createRoutine
}
from
'
../../api/routineAPI
'
;
function
List
({
onRoutineSelect
,
isActive
})
{
function
List
({
onRoutineSelect
,
isActive
})
{
const
[
routines
,
setRoutines
]
=
useState
([]);
const
[
routines
,
setRoutines
]
=
useState
([]);
...
@@ -43,12 +43,12 @@ function List({ onRoutineSelect, isActive }) {
...
@@ -43,12 +43,12 @@ function List({ onRoutineSelect, isActive }) {
// 루틴 데이터와 비디오 데이터 함께 가져오기
// 루틴 데이터와 비디오 데이터 함께 가져오기
const
fetchRoutines
=
async
()
=>
{
const
fetchRoutines
=
async
()
=>
{
try
{
try
{
const
routineData
=
await
routineAPI
.
getUserRoutines
();
const
routineData
=
await
getUserRoutines
();
if
(
routineData
)
{
if
(
routineData
)
{
// 각 루틴에 대해 비디오 정보 가져오기
// 각 루틴에 대해 비디오 정보 가져오기
const
routinesWithVideos
=
await
Promise
.
all
(
const
routinesWithVideos
=
await
Promise
.
all
(
routineData
.
map
(
async
(
routine
)
=>
{
routineData
.
map
(
async
(
routine
)
=>
{
const
videos
=
await
routineAPI
.
getRoutineVideos
(
routine
.
routine_name
);
const
videos
=
await
getRoutineVideos
(
routine
.
routine_name
);
return
{
return
{
...
routine
,
...
routine
,
exercises
:
videos
.
map
(
video
=>
({
exercises
:
videos
.
map
(
video
=>
({
...
@@ -88,7 +88,7 @@ function List({ onRoutineSelect, isActive }) {
...
@@ -88,7 +88,7 @@ function List({ onRoutineSelect, isActive }) {
const
handledelete
=
async
(
name
)
=>
{
const
handledelete
=
async
(
name
)
=>
{
try
{
try
{
await
routineAPI
.
deleteRoutine
(
name
);
await
deleteRoutine
(
name
);
setIsModalOpen
(
false
);
setIsModalOpen
(
false
);
await
fetchRoutines
();
// 삭제 후 목록 새로고침
await
fetchRoutines
();
// 삭제 후 목록 새로고침
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -101,7 +101,7 @@ function List({ onRoutineSelect, isActive }) {
...
@@ -101,7 +101,7 @@ function List({ onRoutineSelect, isActive }) {
const
routineName
=
prompt
(
"
새로운 루틴의 이름을 입력하세요:
"
);
const
routineName
=
prompt
(
"
새로운 루틴의 이름을 입력하세요:
"
);
if
(
!
routineName
)
return
;
if
(
!
routineName
)
return
;
await
routineAPI
.
createRoutine
(
routineName
);
await
createRoutine
(
routineName
);
await
fetchRoutines
();
await
fetchRoutines
();
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
루틴 추가 실패:
"
,
err
);
console
.
error
(
"
루틴 추가 실패:
"
,
err
);
...
...
This diff is collapsed.
Click to expand it.
front/src/components/workout/VideoDetails.jsx
+
11
−
5
View file @
43f6c4a3
...
@@ -30,14 +30,20 @@ function VideoDetails({video, routines}) {
...
@@ -30,14 +30,20 @@ function VideoDetails({video, routines}) {
<
span
>
{
secToTime
(
video
.
video_length
)
}
</
span
>
<
span
>
{
secToTime
(
video
.
video_length
)
}
</
span
>
<
span
><
FontAwesomeIcon
icon
=
{
faHeart
}
/>
{
video
.
video_likes
}
<
br
/></
span
>
<
span
><
FontAwesomeIcon
icon
=
{
faHeart
}
/>
{
video
.
video_likes
}
<
br
/></
span
>
</
span
>
</
span
>
<
select
name
=
"routines"
id
=
"routines"
>
{
routines
?
(
{
routines
.
map
((
item
)
=>
(
<>
<>
<
option
value
=
{
item
}
>
{
item
}
</
option
>
<
select
>
</>
{
routines
.
map
((
item
,
index
)
=>
(
<
option
key
=
{
index
}
value
=
{
item
}
>
{
item
}
</
option
>
))
}
))
}
</
select
>
</
select
>
<
button
className
=
"addbutton"
onClick
=
{
addRoutine
}
>
추가
</
button
>
<
button
className
=
"addbutton"
onClick
=
{
addRoutine
}
>
추가
</
button
>
</>
)
:
(
<
label
>
추가할 루틴이 없습니다.
</
label
>
)
}
</
div
>
</
div
>
</
div
>
</
div
>
);
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment