Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
VCCI-News
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ăn Hoàng
VCCI-News
Commits
911d1d03
Commit
911d1d03
authored
May 19, 2026
by
Lê Bảo Hồng Đức
☄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
2902be94
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
864 additions
and
650 deletions
+864
-650
index.tsx
src/app/(main)/(home)/components/events-calendar/index.tsx
+209
-76
use-home-posts.ts
src/app/(main)/(home)/lib/use-home-posts.ts
+83
-2
categories.ts
src/mockdata/categories.ts
+572
-572
No files found.
src/app/(main)/(home)/components/events-calendar/index.tsx
View file @
911d1d03
This diff is collapsed.
Click to expand it.
src/app/(main)/(home)/lib/use-home-posts.ts
View file @
911d1d03
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
import
*
as
React
from
"react"
;
import
*
as
React
from
"react"
;
import
{
useQuery
}
from
"@tanstack/react-query"
;
import
{
useQuery
}
from
"@tanstack/react-query"
;
import
dayjs
from
"dayjs"
;
import
{
useCustomClient
}
from
"@/api/mutator/custom-client"
;
import
{
useCustomClient
}
from
"@/api/mutator/custom-client"
;
import
Links
,
{
resolveUploadUrl
}
from
"@/links"
;
import
Links
,
{
resolveUploadUrl
}
from
"@/links"
;
...
@@ -83,7 +84,7 @@ export type HomePostItem = {
...
@@ -83,7 +84,7 @@ export type HomePostItem = {
}
|
null
;
}
|
null
;
};
};
const
HOME_POSTS_QUERY_KEY
=
[
"home-page-posts"
,
"
event-calendar-v1
"
]
as
const
;
const
HOME_POSTS_QUERY_KEY
=
[
"home-page-posts"
,
"
featured-page-size-3
"
]
as
const
;
const
HOME_CATEGORY_NAMES
=
{
const
HOME_CATEGORY_NAMES
=
{
tinVcci
:
"Tin VCCI"
,
tinVcci
:
"Tin VCCI"
,
...
@@ -251,10 +252,29 @@ function createCategoryPostsQuery(categoryId: string, pageSize: string) {
...
@@ -251,10 +252,29 @@ function createCategoryPostsQuery(categoryId: string, pageSize: string) {
});
});
}
}
function
createEventCalendarQuery
(
currentMonth
:
Date
)
{
const
monthStart
=
new
Date
(
currentMonth
.
getFullYear
(),
currentMonth
.
getMonth
(),
1
);
const
monthEnd
=
new
Date
(
currentMonth
.
getFullYear
(),
currentMonth
.
getMonth
()
+
1
,
0
,
23
,
59
,
59
,
999
);
return
new
URLSearchParams
({
sortField
:
"registration_deadline"
,
sortOrder
:
"asc"
,
filters
:
[
`category.id==(
${
HOME_CATEGORY_IDS
.
suKien
}
|
${
HOME_CATEGORY_IDS
.
daoTao
}
)`
,
`registration_deadline>=
${
dayjs
(
monthStart
).
format
(
"YYYY-MM-DD HH:mm:ss"
)}
`
,
`registration_deadline<=
${
dayjs
(
monthEnd
).
format
(
"YYYY-MM-DD HH:mm:ss"
)}
`
,
"is_hidden==false"
,
"is_active==true"
,
"status==published"
,
"type==news"
,
].
join
(
","
),
});
}
async
function
fetchHomePosts
()
{
async
function
fetchHomePosts
()
{
const
featuredQuery
=
new
URLSearchParams
({
const
featuredQuery
=
new
URLSearchParams
({
page
:
"1"
,
page
:
"1"
,
pageSize
:
"
10
"
,
pageSize
:
"
3
"
,
sortField
:
"release_at"
,
sortField
:
"release_at"
,
sortOrder
:
"desc"
,
sortOrder
:
"desc"
,
filters
:
[
filters
:
[
...
@@ -517,3 +537,64 @@ export function useHomePosts() {
...
@@ -517,3 +537,64 @@ export function useHomePosts() {
categoryNames
:
HOME_CATEGORY_NAMES
,
categoryNames
:
HOME_CATEGORY_NAMES
,
};
};
}
}
export
function
useEventCalendarPosts
(
currentMonth
:
Date
)
{
const
query
=
useQuery
({
queryKey
:
[
"event-calendar-posts"
,
currentMonth
.
getFullYear
(),
currentMonth
.
getMonth
()],
queryFn
:
async
()
=>
{
const
queryParams
=
createEventCalendarQuery
(
currentMonth
);
const
response
=
await
useCustomClient
<
HomeEnvelope
<
HomePagedResult
<
RawHomePost
>>>
(
`/post?
${
queryParams
.
toString
()}
`
,
);
return
(
response
.
responseData
?.
rows
??
[]).
map
((
item
)
=>
{
const
categories
=
(
item
.
categories
??
[])
.
filter
((
category
)
=>
category
?.
id
&&
category
?.
name
)
.
map
((
category
)
=>
({
id
:
String
(
category
.
id
),
name
:
String
(
category
.
name
),
slug
:
String
(
category
.
slug
??
""
),
url
:
normalizeLink
(
category
.
url
,
"#"
),
type
:
String
(
category
.
type
??
""
),
}));
const
thumbnailPath
=
item
.
thumbnail
?.
path
??
item
.
thumbnail
?.
original
??
null
;
const
title
=
String
(
item
.
title
??
""
).
trim
();
const
externalLink
=
normalizeLink
(
item
.
external_link
||
(
title
?
`/
${
title
}
`
:
undefined
),
"#"
,
);
return
{
id
:
String
(
item
.
id
??
""
),
title
,
externalLink
,
summary
:
String
(
item
.
summary
??
item
.
content
??
""
),
createdAt
:
String
(
item
.
created_at
??
""
),
publishedAt
:
String
(
item
.
published_at
??
item
.
release_at
??
item
.
created_at
??
""
),
startedAt
:
String
(
item
.
started_at
??
""
),
endedAt
:
String
(
item
.
ended_at
??
""
),
registrationDeadline
:
String
(
item
.
registration_deadline
??
""
),
location
:
String
(
item
.
location
??
""
),
participationFee
:
String
(
item
.
participation_fee
??
""
),
expiredAt
:
String
(
item
.
expired_at
??
""
),
isFeatured
:
Boolean
(
item
.
is_featured
),
isHidden
:
Boolean
(
item
.
is_hidden
),
isActive
:
item
.
is_active
!==
false
,
status
:
String
(
item
.
status
??
""
),
type
:
String
(
item
.
type
??
""
),
categories
,
thumbnail
:
thumbnailPath
?
{
url
:
resolveAssetUrl
(
thumbnailPath
),
alt
:
title
,
}
:
null
,
}
satisfies
HomePostItem
;
});
},
staleTime
:
5
*
60
*
1000
,
});
return
query
;
}
src/mockdata/categories.ts
View file @
911d1d03
This diff is collapsed.
Click to expand it.
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