Emails
1 month ago
EngagementChart
1 month ago
MediaHub
1 month ago
Onboarding
1 month ago
Popup
1 month ago
Skeletons
1 week ago
WhatsNew
1 month ago
charts
1 month ago
test
1 month ago
AdminMenuSync.js
1 month ago
ChartEmptyState.js
1 month ago
ChooseDate.js
1 month ago
ColorPicker.js
1 month ago
ExtendPlugins.js
1 month ago
Filters.js
1 month ago
Link.js
1 month ago
Navbar.js
1 week ago
NoFound.js
1 month ago
PageHeader.js
1 month ago
PluginRecommendations.js
1 month ago
PostScheduleField.js
1 month ago
PrestoPlayerIcon.js
1 month ago
ProGateOverlay.js
1 month ago
QuickAccess.js
1 month ago
RankedTable.js
1 month ago
StatCard.js
1 month ago
TopMedia.js
1 month ago
TopPerformingMedia.js
1 month ago
TopUsers.js
1 month ago
TruncatedTitle.js
1 month ago
UpgradeNotice.js
1 month ago
UpgradeToPro.js
1 month ago
VideoModal.js
1 month ago
WelcomeBanner.js
1 month ago
PostScheduleField.js
93 lines
| 1 | import React from 'react'; |
| 2 | import { __ } from '@wordpress/i18n'; |
| 3 | import { Select } from '@bsf/force-ui'; |
| 4 | import ChooseDate from './ChooseDate'; |
| 5 | import { |
| 6 | SELECT_TIME_OPTIONS, |
| 7 | PERIOD_OPTIONS, |
| 8 | getOptionLabel, |
| 9 | } from './Popup/EmailFormPopupUtils'; |
| 10 | |
| 11 | const PostScheduleField = ( { |
| 12 | date, |
| 13 | time, |
| 14 | period, |
| 15 | setDate, |
| 16 | setTime, |
| 17 | setPeriod, |
| 18 | } ) => { |
| 19 | const timeSelectValue = time |
| 20 | ? SELECT_TIME_OPTIONS.find( ( o ) => o.value === time ) || SELECT_TIME_OPTIONS[ 0 ] |
| 21 | : SELECT_TIME_OPTIONS[ 0 ]; |
| 22 | |
| 23 | return ( |
| 24 | <div className="flex flex-col gap-2 flex-1 w-full"> |
| 25 | <span className="text-sm font-medium text-text-secondary whitespace-nowrap"> |
| 26 | { __( 'Publish Date & Time', 'presto-player' ) } |
| 27 | </span> |
| 28 | <div className="flex flex-wrap items-center gap-3"> |
| 29 | <div className="flex-1 min-w-[12rem]"> |
| 30 | <ChooseDate |
| 31 | chosenDate={ date } |
| 32 | onPickDate={ ( s ) => { |
| 33 | if ( ! s ) return setDate( null ); |
| 34 | const [ y, m, d ] = s.split( '-' ).map( Number ); |
| 35 | if ( y && m && d ) setDate( new Date( y, m - 1, d ) ); |
| 36 | } } |
| 37 | placeholder={ __( 'Select date', 'presto-player' ) } |
| 38 | size="md" |
| 39 | /> |
| 40 | </div> |
| 41 | <span className="text-sm font-medium text-text-secondary whitespace-nowrap"> |
| 42 | { __( 'at', 'presto-player' ) } |
| 43 | </span> |
| 44 | <div className="w-32"> |
| 45 | <Select |
| 46 | by="value" |
| 47 | value={ timeSelectValue } |
| 48 | onChange={ ( o ) => o && setTime( o.value ) } |
| 49 | size="md" |
| 50 | > |
| 51 | <Select.Button |
| 52 | placeholder={ __( 'Select time', 'presto-player' ) } |
| 53 | render={ ( v ) => v?.label || '' } |
| 54 | /> |
| 55 | <Select.Options> |
| 56 | { SELECT_TIME_OPTIONS.map( ( o ) => ( |
| 57 | <Select.Option |
| 58 | key={ o.value || 'none' } |
| 59 | value={ { value: o.value, label: o.label } } |
| 60 | > |
| 61 | { o.label } |
| 62 | </Select.Option> |
| 63 | ) ) } |
| 64 | </Select.Options> |
| 65 | </Select> |
| 66 | </div> |
| 67 | <div className="w-24"> |
| 68 | <Select |
| 69 | by="value" |
| 70 | value={ period ?? '-1' } |
| 71 | onChange={ ( v ) => setPeriod( String( v ) ) } |
| 72 | size="md" |
| 73 | > |
| 74 | <Select.Button |
| 75 | placeholder={ __( 'Select', 'presto-player' ) } |
| 76 | render={ ( v ) => getOptionLabel( PERIOD_OPTIONS, v ) } |
| 77 | /> |
| 78 | <Select.Options> |
| 79 | { PERIOD_OPTIONS.map( ( o ) => ( |
| 80 | <Select.Option key={ o.value } value={ o.value }> |
| 81 | { o.label } |
| 82 | </Select.Option> |
| 83 | ) ) } |
| 84 | </Select.Options> |
| 85 | </Select> |
| 86 | </div> |
| 87 | </div> |
| 88 | </div> |
| 89 | ); |
| 90 | }; |
| 91 | |
| 92 | export default PostScheduleField; |
| 93 |