Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add links for rooms from schedule to maps #178

Merged
merged 2 commits into from
Nov 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions src/components/calendar/CalendarEventPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
useTransitionStyles,
} from "@floating-ui/react";
import { EventApi } from "@fullcalendar/core";
import { Link } from "@tanstack/react-router";
import moment from "moment";
import React, { useEffect } from "react";

Expand Down Expand Up @@ -67,6 +68,10 @@ export default function CalendarEventPopover({
// Merge all the interactions into prop getters
const { getFloatingProps } = useInteractions([dismiss, role]);

let locations: string[] | undefined = undefined;
if (event.extendedProps?.location)
locations = event.extendedProps?.location.split("/");

return (
<>
{isMounted && (
Expand Down Expand Up @@ -104,14 +109,40 @@ export default function CalendarEventPopover({
: moment(event.startStr).format("dddd, D MMMM")}
</p>
</div>
{event.extendedProps?.location && (
{locations && (
<div className="flex flex-row gap-2">
<div className="w-6">
<span className="icon-[material-symbols--location-on-outline] text-2xl" />
</div>
<p className="flex w-full whitespace-pre-wrap py-1 [overflow-wrap:anywhere]">
{event.extendedProps.location}
</p>
<div className="flex flex-row gap-1">
{locations.map((location: string, index: number) =>
location.toUpperCase() !== "ONLINE" &&
location.toUpperCase() !== "ОНЛАЙН" ? (
<div className="flex flex-row items-center gap-1">
<Link
key={index}
to="/maps"
search={{
q: location,
}}
target="_blank"
className="flex w-full whitespace-pre-wrap py-1 underline underline-offset-2 [overflow-wrap:anywhere]"
>
{location}
</Link>
{index !== locations.length - 1 && (
<p className="py-1">/</p>
)}
</div>
) : (
<p className="flex w-full whitespace-pre-wrap py-1">
{location.concat(
index !== locations.length - 1 ? " / " : "",
)}
</p>
),
)}
</div>
</div>
)}
{event.extendedProps?.description && (
Expand Down