Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vcci-news-frontend
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-frontend
Commits
def48755
Commit
def48755
authored
Oct 06, 2026
by
Phạm Quang Bảo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: datetime
parent
1a4b0cb4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
11 deletions
+26
-11
query-client.ts
src/api/config/query-client.ts
+1
-1
admin-news-form-content.tsx
...p/admin/news/[id]/_components/admin-news-form-content.tsx
+7
-7
datetime.ts
src/lib/utils/datetime.ts
+18
-3
No files found.
src/api/config/query-client.ts
View file @
def48755
...
...
@@ -47,7 +47,7 @@ export const queryClient = new QueryClient({
staleTime
:
API_QUERY_STALE_TIME
,
gcTime
:
API_QUERY_GC_TIME
,
refetchOnWindowFocus
:
false
,
refetchOnMount
:
false
,
refetchOnMount
:
"always"
,
refetchOnReconnect
:
false
,
placeholderData
:
(
previousData
:
unknown
)
=>
previousData
,
retry
(
failureCount
,
error
)
{
...
...
src/app/admin/news/[id]/_components/admin-news-form-content.tsx
View file @
def48755
...
...
@@ -65,7 +65,7 @@ import {
slugifyAdminNews
,
}
from
"@/lib/utils/admin-news"
;
import
{
normalizeUser
}
from
"@/lib/utils/cms-user"
;
import
{
normalizeDateTimeInput
}
from
"@/lib/utils/datetime"
;
import
{
normalizeDateTimeInput
,
toIsoWithLocalOffset
}
from
"@/lib/utils/datetime"
;
import
{
parsePostContent
,
parseLegacyPostContent
}
from
"@/lib/utils/post-content"
;
import
links
from
"@/links"
;
import
type
{
HeaderCategoryTreeItem
}
from
"@/api/vcci-news/types/header-config"
;
...
...
@@ -607,16 +607,16 @@ export function AdminNewsFormContent() {
is_featured
:
form
.
type
===
"tintuc"
?
form
.
is_featured
:
false
,
is_hidden
:
form
.
is_hidden
,
is_active
:
!
form
.
is_hidden
,
published_at
:
form
.
published_at
||
null
,
expired_at
:
form
.
expired_at
||
null
,
started_at
:
form
.
started_at
||
null
,
ended_at
:
form
.
ended_at
||
null
,
registration_deadline
:
form
.
registration_deadline
||
null
,
published_at
:
toIsoWithLocalOffset
(
form
.
published_at
)
,
expired_at
:
toIsoWithLocalOffset
(
form
.
expired_at
)
,
started_at
:
toIsoWithLocalOffset
(
form
.
started_at
)
,
ended_at
:
toIsoWithLocalOffset
(
form
.
ended_at
)
,
registration_deadline
:
toIsoWithLocalOffset
(
form
.
registration_deadline
)
,
location
:
form
.
location
.
trim
()
||
null
,
participation_fee
:
form
.
participation_fee
.
trim
()
||
null
,
event_dates
:
(
form
.
event_dates
??
[]).
length
>
0
?
form
.
event_dates
:
null
,
release_mode
:
form
.
published_at
?
"SCHEDULED"
:
"NOW"
,
release_at
:
form
.
published_at
||
null
,
release_at
:
toIsoWithLocalOffset
(
form
.
published_at
)
,
content_structure
:
{
post_content
:
form
.
post_content
.
map
((
section
,
index
)
=>
({
...
section
,
...
...
src/lib/utils/datetime.ts
View file @
def48755
import
dayjs
from
"dayjs"
;
/**
* Normalize a datetime string for use in datetime-local inputs.
* Trims to 16 characters (YYYY-MM-DDTHH:mm) if longer.
* Normalize a datetime string from the API (ISO 8601, e.g. "2026-10-22T03:00:00.000Z")
* for use in datetime-local inputs: convert to the browser's local timezone
* and format as YYYY-MM-DDTHH:mm.
*/
export
function
normalizeDateTimeInput
(
value
?:
string
|
null
):
string
{
if
(
!
value
)
return
""
;
return
value
.
length
>=
16
?
value
.
slice
(
0
,
16
)
:
value
;
const
parsed
=
dayjs
(
value
);
return
parsed
.
isValid
()
?
parsed
.
format
(
"YYYY-MM-DDTHH:mm"
)
:
""
;
}
/**
* Convert a datetime-local value (YYYY-MM-DDTHH:mm) to an ISO string that
* carries the browser's UTC offset (e.g. "2026-10-22T10:00:00+07:00"), so the
* backend parses the intended instant regardless of the server's timezone.
*/
export
function
toIsoWithLocalOffset
(
value
?:
string
|
null
):
string
|
null
{
if
(
!
value
)
return
null
;
const
parsed
=
dayjs
(
value
);
return
parsed
.
isValid
()
?
parsed
.
format
()
:
null
;
}
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