{"version":3,"file":"buildUpcomingColumns.js","names":["getTranslation","React","formatDate","Button","Pill","buildUpcomingColumns","dateFormat","deleteHandler","docs","i18n","localization","supportedTimezones","t","columns","accessor","active","field","name","type","Heading","_jsx","renderedCells","map","doc","input","_jsxs","pillStyle","size","id","date","waitUntil","pattern","timezone","matchedTimezone","find","value","label","push","locale","matchedLocale","locales","code","buttonStyle","className","icon","onClick","e","preventDefault","tooltip"],"sources":["../../../../src/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.tsx"],"sourcesContent":["import type { ClientConfig, Column } from 'payload'\n\nimport { getTranslation, type I18nClient, type TFunction } from '@payloadcms/translations'\nimport React from 'react'\n\nimport type { UpcomingEvent } from './types.js'\n\nimport { formatDate } from '../../../utilities/formatDocTitle/formatDateTitle.js'\nimport { Button } from '../../Button/index.js'\nimport { Pill } from '../../Pill/index.js'\n\ntype Args = {\n dateFormat: string\n deleteHandler: (id: number | string) => void\n docs: UpcomingEvent[]\n i18n: I18nClient\n localization: ClientConfig['localization']\n supportedTimezones: ClientConfig['admin']['timezones']['supportedTimezones']\n t: TFunction\n}\n\nexport const buildUpcomingColumns = ({\n dateFormat,\n deleteHandler,\n docs,\n i18n,\n localization,\n supportedTimezones,\n t,\n}: Args): Column[] => {\n const columns: Column[] = [\n {\n accessor: 'input.type',\n active: true,\n field: {\n name: '',\n type: 'text',\n },\n Heading: {t('version:type')},\n renderedCells: docs.map((doc) => {\n const type = doc.input?.type\n\n return (\n \n {type === 'publish' && t('version:publish')}\n {type === 'unpublish' && t('version:unpublish')}\n \n )\n }),\n },\n {\n accessor: 'waitUntil',\n active: true,\n field: {\n name: '',\n type: 'date',\n },\n Heading: {t('general:time')},\n renderedCells: docs.map((doc) => (\n \n {formatDate({\n date: doc.waitUntil,\n i18n,\n pattern: dateFormat,\n timezone: doc.input.timezone,\n })}\n \n )),\n },\n {\n accessor: 'input.timezone',\n active: true,\n field: {\n name: '',\n type: 'text',\n },\n Heading: {t('general:timezone')},\n renderedCells: docs.map((doc) => {\n const matchedTimezone = supportedTimezones.find(\n (timezone) => timezone.value === doc.input.timezone,\n )\n\n const timezone = matchedTimezone?.label || doc.input.timezone\n\n return {timezone || t('general:noValue')}\n }),\n },\n ]\n\n if (localization) {\n columns.push({\n accessor: 'input.locale',\n active: true,\n field: {\n name: '',\n type: 'text',\n },\n Heading: {t('general:locale')},\n renderedCells: docs.map((doc) => {\n if (doc.input.locale) {\n const matchedLocale = localization.locales.find(\n (locale) => locale.code === doc.input.locale,\n )\n if (matchedLocale) {\n return {getTranslation(matchedLocale.label, i18n)}\n }\n }\n\n return {t('general:all')}\n }),\n })\n }\n\n columns.push({\n accessor: 'delete',\n active: true,\n field: {\n name: 'delete',\n type: 'text',\n },\n Heading: {t('general:delete')},\n renderedCells: docs.map((doc) => (\n