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

Prod Release10.10 #462

Merged
merged 20 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
5 changes: 2 additions & 3 deletions booking-app/app/api/approve/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import { NextRequest, NextResponse } from "next/server";
import { serverApproveBooking } from "@/components/src/server/admin";

export async function POST(req: NextRequest) {
const { id } = await req.json();
const { id, email } = await req.json();

try {
console.log("id", id);
await serverApproveBooking(id);
await serverApproveBooking(id, email);
return NextResponse.json(
{ message: "Approved successfully" },
{ status: 200 },
Expand Down
19 changes: 13 additions & 6 deletions booking-app/app/approve/page.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
"use client";

import React, { Suspense, useState } from "react";
import React, { Suspense, useContext, useState } from "react";

import {
DatabaseContext,
DatabaseProvider,
} from "@/components/src/client/routes/components/Provider";
import { clientApproveBooking } from "@/components/src/server/db";
import { Button } from "@mui/material";
import { useSearchParams } from "next/navigation";
import { clientApproveBooking } from "@/components/src/server/db";

const ApprovePageContent: React.FC = () => {
const searchParams = useSearchParams();
const paramCalendarEventId = searchParams.get("calendarEventId");
const [loading, setLoading] = useState(false);
const [approved, setApproved] = useState(false);
const [error, setError] = useState<string | null>(null);
const { userEmail } = useContext(DatabaseContext);

const handleApprove = async () => {
if (paramCalendarEventId) {
setLoading(true);
setError(null);
try {
await clientApproveBooking(paramCalendarEventId);
await clientApproveBooking(paramCalendarEventId, userEmail);
setApproved(true);
} catch (err) {
setError("Failed to approve booking.");
Expand Down Expand Up @@ -55,9 +60,11 @@ const ApprovePageContent: React.FC = () => {
};

const ApprovePage: React.FC = () => (
<Suspense fallback={<div>Loading...</div>}>
<ApprovePageContent />
</Suspense>
<DatabaseProvider>
<Suspense fallback={<div>Loading...</div>}>
<ApprovePageContent />
</Suspense>
</DatabaseProvider>
);

export default ApprovePage;
42 changes: 31 additions & 11 deletions booking-app/app/decline/page.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
"use client";

import React, { Suspense, useState } from "react";

import { Button } from "@mui/material";
import { useSearchParams } from "next/navigation";
import {
DatabaseContext,
DatabaseProvider,
} from "@/components/src/client/routes/components/Provider";
import { decline } from "@/components/src/server/db";
import { Button, TextField } from "@mui/material";
import { useSearchParams } from "next/navigation";
import React, { Suspense, useContext, useState } from "react";

const DeclinePageContent: React.FC = () => {
const searchParams = useSearchParams();
const paramCalendarEventId = searchParams.get("calendarEventId");
const [loading, setLoading] = useState(false);
const [declined, setDeclined] = useState(false);
const [error, setError] = useState<string | null>(null);
const [reason, setReason] = useState("");
const { userEmail } = useContext(DatabaseContext);

const handleDecline = async () => {
if (paramCalendarEventId) {
if (paramCalendarEventId && reason.trim()) {
setLoading(true);
setError(null);
try {
await decline(paramCalendarEventId);
await decline(paramCalendarEventId, userEmail, reason);
setDeclined(true);
} catch (err) {
setError("Failed to decline booking.");
console.log(err);
} finally {
setLoading(false);
}
} else {
setError("Please provide a reason for declining.");
}
};

Expand All @@ -34,9 +41,20 @@ const DeclinePageContent: React.FC = () => {
{paramCalendarEventId ? (
<div>
<p>Event ID: {paramCalendarEventId}</p>
<TextField
label="Reason for Declining"
variant="outlined"
fullWidth
multiline
rows={4}
value={reason}
onChange={e => setReason(e.target.value)}
style={{ marginBottom: 16 }}
required
/>
<Button
onClick={() => handleDecline()}
disabled={loading || declined}
disabled={loading || declined || !reason.trim()}
variant="contained"
>
{loading
Expand All @@ -55,9 +73,11 @@ const DeclinePageContent: React.FC = () => {
};

const DeclinePage: React.FC = () => (
<Suspense fallback={<div>Loading...</div>}>
<DeclinePageContent />
</Suspense>
<DatabaseProvider>
<Suspense fallback={<div>Loading...</div>}>
<DeclinePageContent />
</Suspense>
</DatabaseProvider>
);

export default DeclinePage;
10 changes: 10 additions & 0 deletions booking-app/app/modification/confirmation/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// app/modification/confirmation/page.tsx
import BookingFormConfirmationPage from "@/components/src/client/routes/booking/formPages/BookingFormConfirmationPage";
import { FormContextLevel } from "@/components/src/types";
import React from "react";

const Role: React.FC = () => (
<BookingFormConfirmationPage formContext={FormContextLevel.MODIFICATION} />
);

export default Role;
Loading
Loading