Files
temetro/frontend/components/meetings/use-call-invites.ts
T
Khalid Abdi 913a217e1d feat(meetings): live invite, scheduling calendar, Discord-style redesign
- Live invite: ring a clinic member into a room (socket call:invite + a bell
  notification); the invitee gets a toast with a Join action. Notifications of
  type "meeting" deep-link to /messages/meetings?room=, which auto-joins.
- Scheduling: new scheduled_meetings table + /api/meetings/events (list mine,
  create, delete); a Calendar tab on the Meetings page with a month picker
  (meeting-day dots), the day's agenda, and a Schedule-meeting dialog
  (title/date/time/participants).
- Redesign: rounded control bar with tooltips (mic/cam/screen/invite + separated
  red Leave), speaking ring on tiles (Web Audio), and live room-occupancy counts
  via call:presence broadcasts. Migration 0025.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-20 02:07:41 +03:00

41 lines
1.2 KiB
TypeScript

"use client";
import { useRouter } from "next/navigation";
import { useEffect } from "react";
import { useTranslation } from "react-i18next";
import { toastManager } from "@/components/ui/toast";
import { getSocket } from "@/lib/socket";
type CallInvite = { roomId: string; roomName: string; fromName: string };
// Listens for live "call:invite" events and shows a toast with a Join action
// that drops the user into the room. Mounted once in the app shell (the sidebar)
// so it works from any page.
export function useCallInvites() {
const router = useRouter();
const { t } = useTranslation();
useEffect(() => {
const socket = getSocket();
const onInvite = ({ roomId, roomName, fromName }: CallInvite) => {
toastManager.add({
type: "info",
title: t("meetings.invite.toastTitle", { name: fromName }),
description: roomName,
actionProps: {
children: t("meetings.invite.join"),
onClick: () =>
router.push(
`/messages/meetings?room=${encodeURIComponent(roomId)}`,
),
},
});
};
socket.on("call:invite", onInvite);
return () => {
socket.off("call:invite", onInvite);
};
}, [router, t]);
}