Buchungssystem erste überarbeitungen
This commit is contained in:
@@ -3,29 +3,17 @@
|
||||
import { useState } from "react";
|
||||
import { CalendarIcon } from "lucide-react";
|
||||
import { BookingSystem } from "./BookingSystem";
|
||||
import { User } from "@repo/db";
|
||||
|
||||
interface BookingButtonProps {
|
||||
currentUser: {
|
||||
id: string;
|
||||
emailVerified: boolean;
|
||||
is_banned: boolean;
|
||||
permissions: string[];
|
||||
};
|
||||
currentUser: User;
|
||||
}
|
||||
|
||||
export const BookingButton = ({ currentUser }: BookingButtonProps) => {
|
||||
const [isBookingSystemOpen, setIsBookingSystemOpen] = useState(false);
|
||||
|
||||
// Check if user can access booking system
|
||||
const canAccessBookingSystem = currentUser && currentUser.emailVerified && !currentUser.is_banned;
|
||||
|
||||
const handleOpenBookingSystem = () => {
|
||||
setIsBookingSystemOpen(true);
|
||||
};
|
||||
|
||||
const handleCloseBookingSystem = () => {
|
||||
setIsBookingSystemOpen(false);
|
||||
};
|
||||
const canAccessBookingSystem = currentUser && currentUser.emailVerified && !currentUser.isBanned;
|
||||
|
||||
// Don't render the button if user doesn't have access
|
||||
if (!canAccessBookingSystem) {
|
||||
@@ -37,14 +25,14 @@ export const BookingButton = ({ currentUser }: BookingButtonProps) => {
|
||||
<button
|
||||
className="btn btn-sm btn-ghost tooltip tooltip-bottom"
|
||||
data-tip="Slot Buchung"
|
||||
onClick={handleOpenBookingSystem}
|
||||
onClick={() => setIsBookingSystemOpen(true)}
|
||||
>
|
||||
<CalendarIcon size={20} />
|
||||
</button>
|
||||
|
||||
<BookingSystem
|
||||
isOpen={isBookingSystemOpen}
|
||||
onClose={handleCloseBookingSystem}
|
||||
onClose={() => setIsBookingSystemOpen(false)}
|
||||
currentUser={currentUser}
|
||||
/>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user