Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
a90e5a56
Commit
a90e5a56
authored
Oct 28, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete button
parent
73b95b5f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
22 deletions
+2
-22
BlocksContent.tsx
ui/blocks/BlocksContent.tsx
+2
-22
No files found.
ui/blocks/BlocksContent.tsx
View file @
a90e5a56
import
{
Box
,
Text
,
Show
,
Alert
,
Skeleton
,
Button
}
from
'
@chakra-ui/react
'
;
import
{
Box
,
Text
,
Show
,
Alert
,
Skeleton
}
from
'
@chakra-ui/react
'
;
import
{
useQuery
,
useQueryClient
}
from
'
@tanstack/react-query
'
;
import
{
useQuery
}
from
'
@tanstack/react-query
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
BlockType
,
BlocksResponse
}
from
'
types/api/block
'
;
import
type
{
BlockType
,
BlocksResponse
}
from
'
types/api/block
'
;
...
@@ -25,23 +25,6 @@ const BlocksContent = ({ type }: Props) => {
...
@@ -25,23 +25,6 @@ const BlocksContent = ({ type }: Props) => {
async
()
=>
await
fetch
(
`/api/blocks
${
type
?
`?type=
${
type
}
`
:
''
}
`
),
async
()
=>
await
fetch
(
`/api/blocks
${
type
?
`?type=
${
type
}
`
:
''
}
`
),
);
);
const
queryClient
=
useQueryClient
();
const
handleAddNewBlock
=
React
.
useCallback
(()
=>
{
queryClient
.
setQueryData
([
QueryKeys
.
blocks
,
type
],
(
prevData
:
BlocksResponse
|
undefined
)
=>
{
if
(
prevData
===
undefined
)
{
return
;
}
return
{
...
prevData
,
items
:
[
{
...
prevData
.
items
[
0
],
height
:
prevData
.
items
[
0
].
height
+
1
,
timestamp
:
(
new
Date
()).
toString
()
},
...
prevData
.
items
,
],
};
});
},
[
queryClient
,
type
]);
if
(
isLoading
)
{
if
(
isLoading
)
{
return
(
return
(
<>
<>
...
@@ -67,9 +50,6 @@ const BlocksContent = ({ type }: Props) => {
...
@@ -67,9 +50,6 @@ const BlocksContent = ({ type }: Props) => {
return
(
return
(
<>
<>
<
Text
as=
"span"
>
Total of
{
data
.
items
[
0
].
height
.
toLocaleString
()
}
blocks
</
Text
>
<
Text
as=
"span"
>
Total of
{
data
.
items
[
0
].
height
.
toLocaleString
()
}
blocks
</
Text
>
{
/* for demo purpose only to show how blocks will appear in the list */
}
{
/* remove when adding socket to update block list */
}
<
Button
display=
"inline"
size=
"sm"
ml=
{
4
}
onClick=
{
handleAddNewBlock
}
>
Add new block
</
Button
>
<
Show
below=
"lg"
key=
"content-mobile"
><
BlocksList
data=
{
data
.
items
}
/></
Show
>
<
Show
below=
"lg"
key=
"content-mobile"
><
BlocksList
data=
{
data
.
items
}
/></
Show
>
<
Show
above=
"lg"
key=
"content-desktop"
><
BlocksTable
data=
{
data
.
items
}
/></
Show
>
<
Show
above=
"lg"
key=
"content-desktop"
><
BlocksTable
data=
{
data
.
items
}
/></
Show
>
<
Box
mx=
{
{
base
:
0
,
lg
:
6
}
}
my=
{
{
base
:
6
,
lg
:
3
}
}
>
<
Box
mx=
{
{
base
:
0
,
lg
:
6
}
}
my=
{
{
base
:
6
,
lg
:
3
}
}
>
...
...
Write
Preview
Markdown
is supported
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