1
1
'use client' ;
2
2
3
- import React , { FC , Fragment , useCallback , useEffect , useMemo , useState } from 'react' ;
3
+ import React , {
4
+ FC ,
5
+ Fragment ,
6
+ useCallback ,
7
+ useEffect ,
8
+ useMemo ,
9
+ useState ,
10
+ } from 'react' ;
4
11
import {
5
12
Integrations ,
6
13
useCalendar ,
@@ -159,7 +166,14 @@ export const CalendarColumn: FC<{
159
166
} > = ( props ) => {
160
167
const { getDate, randomHour } = props ;
161
168
const user = useUser ( ) ;
162
- const { integrations, posts, trendings, changeDate, display } = useCalendar ( ) ;
169
+ const {
170
+ integrations,
171
+ posts,
172
+ trendings,
173
+ changeDate,
174
+ display,
175
+ reloadCalendarView,
176
+ } = useCalendar ( ) ;
163
177
164
178
const toaster = useToaster ( ) ;
165
179
const modal = useModals ( ) ;
@@ -168,15 +182,16 @@ export const CalendarColumn: FC<{
168
182
const postList = useMemo ( ( ) => {
169
183
return posts . filter ( ( post ) => {
170
184
const pList = dayjs . utc ( post . publishDate ) . local ( ) ;
171
- const check = display === 'week'
172
- ? pList . isSameOrAfter ( getDate . startOf ( 'hour' ) ) && pList . isBefore ( getDate . endOf ( 'hour' ) )
173
- : pList . format ( 'DD/MM/YYYY' ) === getDate . format ( 'DD/MM/YYYY' ) ;
185
+ const check =
186
+ display === 'week'
187
+ ? pList . isSameOrAfter ( getDate . startOf ( 'hour' ) ) &&
188
+ pList . isBefore ( getDate . endOf ( 'hour' ) )
189
+ : pList . format ( 'DD/MM/YYYY' ) === getDate . format ( 'DD/MM/YYYY' ) ;
174
190
175
191
return check ;
176
192
} ) ;
177
193
} , [ posts , display , getDate ] ) ;
178
194
179
-
180
195
const canBeTrending = useMemo ( ( ) => {
181
196
return ! ! trendings . find ( ( trend ) => {
182
197
return dayjs
@@ -282,6 +297,7 @@ export const CalendarColumn: FC<{
282
297
< ExistingDataContextProvider value = { data } >
283
298
< AddEditModal
284
299
reopenModal = { editPost ( post ) }
300
+ mutate = { reloadCalendarView }
285
301
integrations = { integrations
286
302
. slice ( 0 )
287
303
. filter ( ( f ) => f . id === data . integration )
@@ -308,6 +324,7 @@ export const CalendarColumn: FC<{
308
324
children : (
309
325
< AddEditModal
310
326
integrations = { integrations . slice ( 0 ) . map ( ( p ) => ( { ...p } ) ) }
327
+ mutate = { reloadCalendarView }
311
328
date = {
312
329
randomHour ? getDate . hour ( Math . floor ( Math . random ( ) * 24 ) ) : getDate
313
330
}
@@ -368,11 +385,15 @@ export const CalendarColumn: FC<{
368
385
) ) }
369
386
</ div >
370
387
{ ! isBeforeNow && (
371
- < div className = "pb-[2.5px] px-[5px] flex-1 flex" onClick = { integrations . length ? addModal : addProvider } >
388
+ < div
389
+ className = "pb-[2.5px] px-[5px] flex-1 flex"
390
+ onClick = { integrations . length ? addModal : addProvider }
391
+ >
372
392
< div
373
393
className = { clsx (
374
- display === 'month' ? 'flex-1 min-h-[40px] w-full' :
375
- ! postList . length
394
+ display === 'month'
395
+ ? 'flex-1 min-h-[40px] w-full'
396
+ : ! postList . length
376
397
? 'h-full w-full absolute left-0 top-0 p-[5px]'
377
398
: 'min-h-[40px] w-full' ,
378
399
'flex items-center justify-center cursor-pointer pb-[2.5px]'
0 commit comments