Skip to content

Commit

Permalink
fix:(fixing appointment session)
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmyfrank committed Jul 22, 2024
1 parent 5d79600 commit 5dea845
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 21 deletions.
54 changes: 34 additions & 20 deletions app/messagingAppointment/messaging.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { RootState } from "@/redux/store/store";
import { supabase } from "../supabase";
import { getMessages } from "@/redux/reducers/appointment";
import { SendMessageButton } from "@/components/SendMessageButton";
import checkSession from "@/utils/checkSession";
import checkSession, { isSessionInFuture } from "@/utils/checkSession";
export default function messagingAppointment() {
const [visible, setVisible] = useState(false);
const [isSession, setIsSession] = useState(true);
Expand Down Expand Up @@ -175,26 +175,40 @@ export default function messagingAppointment() {
appointment.duration,
appointment.appointment_date,
appointment.appointment_time
) && (
<View className="flex-row justify-center items-center gap-2">
<View className="flex-1">
<ChatInput
onChangeText={(text) => setTextMessage(text)}
onKeyPress={() => handleSendMessage(textMessage, "message")}
handleMessage={handleSendMessage}
autoFocus={true}
/>
) &&
(!isSessionInFuture(
appointment.duration,
appointment.appointment_date,
appointment.appointment_time
) ? (
<View className="flex-row justify-center items-center gap-2">
<View className="flex-1">
<ChatInput
onChangeText={(text) => setTextMessage(text)}
onKeyPress={() => handleSendMessage(textMessage, "message")}
handleMessage={handleSendMessage}
autoFocus={true}
/>
</View>
{/* Replace recording icon onChangeText to send Icon */}
{textMessage.trim().length === 0 ? (
<Recording direction={""} handleMessage={handleSendMessage} />
) : (
<SendMessageButton
onPress={() => handleSendMessage(textMessage, "message")}
/>
)}
</View>
{/* Replace recording icon onChangeText to send Icon */}
{textMessage.trim().length === 0 ? (
<Recording direction={""} handleMessage={handleSendMessage} />
) : (
<SendMessageButton
onPress={() => handleSendMessage(textMessage, "message")}
/>
)}
</View>
)}
) : (
<View className="flex-row justify-center items-center my-3">
<View className="bg-[#75757512] justify-center items-center rounded-lg px-6 py-1.5">
<Text className="text-sm text-[#757575] font-UrbanistSemiBold">
Session is Not Yet Started
</Text>
</View>
</View>
))}

{checkSession(
appointment.duration,
appointment.appointment_date,
Expand Down
6 changes: 5 additions & 1 deletion utils/checkSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ export const isSessionInFuture = (
const currentDate: Date = new Date();
const appointmentDate: Date = new Date(appDate);
appointmentDate.setHours(
parseInt(appTime.split(":")[0]) + parseInt(duration.split(" ")[0]),
parseInt(appTime.split(":")[0]),
parseInt(appTime.split(":")[1])
);
console.log("duration", duration);
console.log("appDate", appDate);
console.log("appTime", appTime);
console.log(appointmentDate);

if (currentDate < appointmentDate) {
return true;
Expand Down

0 comments on commit 5dea845

Please sign in to comment.