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

Payments #66

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions 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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@nivo/line": "^0.79.1",
"@nivo/pie": "^0.80.0",
"@reduxjs/toolkit": "^1.9.1",
"@stripe/stripe-js": "^1.46.0",
"@tanstack/react-query": "^4.20.4",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Dashboard/AddStuff/AddStuff.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const AddStuff = () => {
console.log(result);
toast.success(`${data.name} is added successfully`);
// setLoading(true)
// navigate("/dashboard/manageProducts");
navigate("/dashboard/manageStuff");
// refetch()
});
}
Expand Down
18 changes: 9 additions & 9 deletions src/Dashboard/DashboardPage/AddDoctor.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const AddDoctor = () => {
const imageHostKey = process.env.REACT_APP_imgbb_key;
// console.log(imageHostKey);
const onSubmit = (data,e) => {
const workingTime= e.target.workingDays.split(",");
// const workingTime= e.target.workingTime.split(",");
const img = data.img[0];
const formData = new FormData();
formData.append("image", img);
Expand All @@ -46,15 +46,15 @@ const AddDoctor = () => {
.then((imgData) => {
if (imgData.success) {
const doctors = {
name: data.doctorName,
doctorName: data.doctorName,
title: data.title,
department: data.department,
workingTime,
workingDays: data.workingDays,
workingDays,
// workingDays: data.workingDays,
degree: data.degree,
doctorCode: data.doctorCode,
age: data.age,
contact: data.contact,
appointNumber: data.appointNumber,
address: data.address,
img: imgData.data.url,
};
Expand Down Expand Up @@ -246,18 +246,18 @@ const AddDoctor = () => {
</div>
<div className="col-span-full sm:col-span-3">
<label htmlFor="contact" className="text-sm">
Contact
Doctor Number
</label>
<input
type="contact"
placeholder="Contact"
{...register("contact", {
{...register("appointNumber", {
required: true,
})}
className="w-full rounded-md py-1 focus:ring-opacity-75 focus:ring-violet-400 border-gray-700 text-gray-900"
/>
{errors.contact && (
<p className="text-red-500">{errors.contact.message}</p>
{errors.appointNumber && (
<p className="text-red-500">{errors.appointNumber.message}</p>
)}
</div>

Expand Down
291 changes: 151 additions & 140 deletions src/Dashboard/DashboardPage/AppointById.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { useQuery } from '@tanstack/react-query';
import axios from 'axios';
import React from 'react';
import { useContext } from 'react';
import { useState } from 'react';
import { useEffect } from 'react';
import DataTable from 'react-data-table-component';
import { toast } from 'react-hot-toast';
import { AuthContext } from '../../contexts/AuthProvider';
import { useQuery } from "@tanstack/react-query";
import axios from "axios";
import React from "react";
import { useContext } from "react";
import { useState } from "react";
import { useEffect } from "react";
import DataTable from "react-data-table-component";
import { toast } from "react-hot-toast";
import { Link } from "react-router-dom";
import { AuthContext } from "../../contexts/AuthProvider";

const AppointById = () => {
const [stuffData, setStuffData] = useState([]);
const [reload, setReload] = useState(true)
const [stuffData, setStuffData] = useState([]);
const [reload, setReload] = useState(true);
const [perPage, setPage] = useState(10);

const caseInsensitiveSort = (rowA, rowB) => {
Expand All @@ -27,151 +28,161 @@ const AppointById = () => {

return 0;
};


const customStyles = {
const customStyles = {
rows: {
style: {
minHeight: '72px', // override the row height

},
style: {
minHeight: "72px", // override the row height
},
},
headCells: {
style: {
paddingLeft: '8px', // override the cell padding for head cells
paddingRight: '8px',
margin: '2px',
backgroundColor: 'rgb(18, 126, 111)',
color: 'white',
borderRadius: '5px',
text: 'bold',
fontSize: '15px'
},
style: {
paddingLeft: "8px", // override the cell padding for head cells
paddingRight: "8px",
margin: "2px",
backgroundColor: "rgb(18, 126, 111)",
color: "white",
borderRadius: "5px",
text: "bold",
fontSize: "15px",
},
},
cells: {
style: {
paddingLeft: '25px', // override the cell padding for data cells
// paddingRight: '8px',
textAlign: 'center',
border: '1px dotted teal',
borderRadius: '5px',
color: 'black',
margin: '2px',

},
style: {
paddingLeft: "25px", // override the cell padding for data cells
// paddingRight: '8px',
textAlign: "center",
border: "1px dotted teal",
borderRadius: "5px",
color: "black",
margin: "2px",
},
},
};
const {user} = useContext(AuthContext);
};
const { user } = useContext(AuthContext);

const getStuffData = async () => {
const getStuffData = async () => {
try {
const response = await axios.get(`http://localhost:5000/appointment?email=${user?.email}`);
setStuffData(response.data)
const response = await axios.get(
`http://localhost:5000/appointment?email=${user?.email}`
);
setStuffData(response.data);
} catch (error) {
console.log(error);
console.log(error);
}
}
console.log(stuffData);
};
console.log(stuffData);


// const handleDeleteUser = (id) =>{
// fetch(`http://localhost:5000/user/${id}`, {
// method: 'DELETE',
// })
// .then(res => res.json())
// .then(data => {
// setReload(!reload)
// toast.success('deleted successfully')

// })
// }
const columns = [
{
name: "id",
selector: (row,i) => (i+1),

},
// {
// name: "Image",
// selector: (row)=> <div >
// <PhotoProvider>
// <PhotoView src={row.img}>
// <img className='h-20 w-16 cursor-pointer' src={row.img} alt=''></img>
// </PhotoView>
// </PhotoProvider> <div className='-mt-8 cursor-pointer '><BiZoomIn></BiZoomIn> </div>
// </div> ,

// sortable: true
// },
{
name: "department",
selector: (row) => row.department,
sortable: true
},


{
name: "serviceName",
selector: (row) => row.serviceName,
sortable: true
},
{
name: "slot",
selector: (row) => row.slot,
sortable: true,
// const handleDeleteUser = (id) =>{
// fetch(`http://localhost:5000/user/${id}`, {
// method: 'DELETE',
// })
// .then(res => res.json())
// .then(data => {
// setReload(!reload)
// toast.success('deleted successfully')

},
{
name: "fee",
selector: (row) => row.fee,
sortable: true,
// })
// }
const columns = [
{
name: "id",
selector: (row, i) => i + 1,
},
// {
// name: "Image",
// selector: (row)=> <div >
// <PhotoProvider>
// <PhotoView src={row.img}>
// <img className='h-20 w-16 cursor-pointer' src={row.img} alt=''></img>
// </PhotoView>
// </PhotoProvider> <div className='-mt-8 cursor-pointer '><BiZoomIn></BiZoomIn> </div>
// </div> ,

},
{
name: "bookingDate",
selector: (row) => row.bookingDate,
sortable: true,
// sortable: true
// },
{
name: "department",
selector: (row) => row.department,
sortable: true,
},

},
{
name: "patientPhone",
selector: (row) => row.patientPhone,
sortable: true,
{
name: "serviceName",
selector: (row) => row.serviceName,
sortable: true,
},
{
name: "slot",
selector: (row) => row.slot,
sortable: true,
},
{
name: "fee",
selector: (row) => row.fee,
sortable: true,
},
{
name: "bookingDate",
selector: (row) => row.bookingDate,
sortable: true,
},
{
name: "patientPhone",
selector: (row) => row.patientPhone,
sortable: true,
},
{
name: "patientEmail",
selector: (row) => row.patientEmail,
sortable: true,
},
{
name: "Pay",
selector: (row) => (
<div>
{row.fee && !row.paid && (
<Link
to={`/dashboard/payment/${row._id}`}
className="btn btn-xs btn-secondary text-teal-600 font-bold"
>
Pay
</Link>
)}
{row.fee && row.paid && (
<button className="btn btn-xs text-white font-medium p-1 rounded-md bg-green-600">
Paid
</button>
)}
</div>
),
sortable: true,
},
];

},
{
name: "patientEmail",
selector: (row) => row.patientEmail,
sortable: true,
useEffect(() => {
getStuffData();
}, []);
return (
<div className="w-full">
<h2 className="text-center text-teal-600 fw-bold text-2xl my-8 ">
{" "}
<span className="text-gray-900">Your total Appointment</span>{" "}
{stuffData.length}
</h2>

},
// {
// name: "Delete",
// selector: (row) => <div className='cursor-pointer' onClick={()=>handleDeleteUser(row._id)}><AiFillDelete></AiFillDelete>{row.delete}</div>,
// sortable: true
// },
]

useEffect(()=>{
getStuffData();
},[reload])
return (
<div className='w-full'>
<h2 className='text-center text-teal-600 fw-bold text-2xl my-8 '> <span className='text-gray-900'>Your total Appointment</span> {stuffData.length}</h2>

<DataTable

columns={columns}
data={stuffData}
fixedHeader
pagination
caseInsensitiveSort={caseInsensitiveSort}
selectableRows
selectableRowsHighlight
customStyles={customStyles}
/>
</div>
);
<DataTable
columns={columns}
data={stuffData}
fixedHeader
pagination
caseInsensitiveSort={caseInsensitiveSort}
selectableRows
selectableRowsHighlight
customStyles={customStyles}
/>
</div>
);
};

export default AppointById;
export default AppointById;
Loading