trypost/resources/js/composables/usePageErrors.ts
Paulo Castellano df35d1b671 feat(posts): add validation message for past date selection in PickTimePopover
- Introduced a new translation key for future date selection prompts in English, Spanish, and Portuguese.
- Implemented logic to disable the confirm button and display a warning message when a past date is selected in the PickTimePopover component.
- Updated date formatting utility to handle UTC dates for HTML datetime-local inputs.
2026-05-19 16:26:40 -03:00

14 lines
641 B
TypeScript

import { usePage } from '@inertiajs/vue3';
import { computed, type ComputedRef } from 'vue';
/**
* Reactive access to Inertia's page-level validation errors, keyed by field
* path (e.g. `scheduled_at`, `platforms.0.content_type`). Returns an empty
* object when no errors are present so consumers can index without null
* checks. Cast to `Record<string, string>` because the app only ever flashes
* single string messages (no nested error bags).
*/
export const usePageErrors = (): ComputedRef<Record<string, string>> => {
const page = usePage();
return computed(() => (page.props.errors ?? {}) as Record<string, string>);
};