diff --git a/src/components/BookAChat/index.tsx b/src/components/BookAChat/index.tsx index eb1a0a44..a8b8a28a 100644 --- a/src/components/BookAChat/index.tsx +++ b/src/components/BookAChat/index.tsx @@ -1,7 +1,7 @@ import { addMinutes } from "date-fns"; import dateFormat from "dateformat"; import _ from "lodash"; -import React, { Fragment, useMemo, useState } from "react"; +import React, { Fragment, useEffect, useMemo, useState } from "react"; import { CreateChatRequestInput, DateInterval, @@ -11,9 +11,11 @@ import { useGetAvailOverrideDatesQuery, useGetAvailWeeklysQuery, useGetChatRequestsQuery, + useGetMyUserQuery, } from "../../generated/graphql"; +import { useCurrentProfile } from "../../hooks"; import useTimezoneConverters from "../../hooks/useTimezoneConverters"; -import { Button, Card, Modal, Text, TextArea } from "../atomic"; +import { Button, Card, Input, Modal, Text, TextArea } from "../atomic"; import Calendar from "../Calendar"; import { getDatesInThisMonth } from "../Calendar/utils"; import OneOptionModal from "../OneOptionModal"; @@ -101,6 +103,8 @@ const BookAChat = ({ mentor }: BookAChatProps) => { useGetChatRequestsQuery({ variables: { profileId: mentor.profileId }, }); + const { data: user } = useGetMyUserQuery(); + const currentProfile = useCurrentProfile(); const [createChatRequest] = useCreateChatRequestMutation({ refetchQueries: [ @@ -112,10 +116,18 @@ const BookAChat = ({ mentor }: BookAChatProps) => { const [loadingCreateChatRequest, setLoadingCreateChatRequest] = useState(false); const [chatRequestMessage, setChatRequestMessage] = useState(""); + const [location, setlocation] = useState( + user?.getMyUser.preferredChatLocation + ); + + useEffect(() => { + setlocation(user?.getMyUser.preferredChatLocation); + }, [user?.getMyUser]); loadingCreateChatRequest; // TODO: Use this variable - if (!fromUTC || !toUTC) return ; + if (!fromUTC || !toUTC || !user || !currentProfile.currentProfile) + return ; const extractDates = ( input: { @@ -208,19 +220,19 @@ const BookAChat = ({ mentor }: BookAChatProps) => { return (
-
+
Book a chat with{" "} {mentor.user.firstName} {mentor.user.lastName} -
+
If no times are open, the mentor is either completely booked or has not set availabilities yet. -
+
@@ -254,14 +266,14 @@ const BookAChat = ({ mentor }: BookAChatProps) => { /> -
+
Available Times
-
+
{selectedDate @@ -270,16 +282,18 @@ const BookAChat = ({ mentor }: BookAChatProps) => {
-
+
{timeslots.map((timeslot) => { return ( -
+
-
- +
+ + { + setRejectModalOpen(false); + }} + > +
+ + Reject Chat Request + +
+ + Let {chatRequest.menteeProfile.user.firstName} know why you are + rejecting the request: + +
-
+ /> +
-
+
-