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
ccfc6467
There was an error fetching the commit references. Please try again later.
Commit
ccfc6467
authored
2 years ago
by
Martin Korec
Browse files
Options
Downloads
Patches
Plain Diff
fix: changed Preview.tsx to fetch movies from API
parent
0276d623
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/Preview.tsx
+28
-104
28 additions, 104 deletions
frontend/src/components/Preview.tsx
with
28 additions
and
104 deletions
frontend/src/components/Preview.tsx
+
28
−
104
View file @
ccfc6467
...
@@ -11,8 +11,9 @@ import {
...
@@ -11,8 +11,9 @@ import {
}
from
"
antd
"
;
}
from
"
antd
"
;
import
Meta
from
"
antd/lib/card/Meta
"
;
import
Meta
from
"
antd/lib/card/Meta
"
;
import
Title
from
"
antd/lib/skeleton/Title
"
;
import
Title
from
"
antd/lib/skeleton/Title
"
;
import
React
from
"
react
"
;
import
React
,
{
useEffect
,
useState
}
from
"
react
"
;
import
{
Link
}
from
"
react-router-dom
"
;
import
{
Link
}
from
"
react-router-dom
"
;
import
axiosConfig
from
"
../axios-config
"
;
const
contentStyle
:
React
.
CSSProperties
=
{
const
contentStyle
:
React
.
CSSProperties
=
{
height
:
"
320px
"
,
height
:
"
320px
"
,
...
@@ -46,106 +47,6 @@ export interface DirectorIO {
...
@@ -46,106 +47,6 @@ export interface DirectorIO {
birthDate
?:
string
;
birthDate
?:
string
;
}
}
//example - TODO replace this with API preview call - get POPULAR movies (probably 6 is enough)
export
const
cardsDataExample
:
MovieIO
[]
=
[
{
id
:
"
1
"
,
originalName
:
"
Cars
"
,
name
:
"
Auta
"
,
intro
:
"
auta ve filmu
"
,
publishedAt
:
"
7.8.2005
"
,
runTimeMinutes
:
125
,
director
:
{
id
:
"
xd123
"
,
name
:
"
Kenny
"
,
surname
:
"
Omega
"
,
birthDate
:
"
9.9.1980
"
,
},
picture
:
"
https://upload.wikimedia.org/wikipedia/en/3/34/Cars_2006.jpg
"
,
},
{
id
:
"
2
"
,
originalName
:
"
Monster House
"
,
name
:
"
V tom domě straší
"
,
intro
:
"
jo ten dum je docela spooky
"
,
publishedAt
:
"
4.4.1994
"
,
runTimeMinutes
:
80
,
picture
:
"
https://images-na.ssl-images-amazon.com/images/S/pv-target-images/9a996123e0b01f618ab2291b479f9d5034de354b2d1bb58979ddc6937588dfa8._RI_V_TTW_.jpg
"
,
director
:
{
id
:
"
xp234
"
,
name
:
"
Bray
"
,
surname
:
"
Wyatt
"
,
birthDate
:
"
unknown
"
,
},
},
{
id
:
"
3
"
,
originalName
:
"
Pokemon
"
,
name
:
"
Pokémon
"
,
intro
:
"
Gotta catch them all.
"
,
publishedAt
:
"
9.9.1970
"
,
runTimeMinutes
:
600
,
picture
:
"
https://www.obchod.crew.cz/im/coc/1280/0/content/629080/cover_image.1607432614.jpg
"
,
director
:
{
id
:
"
xc456
"
,
name
:
"
Kazuchika
"
,
surname
:
"
Okada
"
,
birthDate
:
"
17.2.1984
"
,
},
},
{
id
:
"
4
"
,
originalName
:
"
Gympl
"
,
name
:
"
Gympl
"
,
intro
:
"
VO SEDUMNÁCT METRŮ?
"
,
publishedAt
:
"
2.2.2005
"
,
runTimeMinutes
:
96
,
picture
:
"
https://img.csfd.cz/files/images/user/profile/162/847/162847510_91e839.jpg
"
,
director
:
{
id
:
"
xs789
"
,
name
:
"
Tomáš
"
,
surname
:
"
Vorel
"
,
birthDate
:
"
někdy minulé století
"
,
},
},
{
id
:
"
5
"
,
originalName
:
"
Toy Story
"
,
name
:
"
Příběh hraček
"
,
intro
:
"
Hmm the floor here is made of floor
"
,
publishedAt
:
"
4.5.1999
"
,
runTimeMinutes
:
90
,
picture
:
"
https://m.media-amazon.com/images/M/MV5BMDU2ZWJlMjktMTRhMy00ZTA5LWEzNDgtYmNmZTEwZTViZWJkXkEyXkFqcGdeQXVyNDQ2OTk4MzI@._V1_.jpg
"
,
director
:
{
id
:
"
xl753
"
,
name
:
"
Tomohiro
"
,
surname
:
"
Ishii
"
,
birthDate
:
"
19.9.1970
"
,
},
},
{
id
:
"
6
"
,
name
:
"
Smoke
"
,
originalName
:
"
Kouř
"
,
intro
:
"
Jedu dál stále s tebou víme kam cesty vedou je to fajn fajn fajn je to fajn fajnový
"
,
publishedAt
:
"
17.11.1989
"
,
runTimeMinutes
:
50
,
picture
:
"
https://img.csfd.cz/files/images/user/profile/164/556/164556101_d8e43b.jpg
"
,
director
:
{
id
:
"
xx787
"
,
name
:
"
Zdenda
"
,
surname
:
"
Pohlreich
"
,
birthDate
:
"
4.4.1985
"
,
},
},
];
//example - TODO replace this with API preview call - get RECENT movies (probably 6-7 is enough)
//example - TODO replace this with API preview call - get RECENT movies (probably 6-7 is enough)
export
const
cardsDataExample2
:
MovieIO
[]
=
[
export
const
cardsDataExample2
:
MovieIO
[]
=
[
{
{
...
@@ -246,7 +147,30 @@ export const cardsDataExample2: MovieIO[] = [
...
@@ -246,7 +147,30 @@ export const cardsDataExample2: MovieIO[] = [
},
},
];
];
const
Preview
:
React
.
FC
=
()
=>
(
export
const
Preview
:
React
.
FC
=
()
=>
{
const
[
movies
,
setMovies
]
=
useState
<
MovieIO
[]
>
([]);
const
[
isError
,
setIsError
]
=
useState
<
boolean
>
(
false
);
useEffect
(()
=>
{
const
fetchCategories
=
async
()
=>
{
try
{
const
response
=
await
axiosConfig
.
get
(
"
movies?mostRecentCnt=6
"
);
setMovies
(
response
.
data
);
}
catch
(
err
)
{
setIsError
(
true
);
}
}
void
fetchCategories
();
},
[])
if
(
isError
)
{
return
<
h3
>
Something went wrong…
</
h3
>;
}
return
(
<
Space
<
Space
className
=
"preview"
className
=
"preview"
direction
=
"vertical"
direction
=
"vertical"
...
@@ -254,7 +178,7 @@ const Preview: React.FC = () => (
...
@@ -254,7 +178,7 @@ const Preview: React.FC = () => (
>
>
<
Card
title
=
"Editor's picks"
>
<
Card
title
=
"Editor's picks"
>
<
Row
justify
=
"space-evenly"
gutter
=
{
50
}
>
<
Row
justify
=
"space-evenly"
gutter
=
{
50
}
>
{
cardsDataExample
.
map
((
movie
)
=>
{
{
movies
.
map
((
movie
)
=>
{
return
(
return
(
<
Col
flex
=
{
1
}
>
<
Col
flex
=
{
1
}
>
<
Link
to
=
{
`/movie/
${
movie
.
id
}
`
}
>
<
Link
to
=
{
`/movie/
${
movie
.
id
}
`
}
>
...
@@ -297,6 +221,6 @@ const Preview: React.FC = () => (
...
@@ -297,6 +221,6 @@ const Preview: React.FC = () => (
</
Space
>
</
Space
>
</
Card
>
</
Card
>
</
Space
>
</
Space
>
);
)
}
;
export
default
Preview
;
export
default
Preview
;
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