@@ -15,25 +15,41 @@ import { useStateCtx } from "@/context/StateCtx";
1515import { cn } from "@/utils" ;
1616import { X } from "lucide-react" ;
1717import { RadioGroup , RadioGroupItem } from "@/components/ui/radio" ;
18- import { Calendar } from "@/components/ui/Calendar" ;
18+ import {
19+ Select ,
20+ SelectContent ,
21+ SelectItem ,
22+ SelectTrigger ,
23+ SelectValue ,
24+ } from "@/components/ui/select" ;
1925import {
2026 Popover ,
2127 PopoverContent ,
2228 PopoverTrigger ,
2329} from "@/components/ui/Popover" ;
24- import { format } from "date-fns " ;
30+ import { Calendar } from "@/components/ui/Calendar " ;
2531import { Button } from "@/components/ui/butt" ;
32+ import { CalendarIcon } from "@radix-ui/react-icons" ;
33+ import { addDays , format } from "date-fns" ;
2634
2735const CreateMeet = ( ) => {
2836 const { user } = useUserCtx ( ) ;
2937 const { CreateMeet, setCreateMeet } = useStateCtx ( ) ;
3038 const client = useStreamVideoClient ( ) ;
3139 const [ participantsInput , setParticipantsInput ] = useState ( "" ) ;
32- const [ startTimeInput , setStartTimeInput ] = useState ( "" ) ;
40+ const [ date , setDate ] = useState < Date > ( new Date ( ) ) ;
3341 const [ descriptionInput , setDescriptionInput ] = useState ( "" ) ;
3442 const [ call , setCall ] = useState ( null ) ;
3543
3644 const [ Adddescription , setAdddescription ] = useState ( false ) ;
45+ const [ Time , setTime ] = useState ( false ) ;
46+
47+ if ( ! CreateMeet ) {
48+ if ( Adddescription || Time ) {
49+ setAdddescription ( false ) ;
50+ setTime ( false ) ;
51+ }
52+ }
3753
3854 // async function createMeeting() {
3955 // if (!client || !user) {
@@ -91,10 +107,11 @@ const CreateMeet = () => {
91107 role = "dialog"
92108 aria-labelledby = "remove-client"
93109 className = { cn (
94- "py-6 flex flex-col max-[350px]:h-[450px] w-[90%] h-[420px] min-[550px]:w-[500px] md:w-[682px] md:h-[500px] items-center bg-white dark:bg-primary fixed top-1/2 left-1/2 z-[999 ] transition-all opacity-0 select-none -translate-y-1/2 -translate-x-1/2" ,
110+ "py-6 flex flex-col max-[350px]:h-[450px] w-[90%] h-[420px] min-[550px]:w-[500px] md:w-[682px] md:h-[500px] items-center bg-white dark:bg-primary fixed top-1/2 left-1/2 z-[99 ] transition-all opacity-0 select-none -translate-y-1/2 -translate-x-1/2" ,
95111 CreateMeet
96112 ? "scale-100 duration-500 opacity-100 rounded-xl md:rounded-2xl"
97- : "scale-0 duration-200 pointer-events-none"
113+ : "scale-0 duration-200 pointer-events-none" ,
114+ Adddescription || Time ? "overflow-y-auto overflow-x-hidden" : ""
98115 ) }
99116 >
100117 < div className = "flex items-center justify-between w-full border-b border-[#e1e1e1] pb-4 pl-4 px-4 md:pl-8 sticky top-0 bg-white" >
@@ -142,20 +159,75 @@ const CreateMeet = () => {
142159 </ >
143160 < >
144161 < p className = "text-[16px] md:text-[20px] " > Meeting Time</ p >
145- < RadioGroup defaultValue = "comfortable" >
162+ < RadioGroup
163+ defaultValue = "fasle"
164+ onValueChange = { ( ) => setTime ( ! Time ) }
165+ >
146166 < div className = "flex items-center space-x-2" >
147167 < RadioGroupItem value = "default" id = "r1" />
148168 < Label htmlFor = "r1" > Start meeting immediately</ Label >
149169 </ div >
150170 < div className = "flex items-center space-x-2" >
151- < RadioGroupItem value = "comfortable " id = "r2" />
171+ < RadioGroupItem value = "later " id = "r2" />
152172 < Label htmlFor = "r2" > Start meeting at a later date</ Label >
153173 </ div >
154174 </ RadioGroup >
175+ { Time && (
176+ < Popover >
177+ < PopoverTrigger asChild >
178+ < Button
179+ variant = { "outline" }
180+ className = { cn (
181+ "w-full justify-start text-left font-normal min-h-8 md:py-4 py-2" ,
182+ ! date && "text-muted-foreground"
183+ ) }
184+ >
185+ < CalendarIcon className = "mr-2 h-4 w-4" />
186+ { date ? format ( date , "PPP" ) : < span > Pick a date</ span > }
187+ </ Button >
188+ </ PopoverTrigger >
189+ < PopoverContent
190+ align = "start"
191+ className = "flex w-full flex-col space-y-2 p-2 z-[500]"
192+ >
193+ < Select
194+ onValueChange = { ( value ) =>
195+ setDate ( addDays ( new Date ( ) , parseInt ( value ) ) )
196+ }
197+ >
198+ < SelectTrigger >
199+ < SelectValue placeholder = "Select Time Frame" />
200+ </ SelectTrigger >
201+ < SelectContent
202+ position = "popper"
203+ className = "z-[999] bg-white"
204+ >
205+ < SelectItem value = "0" > Today</ SelectItem >
206+ < SelectItem value = "1" > Tomorrow</ SelectItem >
207+ < SelectItem value = "3" > In 3 days</ SelectItem >
208+ < SelectItem value = "7" > In a week</ SelectItem >
209+ </ SelectContent >
210+ </ Select >
211+ < div className = "rounded-md border" >
212+ < Calendar
213+ mode = "single"
214+ selected = { date }
215+ onSelect = { ( selectedDate : Date | undefined ) => {
216+ if ( selectedDate ) {
217+ setDate ( selectedDate ) ;
218+ }
219+ } }
220+ disabled = { ( date ) => date < new Date ( ) }
221+ // initialFocus
222+ />
223+ </ div >
224+ </ PopoverContent >
225+ </ Popover >
226+ ) }
155227 </ >
156228 < >
157229 < p className = "text-[16px] md:text-[20px] " > Who Can Join</ p >
158- < RadioGroup defaultValue = "comfortable " >
230+ < RadioGroup defaultValue = "false " >
159231 < div className = "flex items-center space-x-2" >
160232 < RadioGroupItem value = "default" id = "r1" />
161233 < Label htmlFor = "r1" > Every One</ Label >
0 commit comments