refactor(posts): encode scheduled_at for API via date helper
Parse datetime-local values in the user timezone before converting to UTC, matching formatUtcForDateTimeLocalInput. Fix ESLint import order in usePostCompliance. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
df35d1b671
commit
35051350c6
3 changed files with 14 additions and 4 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { computed, type ComputedRef, type Ref } from 'vue';
|
||||
import { trans } from 'laravel-vue-i18n';
|
||||
import { computed, type ComputedRef, type Ref } from 'vue';
|
||||
|
||||
import { getMediaItemIssue, type MediaItem } from '@/composables/useMedia';
|
||||
import { getMediaRulesForContentType } from '@/composables/useMediaRules';
|
||||
|
|
|
|||
|
|
@ -176,6 +176,18 @@ export default {
|
|||
return dayjs.utc(date).tz(getUserTimezone()).format('YYYY-MM-DDTHH:mm:00');
|
||||
},
|
||||
|
||||
/**
|
||||
* Inverso de `formatUtcForDateTimeLocalInput`: recebe uma string vinda de um
|
||||
* input `datetime-local` (no timezone do usuário) e devolve uma ISO 8601 em
|
||||
* UTC pronta para enviar à API. Retorna `null` quando não houver data.
|
||||
* @param date - String do input (YYYY-MM-DDTHH:mm[:ss]) ou nulo
|
||||
* @returns ISO 8601 em UTC (ex.: 2026-05-19T19:40:00Z) ou null
|
||||
*/
|
||||
formatLocalDateTimeForApi(date: string | null | undefined): string | null {
|
||||
if (!date) return null;
|
||||
return dayjs.tz(date, getUserTimezone()).utc().format();
|
||||
},
|
||||
|
||||
/**
|
||||
* Formata minutos para formato legível
|
||||
* @param minutes - Número de minutos
|
||||
|
|
|
|||
|
|
@ -236,9 +236,7 @@ const getSubmitData = () => {
|
|||
content: content.value,
|
||||
media: media.value,
|
||||
platforms,
|
||||
scheduled_at: scheduledDateTime.value
|
||||
? dayjs(scheduledDateTime.value).utc().format()
|
||||
: null,
|
||||
scheduled_at: date.formatLocalDateTimeForApi(scheduledDateTime.value),
|
||||
label_ids: selectedLabelIds.value,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue