mirror of
https://github.com/Since-3/Kuma.git
synced 2026-10-12 20:51:18 +00:00
see comments and fix individual course copy
This commit is contained in:
parent
e7521facc2
commit
ef50f18e3a
4 changed files with 27 additions and 6 deletions
|
|
@ -20,5 +20,5 @@ export default async function CourseBookingPage({ params }: CourseBookingPagePro
|
|||
notFound();
|
||||
}
|
||||
|
||||
redirect(`/business/${result.course.business.slug}`);
|
||||
redirect(`/business/${result.course.business.slug}?course=${courseId}`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,8 +59,11 @@ export async function checkUserBookingStatus(courseId: string) {
|
|||
*/
|
||||
export async function getCourseSummaryForConfirmation(courseId: string) {
|
||||
try {
|
||||
const course = await prisma.course.findUnique({
|
||||
where: { id: courseId },
|
||||
const course = await prisma.course.findFirst({
|
||||
where: {
|
||||
id: courseId,
|
||||
business: { isPublic: true },
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ interface PublicCourse {
|
|||
interface PublicCourseCardProps {
|
||||
course: PublicCourse;
|
||||
business?: BusinessInfo;
|
||||
defaultOpen?: boolean; // öffnet das Detail-Popup beim Mount (für Deep-Links)
|
||||
}
|
||||
|
||||
const TrainerAvatar = ({ trainer, size }: { trainer: TrainerProfile; size: "sm" | "lg" }) => {
|
||||
|
|
@ -310,8 +311,8 @@ const BookingDialog = ({
|
|||
);
|
||||
};
|
||||
|
||||
const PublicCourseCard = ({ course, business }: PublicCourseCardProps) => {
|
||||
const [dialogOpen, setDialogOpen] = useState(false);
|
||||
const PublicCourseCard = ({ course, business, defaultOpen = false }: PublicCourseCardProps) => {
|
||||
const [dialogOpen, setDialogOpen] = useState(defaultOpen);
|
||||
|
||||
const cardSafeCurrent = Math.max(0, course.currentParticipants);
|
||||
const cardSafeMax = Math.max(0, course.maxParticipants);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
"use client";
|
||||
|
||||
import { useState, useTransition, useMemo } from "react";
|
||||
import { useState, useTransition, useMemo, useEffect } from "react";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import PublicCourseCard from "../components/PublicCourseCard";
|
||||
import { getPublishedCoursesForBusiness } from "../../actions/booking-actions";
|
||||
import { Calendar } from "@/src/components/ui/calendar";
|
||||
|
|
@ -58,6 +59,21 @@ const BusinessPublicView = ({
|
|||
const [activeSport, setActiveSport] = useState<string>("Alle");
|
||||
const [isPending, startTransition] = useTransition();
|
||||
|
||||
// Deep-Link: ?course=<id> öffnet das Detail-Popup des Kurses und springt
|
||||
// auf dessen Datum, damit die Karte sichtbar ist (z.B. geteilter Buchungslink).
|
||||
const searchParams = useSearchParams();
|
||||
const deepLinkCourseId = searchParams.get("course");
|
||||
|
||||
useEffect(() => {
|
||||
if (!deepLinkCourseId) return;
|
||||
const target = loadedCourses.find((c) => c.id === deepLinkCourseId);
|
||||
if (!target) return;
|
||||
const day = new Date(target.date);
|
||||
day.setHours(0, 0, 0, 0);
|
||||
setSelectedDate(day);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [deepLinkCourseId]);
|
||||
|
||||
const handleDateSelect = (date: Date | undefined) => {
|
||||
if (!date) return;
|
||||
|
||||
|
|
@ -204,6 +220,7 @@ const BusinessPublicView = ({
|
|||
key={course.id}
|
||||
course={course}
|
||||
business={{ address: business.address, email: business.email }}
|
||||
defaultOpen={course.id === deepLinkCourseId}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue