Skip to content

Commit

Permalink
updated modals
Browse files Browse the repository at this point in the history
  • Loading branch information
ericramos-07 committed Dec 16, 2023
1 parent 1154d0e commit 9c9ecd7
Show file tree
Hide file tree
Showing 5 changed files with 305 additions and 23 deletions.
14 changes: 12 additions & 2 deletions frontend/app/components/modal_admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ function ModalAdmin({ isOpen, onClose }: BasicModalProps) {

<div className="flex justify-center space-x-5 text-xs">
<Butt
title="Cancel"
title="Terminate"
Bgcolor="#A081AB"
width="152px"
height="30px"
borderRadius="10px"
onClick={onClose} // Close the main modal on Cancel button click
/>
<Butt
title="Extend"
Expand All @@ -73,6 +72,17 @@ function ModalAdmin({ isOpen, onClose }: BasicModalProps) {
onClick={handleOpen} // Show the extend modal on Extend button click
/>
</div>

<div className="flex justify-center items-center">
<Butt
title="Cancel"
Bgcolor="#EBE0D0"
width="320px"
height="30px"
borderRadius="10px"
onClick={onClose} // Close the main modal on Cancel button click
/>
</div>
</div>
</Box>
</Modal>
Expand Down
84 changes: 84 additions & 0 deletions frontend/app/components/modal_createacc.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
"use client";
import React, { useState } from "react";
import Box from "@mui/material/Box";
import Modal from "@mui/material/Modal";
import Butt from "./button";
import Link from "next/link";
import ModalExtend from "./modal_extend"; // Import your ModalExtend component

const style = {
position: "absolute" as "absolute",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
width: 400,
bgcolor: "background.paper",
borderRadius: "20px",
border: "2px solid #DC9D94",
boxShadow: 24,
p: 4,
};

interface BasicModalProps {
isOpen: boolean;
onClose: () => void;
}

function ModalCreate({ isOpen, onClose }: BasicModalProps) {
const [showExtendModal, setShowExtendModal] = useState(false);

const handleOpen = () => {
setShowExtendModal(true);
};

const handleClose = () => {
setShowExtendModal(false);
onClose();
};

return (
<div>
<Modal
open={isOpen}
onClose={onClose}
aria-labelledby="modal-modal-title"
aria-describedby="modal-modal-description"
>
<Box sx={style}>
<div className="text-textcolor text-xl font-bold">
<h2>Create Account</h2>
</div>

<div className="container">
<div className="flex justify-center items-center mt-5">
<div className="text-textcolor text-base font-bold">
<h2>Account Created Successfully!</h2>
</div>
</div>

<div className="flex justify-center space-x-5 text-xs">
<Link href="/sign_in">
<Butt
title="Back to Sign In"
Bgcolor="#EBE0D0"
width="160px"
height="30px"
borderRadius="10px"
/>
</Link>
</div>
</div>
</Box>
</Modal>

{showExtendModal && (
<ModalExtend
isOpen={true /* or use a state variable for this */}
onClose={handleClose}
/>
)}
</div>
);
}

export default ModalCreate;
25 changes: 18 additions & 7 deletions frontend/app/components/modal_extend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,24 @@ function ModalExtend({ isOpen, onClose }: BasicModalProps) {
</div>
</div>

<Butt
onClick={handleCreateAccount}
title="Continue"
Bgcolor="#EBE0D0"
width="325px"
height="34px"
/>
<div className="flex justify-center space-x-5 text-xs">
<Butt
title="Cancel"
Bgcolor="#EBE0D0"
width="152px"
height="30px"
borderRadius="10px"
onClick={onClose}
/>
<Butt
title="Continue"
Bgcolor="#F8D8D4"
width="152px"
height="30px"
borderRadius="10px"
onClick={handleCreateAccount}
/>
</div>
</Box>
</Modal>
</div>
Expand Down
139 changes: 139 additions & 0 deletions frontend/app/components/modal_wait.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
"use client";
import React, { useEffect, useState } from "react";
import Box from "@mui/material/Box";
import Modal from "@mui/material/Modal";
import Butt from "./button";
import DatePick from "./date_picker";
import TimePick from "./time_picker";
import { useRouter } from "next/navigation";

const style = {
position: "absolute" as "absolute",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
width: 400,
bgcolor: "background.paper",
borderRadius: "20px",
border: "2px solid #DC9D94",
boxShadow: 24,
p: 4,
};

interface BasicModalProps {
isOpen: boolean;
onClose: () => void;
}

function BasicModal({ isOpen, onClose }: BasicModalProps) {
const [open, setOpen] = React.useState(false);
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);
const router = useRouter();

const [formData, setFormData] = useState<{
Date: string | any;
StartTime: string | any;
EndTime: string | any;
}>({
Date: "",
StartTime: "",
EndTime: "",
});

const handleInputChange = (field: string, value: string) => {
setFormData({
...formData,
[field]: value,
});
};
const redirectUrl = "http://localhost:3000/qr_success_reservation"; //change this to a page after ng payment so magamit yung handleCreateAccount function. Dun pa dapat ma-ce-create yung reservation
const getName = "Gian"; //change get the name of user from session or local storage kung san man naka store
const tableFee = 140; //change den sa calculation

const handleCreateAccount = async () => {
try {
const apiData = {
chair_id: "", // Set a default value if not applicable
date: formData.Date,
starttime: formData.StartTime,
endtime: formData.EndTime,
};
router.push(
`https://payment-gateway-weld.vercel.app/gcash/login?amountDue=${tableFee}&merchant=Brew and Brains&redirectUrl=${redirectUrl}`
);

const response = await fetch(
"http://localhost:5000/api/create-reservation",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(apiData),
}
);

if (response.ok) {
// Successfully created account
console.log("Reserved successfully!");
// Optionally, you can redirect the user to a login page or another page
} else {
// Handle error cases
console.error("Error Reservation", await response.json());
}
} catch (error) {
console.error("Error Reservation", error);
}
};

return (
<div>
<Modal
open={isOpen}
onClose={onClose}
aria-labelledby="modal-modal-title"
aria-describedby="modal-modal-description"
>
<Box sx={style}>
<div className="text-textcolor text-xl font-bold">
<h2>Ben Eric Trial</h2>
</div>

<div className="container">
<div className="flex justify-center items-center mt-3">
<DatePick
text="Date:"
onInputChange={(value) => handleInputChange("date", value)}
></DatePick>
</div>

<div className="flex justify-center items-center mt-3">
<TimePick
text="Start Time:"
onInputChange={(value) => handleInputChange("starttime", value)}
></TimePick>
</div>

<div className="flex justify-center items-center mt-3">
<TimePick
text="End Time:"
onInputChange={(value) => handleInputChange("endtime", value)}
></TimePick>
</div>
</div>

<Butt
onClick={handleCreateAccount}
title="Reserve"
Bgcolor="#EBE0D0"
width="325px"
height="34px"
/>
</Box>
</Modal>
</div>
);
}

export default BasicModal;
Loading

0 comments on commit 9c9ecd7

Please sign in to comment.