gesJav-wocxo3-vedgyg
This commit is contained in:
@@ -6,7 +6,6 @@ import CreateAppointment from './appointment/CreateAppointment';
|
||||
import UpdateAppointemnt from './appointment/UpdateAppointment';
|
||||
import Calendar from './Calendar';
|
||||
import { Switch, Route } from 'react-router-dom';
|
||||
// import ProductList from './ProductList';
|
||||
|
||||
const App = () => {
|
||||
return (
|
||||
@@ -14,7 +13,6 @@ const App = () => {
|
||||
<Header />
|
||||
<div className="ph3 pv1 background-gray">
|
||||
<Switch>
|
||||
{/* <Route exact path="/" component={ProductList} /> */}
|
||||
<Route exact path="/" component={AppointmentList} />
|
||||
<Route exact path="/create" component={CreateAppointment} />
|
||||
<Route exact path="/update/:_id" component={UpdateAppointemnt} />
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import React from 'react';
|
||||
|
||||
const Product = (props) => {
|
||||
const { product } = props;
|
||||
return (
|
||||
<div>
|
||||
<div>
|
||||
<b>{product.title}</b>: only {product.qty}!
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Product;
|
||||
@@ -1,40 +0,0 @@
|
||||
import React from 'react';
|
||||
import Product from './Product';
|
||||
import { useQuery, gql } from '@apollo/client';
|
||||
|
||||
const FEED_QUERY = gql`
|
||||
{
|
||||
allProducts{
|
||||
title
|
||||
qty
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const ProductList = () => {
|
||||
|
||||
const { data } = useQuery(FEED_QUERY);
|
||||
|
||||
console.log("Data:", data);
|
||||
|
||||
if (data !== undefined) {
|
||||
return (
|
||||
<div>
|
||||
{
|
||||
data.allProducts.map((product) => (
|
||||
<Product key={product.id} product={product} />
|
||||
))
|
||||
}
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<div>
|
||||
Rendering...
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
export default ProductList;
|
||||
@@ -21,15 +21,16 @@ const Appointment = (props) => {
|
||||
onCompleted: () => history.push('/')
|
||||
})
|
||||
|
||||
const updateAppointment = () => {
|
||||
let path = `/update/${appointment._id}`;
|
||||
history.push(path);
|
||||
}
|
||||
// const updateAppointment = () => {
|
||||
// let path = `/update/${appointment._id}`;
|
||||
// history.push(path);
|
||||
// }
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div>
|
||||
<b>{appointment.title}</b> starts at {appointment.start}, ends at {appointment.end}. It is described as "{appointment.description}"<button onClick={deleteAppointment}>DELETE</button><button onClick={updateAppointment}>EDIT</button>
|
||||
<b>{appointment.title}</b> starts at {appointment.start}, ends at {appointment.end}. It is described as "{appointment.description}"<button onClick={deleteAppointment}>DELETE</button>
|
||||
{/* <button onClick={updateAppointment}>EDIT</button> */}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user