Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PB138 - Film Database Group Project
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tomáš Havlíček
PB138 - Film Database Group Project
Commits
81141660
There was an error fetching the commit references. Please try again later.
Commit
81141660
authored
2 years ago
by
Martin Korec
Browse files
Options
Downloads
Patches
Plain Diff
fix: add fetch from api
parent
19be1ffe
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/components/MoviePage.tsx
+37
-30
37 additions, 30 deletions
frontend/src/components/MoviePage.tsx
with
37 additions
and
30 deletions
frontend/src/components/MoviePage.tsx
+
37
−
30
View file @
81141660
import
{
Badge
,
Descriptions
,
Image
}
from
"
antd
"
;
import
React
from
"
react
"
;
import
React
,
{
useEffect
,
useState
}
from
"
react
"
;
import
{
Link
,
useParams
}
from
"
react-router-dom
"
;
import
{
MovieIO
}
from
"
./Preview
"
;
import
{
DirectorIO
,
MovieIO
}
from
"
./Preview
"
;
import
axios
from
'
axios
'
;
export
const
MoviePage
=
()
=>
{
const
{
id
,
name
}
=
useParams
();
//replace this with /channel/${id} API call
const
exampleMovie
:
MovieIO
=
{
id
:
"
789
"
,
name
:
"
Saw
"
,
originalName
:
"
Saw
"
,
intro
:
"
Jigsaw is the bad guy and this is the game
"
,
picture
:
"
https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftse3.mm.bing.net%2Fth%3Fid%3DOIP.Jo6M-3oyAlMsB4-F__Z9bwHaHa%26pid%3DApi&f=1
"
,
published
:
"
1.1.2000
"
,
runtimeMinutes
:
120
,
director
:
{
id
:
"
123456789
"
,
name
:
"
Karel
"
,
surname
:
"
Vomacka
"
,
birthdate
:
"
20.2.1987
"
,
},
};
const
instance
=
axios
.
create
({
baseURL
:
'
http://127.0.0.1:4000/movies/
'
,
});
const
[
movie
,
setMovie
]
=
useState
<
MovieIO
>
(
Object
);
const
[
director
,
setDirector
]
=
useState
<
DirectorIO
>
(
Object
);
useEffect
(()
=>
{
const
fetchMovie
=
async
()
=>
{
try
{
const
response
=
await
instance
.
get
(
id
as
string
);
setMovie
(
response
.
data
);
if
(
response
.
data
.
director
)
{
setDirector
(
response
.
data
.
director
);
}
}
catch
(
err
)
{
}
}
fetchMovie
();
},
[])
return
(
<>
<
Descriptions
title
=
{
exampleM
ovie
.
name
}
title
=
{
m
ovie
.
name
}
bordered
style
=
{
{
padding
:
"
5%
"
}
}
>
<
Descriptions
.
Item
label
=
"Title picture"
span
=
{
3
}
>
<
Image
src
=
{
exampleM
ovie
.
picture
}
></
Image
>
<
Image
src
=
{
m
ovie
.
picture
}
></
Image
>
</
Descriptions
.
Item
>
<
Descriptions
.
Item
label
=
"Name"
span
=
{
2
}
>
{
exampleM
ovie
.
name
}
{
m
ovie
.
name
}
</
Descriptions
.
Item
>
<
Descriptions
.
Item
label
=
"Original Name"
>
{
exampleM
ovie
.
originalName
}
{
m
ovie
.
originalName
}
</
Descriptions
.
Item
>
<
Descriptions
.
Item
label
=
"Description"
span
=
{
3
}
>
{
exampleM
ovie
.
intro
}
{
m
ovie
.
intro
}
</
Descriptions
.
Item
>
<
Descriptions
.
Item
label
=
"Published"
>
{
exampleM
ovie
.
published
}
{
m
ovie
.
published
At
}
</
Descriptions
.
Item
>
<
Descriptions
.
Item
label
=
"Runtime"
span
=
{
2
}
>
{
exampleM
ovie
.
run
t
imeMinutes
}
minutes
{
m
ovie
.
run
T
imeMinutes
}
minutes
</
Descriptions
.
Item
>
</
Descriptions
>
<
Descriptions
title
=
"Director"
bordered
style
=
{
{
padding
:
"
5%
"
}
}
>
<
Descriptions
.
Item
label
=
"Name"
span
=
{
3
}
>
<
Link
to
=
{
`/director/
${
exampleMovie
.
director
.
id
}
`
}
>
{
exampleMovie
.
director
.
name
}
{
exampleMovie
.
director
.
surname
}
<
Link
to
=
{
`/director/
${
director
.
id
}
`
}
>
{
director
.
name
}
{
director
.
surname
}
</
Link
>
</
Descriptions
.
Item
>
<
Descriptions
.
Item
label
=
"Birthdate"
>
{
exampleMovie
.
director
.
birthdate
}
{
director
.
birthdate
}
</
Descriptions
.
Item
>
</
Descriptions
>
</>
...
...
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