set scedule date to null when schedule status changed

This commit is contained in:
Sadaqat Ali 2022-07-05 22:59:39 +05:00
parent 31ee6ef52f
commit 16f4e2c453

View File

@ -79,7 +79,7 @@ const PostOptionsModal = forwardRef(({
handleScheduleChange(scheduledFor) handleScheduleChange(scheduledFor)
} }
}, [scheduleLater, scheduledFor]) }, [scheduleLater, scheduledFor])
*/ */
useEffect(() => { useEffect(() => {
if(scheduledFor){ if(scheduledFor){
handleScheduleChange(scheduledFor); handleScheduleChange(scheduledFor);
@ -87,9 +87,12 @@ const PostOptionsModal = forwardRef(({
},[scheduledFor]) },[scheduledFor])
useEffect(() => { useEffect(() => {
if(scheduledForDate){ if (scheduledForDate) {
setScheduleLater(true); setScheduleLater(true);
setScheduledFor(scheduledForDate); setScheduledFor(scheduledForDate);
} else {
setScheduleLater(false);
setScheduledFor('');
} }
},[scheduledForDate]) },[scheduledForDate])
@ -155,8 +158,11 @@ const PostOptionsModal = forwardRef(({
intl.formatMessage({id:"editor.scheduled_later"}), intl.formatMessage({id:"editor.scheduled_later"}),
]} ]}
selectedOptionIndex={scheduleLater ? 1 : 0} selectedOptionIndex={scheduleLater ? 1 : 0}
handleOnChange={(index)=>{ handleOnChange={(index)=> {
setScheduleLater(index === 1) setScheduleLater(index === 1);
if (index !== 1) {
handleScheduleChange(null);
}
}} }}
/> />