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
5923b712
There was an error fetching the commit references. Please try again later.
Commit
5923b712
authored
2 years ago
by
Lukáš Kratochvíl
Browse files
Options
Downloads
Patches
Plain Diff
fix: BrowseDirectors - birthdate sorting, indentation
parent
017e2d08
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/BrowseDirectors.tsx
+52
-65
52 additions, 65 deletions
frontend/src/components/BrowseDirectors.tsx
with
52 additions
and
65 deletions
frontend/src/components/BrowseDirectors.tsx
+
52
−
65
View file @
5923b712
import
{
Space
,
Card
,
Table
}
from
"
antd
"
;
import
React
from
"
react
"
import
{
Space
,
Table
}
from
"
antd
"
;
import
{
Link
}
from
"
react-router-dom
"
;
import
{
DirectorIO
}
from
"
./Preview
"
...
...
@@ -30,71 +29,59 @@ const exampleDirectors: DirectorIO[] = [{
},
]
export
const
BrowseDirectors
=
()
=>
{
const
columns
=
[
{
title
:
"
Name
"
,
dataIndex
:
"
name
"
,
sorter
:
(
a
:
DirectorIO
,
b
:
DirectorIO
)
=>
{
//surname has higher priority
if
(
a
.
surname
<
b
.
surname
){
return
-
1
;}
if
(
a
.
surname
>
b
.
surname
){
return
1
;}
if
(
a
.
name
<
b
.
name
){
return
-
1
;}
if
(
a
.
name
>
b
.
name
){
return
1
;}
return
0
;
},
render
:
(
text
:
string
,
record
:
DirectorIO
)
=>
(
<
Link
to
=
{
`/director/
${
record
.
id
}
`
}
>
<
a
>
{
record
.
name
}
{
record
.
surname
}
</
a
>
</
Link
>
),
},
const
columns
=
[
{
title
:
"
Name
"
,
dataIndex
:
"
name
"
,
sorter
:
(
a
:
DirectorIO
,
b
:
DirectorIO
)
=>
{
//surname has higher priority
if
(
a
.
surname
<
b
.
surname
)
{
return
-
1
;}
if
(
a
.
surname
>
b
.
surname
)
{
return
1
;}
{
title
:
"
Birthdate
"
,
className
:
"
birthdate
"
,
dataIndex
:
"
birthdate
"
,
sorter
:
(
a
:
DirectorIO
,
b
:
DirectorIO
)
=>
{
const
first
=
a
.
birthdate
.
split
(
'
.
'
).
reverse
();
const
second
=
b
.
birthdate
.
split
(
'
.
'
).
reverse
();
if
(
first
[
0
]
>
second
[
0
]){
return
1
;}
if
(
first
[
0
]
<
second
[
0
]){
return
-
1
;}
if
(
first
[
1
]
>
second
[
1
]){
return
1
;}
if
(
first
[
1
]
<
second
[
1
]){
return
-
1
;}
if
(
first
[
2
]
>
second
[
2
]){
return
1
;}
if
(
first
[
2
]
<
second
[
2
]){
return
-
1
;}
return
0
;},
}
];
if
(
a
.
name
<
b
.
name
)
{
return
-
1
;}
if
(
a
.
name
>
b
.
name
)
{
return
1
;}
return
0
;
},
render
:
(
text
:
string
,
record
:
DirectorIO
)
=>
(
<
Link
to
=
{
`/director/
${
record
.
id
}
`
}
>
<
a
>
{
record
.
name
}
{
record
.
surname
}
</
a
>
</
Link
>
),
},
{
title
:
"
Birthdate
"
,
className
:
"
birthdate
"
,
dataIndex
:
"
birthdate
"
,
sorter
:
(
a
:
DirectorIO
,
b
:
DirectorIO
)
=>
{
const
first
=
a
?.
birthdate
?.
split
(
'
.
'
).
reverse
();
const
second
=
b
?.
birthdate
?.
split
(
'
.
'
).
reverse
();
if
(
first
===
undefined
&&
second
===
undefined
)
{
return
0
;
}
if
(
first
===
undefined
)
{
return
1
;}
if
(
second
===
undefined
)
{
return
-
1
;}
if
(
first
[
0
]
>
second
[
0
])
{
return
1
;}
if
(
first
[
0
]
<
second
[
0
])
{
return
-
1
;}
if
(
first
[
1
]
>
second
[
1
])
{
return
1
;}
if
(
first
[
1
]
<
second
[
1
])
{
return
-
1
;}
if
(
first
[
2
]
>
second
[
2
])
{
return
1
;}
if
(
first
[
2
]
<
second
[
2
])
{
return
-
1
;}
return
0
;
},
}
];
return
(
<
div
className
=
"browse-container"
>
<
Space
direction
=
"vertical"
size
=
"middle"
style
=
{
{
padding
:
"
4%
"
}
}
>
<
Table
columns
=
{
columns
}
dataSource
=
{
exampleDirectors
}
>
</
Table
>
</
Space
>
</
div
>
);
}
\ No newline at end of file
return
(
<
div
className
=
"browse-container"
>
<
Space
direction
=
"vertical"
size
=
"middle"
style
=
{
{
padding
:
"
4%
"
}
}
>
<
Table
columns
=
{
columns
}
dataSource
=
{
exampleDirectors
}
/>
</
Space
>
</
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