Skip to content

Commit

Permalink
Merge pull request Project-Based-Learning-IT#41 from Project-Based-Le…
Browse files Browse the repository at this point in the history
…arning-IT/Mayank

Fixed some error
  • Loading branch information
Mayank8085 committed Apr 2, 2021
2 parents 24c113b + 1f6ad3e commit 19a0ef2
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 86 deletions.
24 changes: 17 additions & 7 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"react-scripts": "4.0.3",
"react-scrollbars-custom": "^4.0.25",
"react-stripe-checkout": "^2.6.3",
"react-toastify": "^7.0.3",
"reactstrap": "^8.9.0",
"web-vitals": "^1.0.1"
},
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Dashbaord/LeftsideDoctor.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const LeftsideDoctor = () => {

<li style={{ textDecoration: "none" }}>
<Link to="/doctor/payment-history">
<Option Value="Payment History" />
<Option Value="Appointment History" />
</Link>
</li>

Expand Down
4 changes: 1 addition & 3 deletions frontend/src/Dashbaord/LeftsidePatient.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ const LeftsidePatient = () => {
</Link>
</li>

<li>
<Option Value="Payment Details" />
</li>

</ul>
</div>
);
Expand Down
10 changes: 7 additions & 3 deletions frontend/src/Doctor/TodaysSchedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ const TodaysSchedule = () => {
var token = localStorage.getItem("token");
var decoded = jwt_decode(token);
const { data } = await Axios.post(
`${process.env.REACT_APP_SERVER_URL}/doctors//appointments/`,
`${process.env.REACT_APP_SERVER_URL}/doctors/appointments`,
{
doctorId: decoded._id,
}
);
// console.log(data);
// console.log(date);
console.log(date);
setAppointments(data);
console.log(Appointments);

setAppointments((Appointments) => {
return Appointments.filter(
(Appointment) =>
Expand All @@ -31,6 +33,8 @@ const TodaysSchedule = () => {
date.getDate().toString()
);
});
console.log(Appointments);

};

useEffect(() => {
Expand All @@ -49,7 +53,7 @@ const TodaysSchedule = () => {
</thead>
<tbody>
{Appointments.map((Appointment) => (
<tr>
<tr key={Appointment._id} >
<th scope="row">{Appointment.date}</th>
<th scope="row">{Appointment.slotTime}</th>
<th scope="row">{Appointment.patientName}</th>
Expand Down
145 changes: 74 additions & 71 deletions frontend/src/Patient/Payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,63 +5,64 @@ import { Link, useHistory } from "react-router-dom";
import Navbar from "../Basic/Navbar";
import Leftside from "../Dashbaord/LeftsidePatient";
import StripeCheckoutButton from "react-stripe-checkout";
import { toast } from "react-toastify";
// import { Toast } from "react-toastify/dist/components";

function getEndDateTime(dateTime) {
const hrs = (parseInt(dateTime.split('T')[1].split(':')[0]) + 1).toString().padStart(2, '0')
const time = hrs + ':00:00'
const date = dateTime.split('T')[0]
return date + 'T' + time
const hrs = (parseInt(dateTime.split("T")[1].split(":")[0]) + 1)
.toString()
.padStart(2, "0");
const time = hrs + ":00:00";
const date = dateTime.split("T")[0];
return date + "T" + time;
}

const Payment = (props) => {
const [finalBalnce, setFinalBalnce] = useState(0)
const [finalBalnce, setFinalBalnce] = useState(0);
const history = useHistory();

function createEvent(id, dateTime, doctorEmail) {
var virtualEvent = {
'id': id,
'summary': 'Appointment',
'location': 'Virtual',
'description': 'Doctor-Patient appointment',
'start': {
'dateTime': dateTime,
'timeZone': 'Asia/Kolkata'
id: id,
summary: "Appointment",
location: "Virtual",
description: "Doctor-Patient appointment",
start: {
dateTime: dateTime,
timeZone: "Asia/Kolkata",
},
'end': {
'dateTime': getEndDateTime(dateTime),
'timeZone': 'Asia/Kolkata'
end: {
dateTime: getEndDateTime(dateTime),
timeZone: "Asia/Kolkata",
},
'conferenceData': {
'createRequest': {
'requestId': "7qxalsvy0e"
}
conferenceData: {
createRequest: {
requestId: "7qxalsvy0e",
},
},
attendees: [{ email: doctorEmail }],
guestsCanModify: true,
reminders: {
useDefault: false,
overrides: [
{ method: "email", minutes: 24 * 60 },
{ method: "popup", minutes: 15 },
],
},
'attendees': [
{ 'email': doctorEmail }
],
'guestsCanModify': true,
'reminders': {
'useDefault': false,
'overrides': [
{ 'method': 'email', 'minutes': 24 * 60 },
{ 'method': 'popup', 'minutes': 15 }
]
}
};

var request = window.gapi.client.calendar.events.insert({
'calendarId': 'primary',
'resource': virtualEvent,
'sendUpdates': 'all',
'supportsAttachments': true,
'conferenceDataVersion': 1
calendarId: "primary",
resource: virtualEvent,
sendUpdates: "all",
supportsAttachments: true,
conferenceDataVersion: 1,
});

request.execute(function (event) {
console.log("Executed!")
console.log("Executed!");
console.log(event);
});

}

const { dateId, doctor, slotId } = props.location.data;
Expand All @@ -79,33 +80,38 @@ const Payment = (props) => {
);

if (data.doctorEmail) {
createEvent(data._id, data.date + 'T' + data.slotTime, data.doctorEmail)

createEvent(data._id, data.date + "T" + data.slotTime, data.doctorEmail);
}

// history.push("/patient");
};
useEffect(() => {
setFinalBalnce(1.18*doctor.feesPerSession)
}, [])
useEffect(() => {
setFinalBalnce(1.18 * doctor.feesPerSession);
}, []);


const makePayment=async(token)=>{

const {data}= await Axios.post( `${process.env.REACT_APP_SERVER_URL}/patients/payment`,{
token, finalBalnce
})

console.log(data);
const makePayment = async (token) => {
const { data } = await Axios.post(
`${process.env.REACT_APP_SERVER_URL}/patients/payment`,
{
token,
finalBalnce,
}
);


if (data) {
BookSlot();
setFinalBalnce(0);
toast("Appointment booed successfully",{
type:"success"
})
history.push("/patient");
}

}
console.log(data);
};

return (
<div className="bg-dark" style={{ height: "100vh" }}>
<Navbar />
<div >
<div>
<div className="row m-5" style={{ maxWidth: "100%" }}>
<div
className="col-3 col-md-3 p-4 bg-white "
Expand Down Expand Up @@ -192,7 +198,6 @@ const makePayment=async(token)=>{
</p>
<p>
<strong>{0.18 * doctor.feesPerSession}</strong>

</p>
</td>
</tr>
Expand All @@ -206,30 +211,28 @@ const makePayment=async(token)=>{
</td>
<td className="text-center text-danger">
<h4>

<strong>{finalBalnce}</strong>
</h4>
</td>
</tr>
</tbody>
</table>
<StripeCheckoutButton
stripeKey="pk_test_51IabQNSCj4BydkZ3VIEbtfIJoWfSESvGSia3mSOfCYPWiyGxNxyr42IRvpmi8f8WbnhzCYBIZMyshg540TErXG3500fbHzRzLc"
token={makePayment}
amount={finalBalnce}
name="Placed Appointment"
shippingAddress
billingAddress>
<button
type="button"
className="btn btn-success btn-lg btn-block"
onClick={BookSlot}
stripeKey="pk_test_51IabQNSCj4BydkZ3VIEbtfIJoWfSESvGSia3mSOfCYPWiyGxNxyr42IRvpmi8f8WbnhzCYBIZMyshg540TErXG3500fbHzRzLc"
token={makePayment}
amount={finalBalnce * 100}
name="Placed Appointment"
shippingAddress
billingAddress
>
Pay Now&nbsp;&nbsp;&nbsp;
<span className="glyphicon glyphicon-chevron-right" />
</button>
<button
type="button"
className="btn btn-success btn-lg btn-block"
>
Pay Now&nbsp;&nbsp;&nbsp;
<span className="glyphicon glyphicon-chevron-right" />
</button>
</StripeCheckoutButton>

</div>
</div>
</div>
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion frontend/src/Patient/PerviousAppointments.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const PatientAppointments = () => {
</thead>
<tbody>
{Appointments.map((Appointment) => (
<tr key={Appointment._id}>
<tr key={Appointment._id} >
<th scope="row">{Appointment.date}</th>
<th scope="row">{Appointment.slotTime}</th>
<th scope="row">{Appointment.doctorName}</th>
Expand Down

0 comments on commit 19a0ef2

Please sign in to comment.