Commit b083c86b authored by Phạm Quang Bảo's avatar Phạm Quang Bảo

[tag]0.1-vcci

parents c39267e1 def48755
Pipeline #53497 passed with stages
in 1 minute and 54 seconds
......@@ -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) {
......
......@@ -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,
......
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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment