Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
PPL Sosial
tbcare
tbcare-web
Commits
2dc0e3f8
Commit
2dc0e3f8
authored
May 31, 2021
by
Sean Zeliq Urian
Browse files
[REFACTOR] fix code style
parent
e6616171
Changes
2
Show whitespace changes
Inline
Side-by-side
src/components/Table/index.tsx
View file @
2dc0e3f8
...
...
@@ -9,7 +9,6 @@ import Button from 'components/Button';
import
Loading
from
'
components/Loading
'
;
import
Icon
from
'
components/Icon
'
;
type
ValueType
=
string
|
number
;
interface
TableProps
{
...
...
@@ -17,10 +16,13 @@ interface TableProps {
header
:
Array
<
string
>
;
data
?:
Array
<
Array
<
ValueType
>>
;
setData
?:
any
;
onChange
?:
(
value
:
string
,
pageNumber
:
number
)
=>
Promise
<
Array
<
Array
<
ValueType
>>>
;
onChange
?:
(
value
:
string
,
pageNumber
:
number
)
=>
Promise
<
Array
<
Array
<
ValueType
>>>
;
searchPlaceholder
?:
string
;
maximumData
?:
number
;
rowOnClick
?:
(
row
:
Array
<
ValueType
>
)
=>
void
rowOnClick
?:
(
row
:
Array
<
ValueType
>
)
=>
void
;
}
const
Click
=
styled
.
div
`
...
...
@@ -68,7 +70,7 @@ const TableHeader = styled.th`
const
LoadingContainer
=
styled
.
tr
`
height: 400px;
`
`
;
const
DEFAULT_THEME
=
{
colors
:
{
...
...
@@ -124,7 +126,9 @@ export default function Table({
if
(
newData
.
length
===
0
||
newData
[
0
].
length
===
0
)
return
;
setPageNumber
(
newPageNumber
);
setPreviousDataTotal
(
previousDataTotal
+
(
sign
===
1
?
data
.
length
:
-
newData
.
length
));
setPreviousDataTotal
(
previousDataTotal
+
(
sign
===
1
?
data
.
length
:
-
newData
.
length
)
);
setData
([...
newData
]);
};
...
...
@@ -149,7 +153,7 @@ export default function Table({
initializeData
();
},
[]);
if
(
data
[
0
]
&&
(
header
.
length
>
data
[
0
].
length
)
)
{
if
(
data
[
0
]
&&
header
.
length
>
data
[
0
].
length
)
{
throw
new
Error
(
'
The shape of Header and data are not consistent
'
);
}
...
...
@@ -218,7 +222,7 @@ export default function Table({
})
}
</
tr
>
</
thead
>
{
isLoading
?
(
{
isLoading
?
(
<
tbody
>
<
LoadingContainer
>
<
Loading
isLoading
=
{
isLoading
}
shouldSetBlackTheme
=
{
true
}
/>
...
...
@@ -235,7 +239,9 @@ export default function Table({
index
%
2
===
0
?
'
transparent
'
:
colors
.
almostWhite
}
>
{
row
.
filter
((
_
,
index
)
=>
index
<
header
.
length
).
map
((
value
:
ValueType
,
index
:
number
)
=>
{
{
row
.
filter
((
_
,
index
)
=>
index
<
header
.
length
)
.
map
((
value
:
ValueType
,
index
:
number
)
=>
{
return
(
<
td
key
=
{
index
}
>
<
Text
...
...
@@ -248,7 +254,7 @@ export default function Table({
</
td
>
);
})
}
{
rowOnClick
?
(
{
rowOnClick
?
(
<
td
>
<
Box
height
=
"100%"
...
...
@@ -269,34 +275,33 @@ export default function Table({
crossAxis
=
"center"
background
=
{
colors
.
green
}
>
<
Icon
src
=
"/assets/icons/zoom.svg"
height
=
"50%"
cursor
=
"pointer"
/>
<
Icon
src
=
"/assets/icons/zoom.svg"
height
=
"50%"
cursor
=
"pointer"
/>
</
Box
>
</
Click
>
</
Box
>
</
td
>
)
:
<></>
}
)
:
(
<></>
)
}
</
Row
>
);
})
}
</
tbody
>
)
}
</
StyledTable
>
{
!
isLoading
&&
data
.
length
===
0
?
(
<
Box
width
=
"100%"
height
=
"300px"
mainAxis
=
'center'
crossAxis
=
'center'
>
<
Text
type
=
{
Text
.
StyleType
.
Medium
}
color
=
{
colors
.
mediumGray
}
>
{
!
isLoading
&&
data
.
length
===
0
?
(
<
Box
width
=
"100%"
height
=
"300px"
mainAxis
=
"center"
crossAxis
=
"center"
>
<
Text
type
=
{
Text
.
StyleType
.
Medium
}
color
=
{
colors
.
mediumGray
}
>
Tidak ada data
</
Text
>
</
Box
>
)
:
<></>
}
)
:
(
<></>
)
}
<
Gap
gap
=
{
20
}
axis
=
{
Gap
.
Axis
.
Vertical
}
/>
<
Box
width
=
"100%"
mainAxis
=
"flex-end"
>
<
Box
crossAxis
=
"center"
>
...
...
@@ -318,7 +323,10 @@ export default function Table({
transform
=
"rotateZ(180deg)"
/>
<
Gap
gap
=
{
12
}
axis
=
{
Gap
.
Axis
.
Horizontal
}
/>
<
Text
id
=
'page-number'
type
=
{
Text
.
StyleType
.
Small
}
>
{
`
${
pageNumber
}
`
}
</
Text
>
<
Text
id
=
"page-number"
type
=
{
Text
.
StyleType
.
Small
}
>
{
`
${
pageNumber
}
`
}
</
Text
>
<
Gap
gap
=
{
12
}
axis
=
{
Gap
.
Axis
.
Horizontal
}
/>
<
Icon
data-test-id
=
"next-button"
...
...
src/scenes/ActivityLog/utilities/utils.tsx
View file @
2dc0e3f8
import
{
LogDetail
}
from
'
scenes/ActivityLog/types/types
'
import
{
LogDetail
}
from
'
scenes/ActivityLog/types/types
'
;
const
generateLogMessage
=
async
(
log
:
any
,
services
:
any
)
=>
{
let
message
=
''
;
...
...
@@ -10,9 +10,7 @@ const generateLogMessage = async (log: any, services: any) => {
case
'
Create
'
:
{
if
(
accountResponse
.
status
===
200
)
{
let
username
=
accountResponse
.
data
.
username
;
let
accountType
=
accountResponse
.
data
.
is_admin
?
'
admin
'
:
'
kader
'
;
let
accountType
=
accountResponse
.
data
.
is_admin
?
'
admin
'
:
'
kader
'
;
message
=
'
Menambahkan akun
'
+
accountType
+
...
...
@@ -26,9 +24,7 @@ const generateLogMessage = async (log: any, services: any) => {
case
'
Edit
'
:
{
if
(
accountResponse
.
status
===
200
)
{
let
username
=
accountResponse
.
data
.
username
;
let
accountType
=
accountResponse
.
data
.
is_admin
?
'
admin
'
:
'
kader
'
;
let
accountType
=
accountResponse
.
data
.
is_admin
?
'
admin
'
:
'
kader
'
;
message
=
'
Memperbarui akun
'
+
accountType
+
...
...
@@ -77,7 +73,10 @@ const generateLogMessage = async (log: any, services: any) => {
return
message
;
};
const
generateLogDetail
=
async
(
log
:
any
,
services
:
any
):
Promise
<
LogDetail
>
=>
{
const
generateLogDetail
=
async
(
log
:
any
,
services
:
any
):
Promise
<
LogDetail
>
=>
{
let
logDetail
:
LogDetail
=
{
activity
:
log
.
model_name
,
authorRole
:
log
.
author
.
is_admin
?
'
admin
'
:
'
kader
'
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment