@@ -14,14 +14,19 @@ import { useToaster } from '@gitroom/react/toaster/toaster';
1414import interClass from '@gitroom/react/helpers/inter.font' ;
1515import { useModals } from '@mantine/modals' ;
1616import { TimeTable } from '@gitroom/frontend/components/launches/time.table' ;
17- import { useCalendar } from '@gitroom/frontend/components/launches/calendar.context' ;
17+ import {
18+ Integrations ,
19+ useCalendar ,
20+ } from '@gitroom/frontend/components/launches/calendar.context' ;
1821import { BotPicture } from '@gitroom/frontend/components/launches/bot.picture' ;
1922import { CustomerModal } from '@gitroom/frontend/components/launches/customer.modal' ;
2023import { Integration } from '@prisma/client' ;
2124import { SettingsModal } from '@gitroom/frontend/components/launches/settings.modal' ;
2225import { CustomVariables } from '@gitroom/frontend/components/launches/add.provider.component' ;
2326import { useRouter } from 'next/navigation' ;
2427import { useT } from '@gitroom/react/translation/get.transation.service.client' ;
28+ import { AddEditModal } from '@gitroom/frontend/components/new-launch/add.edit.modal' ;
29+ import dayjs from 'dayjs' ;
2530export const Menu : FC < {
2631 canEnable : boolean ;
2732 canDisable : boolean ;
@@ -50,7 +55,7 @@ export const Menu: FC<{
5055
5156 const fetch = useFetch ( ) ;
5257 const router = useRouter ( ) ;
53- const { integrations } = useCalendar ( ) ;
58+ const { integrations, reloadCalendarView } = useCalendar ( ) ;
5459 const toast = useToaster ( ) ;
5560 const modal = useModals ( ) ;
5661 const [ show , setShow ] = useState ( false ) ;
@@ -112,6 +117,7 @@ export const Menu: FC<{
112117 setShow ( false ) ;
113118 onChange ( true ) ;
114119 } , [ ] ) ;
120+
115121 const enableChannel = useCallback ( async ( ) => {
116122 await fetch ( '/integrations/enable' , {
117123 method : 'POST' ,
@@ -123,6 +129,7 @@ export const Menu: FC<{
123129 setShow ( false ) ;
124130 onChange ( false ) ;
125131 } , [ ] ) ;
132+
126133 const editTimeTable = useCallback ( ( ) => {
127134 const findIntegration = integrations . find (
128135 ( integration ) => integration . id === id
@@ -139,6 +146,42 @@ export const Menu: FC<{
139146 } ) ;
140147 setShow ( false ) ;
141148 } , [ integrations ] ) ;
149+
150+ const createPost = useCallback (
151+ ( integration : Integrations ) => async ( ) => {
152+ setShow ( false ) ;
153+
154+ const { date } = await (
155+ await fetch ( `/posts/find-slot/${ integration . id } ` )
156+ ) . json ( ) ;
157+
158+ modal . openModal ( {
159+ closeOnClickOutside : false ,
160+ closeOnEscape : false ,
161+ withCloseButton : false ,
162+ classNames : {
163+ modal : 'w-[100%] max-w-[1400px] bg-transparent text-textColor' ,
164+ } ,
165+ children : (
166+ < AddEditModal
167+ allIntegrations = { integrations . map ( ( p ) => ( {
168+ ...p ,
169+ } ) ) }
170+ reopenModal = { createPost ( integration ) }
171+ mutate = { reloadCalendarView }
172+ integrations = { integrations }
173+ selectedChannels = { [ integration . id ] }
174+ focusedChannel = { integration . id }
175+ date = { dayjs . utc ( date ) . local ( ) }
176+ />
177+ ) ,
178+ size : '80%' ,
179+ title : `` ,
180+ } ) ;
181+ } ,
182+ [ integrations ]
183+ ) ;
184+
142185 const changeBotPicture = useCallback ( ( ) => {
143186 const findIntegration = integrations . find (
144187 ( integration ) => integration . id === id
@@ -251,6 +294,30 @@ export const Menu: FC<{
251294 onClick = { ( e ) => e . stopPropagation ( ) }
252295 className = { `absolute top-[100%] start-0 p-[8px] px-[20px] bg-fifth flex flex-col gap-[16px] z-[100] rounded-[8px] border border-tableBorder ${ interClass } text-nowrap` }
253296 >
297+ { canDisable && ! findIntegration ?. refreshNeeded && (
298+ < div
299+ className = "flex gap-[12px] items-center"
300+ onClick = { createPost ( findIntegration ! ) }
301+ >
302+ < div >
303+ < svg
304+ xmlns = "http://www.w3.org/2000/svg"
305+ width = "18"
306+ height = "18"
307+ viewBox = "0 0 32 32"
308+ fill = "none"
309+ >
310+ < path
311+ d = "M21 4H11C9.14409 4.00199 7.36477 4.74012 6.05245 6.05245C4.74012 7.36477 4.00199 9.14409 4 11V21C4.00199 22.8559 4.74012 24.6352 6.05245 25.9476C7.36477 27.2599 9.14409 27.998 11 28H17C17.1075 27.9999 17.2142 27.9826 17.3162 27.9487C20.595 26.855 26.855 20.595 27.9487 17.3162C27.9826 17.2142 27.9999 17.1075 28 17V11C27.998 9.14409 27.2599 7.36477 25.9476 6.05245C24.6352 4.74012 22.8559 4.00199 21 4ZM17 25.9275V22C17 20.6739 17.5268 19.4021 18.4645 18.4645C19.4021 17.5268 20.6739 17 22 17H25.9275C24.77 19.6938 19.6938 24.77 17 25.9275Z"
312+ fill = "green"
313+ />
314+ </ svg >
315+ </ div >
316+ < div className = "text-[12px]" >
317+ { t ( 'create_new_post' , 'Create a new post' ) }
318+ </ div >
319+ </ div >
320+ ) }
254321 { canDisable &&
255322 findIntegration ?. refreshNeeded &&
256323 ! findIntegration . customFields && (
0 commit comments