Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
Vũ Hoàng Anh
canifa_note
Commits
a1083e64
Commit
a1083e64
authored
Jul 28, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: fix resource display time
parent
4b415e51
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
18 deletions
+13
-18
Resources.tsx
web/src/pages/Resources.tsx
+13
-18
No files found.
web/src/pages/Resources.tsx
View file @
a1083e64
import
{
Divider
,
IconButton
,
Input
,
Tooltip
}
from
"@mui/joy"
;
import
{
Divider
,
IconButton
,
Input
,
Tooltip
}
from
"@mui/joy"
;
import
dayjs
from
"dayjs"
;
import
{
includes
}
from
"lodash-es"
;
import
{
includes
}
from
"lodash-es"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
Empty
from
"@/components/Empty"
;
import
Empty
from
"@/components/Empty"
;
...
@@ -13,22 +14,15 @@ import { Resource } from "@/types/proto/api/v1/resource_service";
...
@@ -13,22 +14,15 @@ import { Resource } from "@/types/proto/api/v1/resource_service";
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
function
groupResourcesByDate
(
resources
:
Resource
[])
{
function
groupResourcesByDate
(
resources
:
Resource
[])
{
const
grouped
=
new
Map
<
number
,
Resource
[]
>
();
const
grouped
=
new
Map
<
string
,
Resource
[]
>
();
resources
resources
.
sort
((
a
:
Resource
,
b
:
Resource
)
=>
{
.
sort
((
a
,
b
)
=>
dayjs
(
b
.
createTime
).
unix
()
-
dayjs
(
a
.
createTime
).
unix
())
const
a_date
=
new
Date
(
a
.
createTime
as
any
);
const
b_date
=
new
Date
(
b
.
createTime
as
any
);
return
b_date
.
getTime
()
-
a_date
.
getTime
();
})
.
forEach
((
item
)
=>
{
.
forEach
((
item
)
=>
{
const
date
=
new
Date
(
item
.
createTime
as
any
);
const
monthStr
=
dayjs
(
item
.
createTime
).
format
(
"YYYY-MM"
);
const
year
=
date
.
getFullYear
();
if
(
!
grouped
.
has
(
monthStr
))
{
const
month
=
date
.
getMonth
()
+
1
;
grouped
.
set
(
monthStr
,
[]);
const
timestamp
=
Date
.
UTC
(
year
,
month
-
1
,
1
);
if
(
!
grouped
.
has
(
timestamp
))
{
grouped
.
set
(
timestamp
,
[]);
}
}
grouped
.
get
(
timestamp
)?.
push
(
item
);
grouped
.
get
(
monthStr
)?.
push
(
item
);
});
});
return
grouped
;
return
grouped
;
}
}
...
@@ -101,13 +95,14 @@ const Resources = () => {
...
@@ -101,13 +95,14 @@ const Resources = () => {
</
div
>
</
div
>
)
:
(
)
:
(
<
div
className=
{
"w-full h-auto px-2 flex flex-col justify-start items-start gap-y-8"
}
>
<
div
className=
{
"w-full h-auto px-2 flex flex-col justify-start items-start gap-y-8"
}
>
{
Array
.
from
(
groupedResources
.
entries
()).
map
(([
timestamp
,
resources
])
=>
{
{
Array
.
from
(
groupedResources
.
entries
()).
map
(([
monthStr
,
resources
])
=>
{
const
date
=
new
Date
(
timestamp
);
return
(
return
(
<
div
key=
{
timestamp
}
className=
"w-full flex flex-row justify-start items-start"
>
<
div
key=
{
monthStr
}
className=
"w-full flex flex-row justify-start items-start"
>
<
div
className=
"w-16 sm:w-24 pt-4 sm:pl-4 flex flex-col justify-start items-start"
>
<
div
className=
"w-16 sm:w-24 pt-4 sm:pl-4 flex flex-col justify-start items-start"
>
<
span
className=
"text-sm opacity-60"
>
{
date
.
getFullYear
()
}
</
span
>
<
span
className=
"text-sm opacity-60"
>
{
dayjs
(
monthStr
).
year
()
}
</
span
>
<
span
className=
"font-medium text-xl"
>
{
date
.
toLocaleString
(
i18n
.
language
,
{
month
:
"short"
})
}
</
span
>
<
span
className=
"font-medium text-xl"
>
{
dayjs
(
monthStr
).
toDate
().
toLocaleString
(
i18n
.
language
,
{
month
:
"short"
})
}
</
span
>
</
div
>
</
div
>
<
div
className=
"w-full max-w-[calc(100%-4rem)] sm:max-w-[calc(100%-6rem)] flex flex-row justify-start items-start gap-4 flex-wrap"
>
<
div
className=
"w-full max-w-[calc(100%-4rem)] sm:max-w-[calc(100%-6rem)] flex flex-row justify-start items-start gap-4 flex-wrap"
>
{
resources
.
map
((
resource
)
=>
{
{
resources
.
map
((
resource
)
=>
{
...
...
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