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>
|
||||
);
|
||||
|
||||
@@ -23,14 +23,14 @@
|
||||
"dotenv": "^8.2.0",
|
||||
"esm": "^3.2.25",
|
||||
"express": "^4.17.1",
|
||||
"express-graphql": "^0.12.0",
|
||||
"graphql": "^15.4.0",
|
||||
"graphql-compose": "^7.23.0",
|
||||
"graphql-compose-connection": "^8.0.1",
|
||||
"graphql-compose-mongoose": "^9.0.0",
|
||||
"graphql-depth-limit": "^1.1.0",
|
||||
"graphql-middleware": "^6.0.0",
|
||||
"graphql-tools": "^7.0.2",
|
||||
"express-graphql": "*",
|
||||
"graphql": "*",
|
||||
"graphql-compose": "*",
|
||||
"graphql-compose-connection": "*",
|
||||
"graphql-compose-mongoose": "*",
|
||||
"graphql-depth-limit": "*",
|
||||
"graphql-middleware": "*",
|
||||
"graphql-tools": "*",
|
||||
"jsonwebtoken": "8.5.1",
|
||||
"migrate": "^1.7.0",
|
||||
"mocha": "^8.2.1",
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import mongoose from 'mongoose';
|
||||
const Schema = mongoose.Schema;
|
||||
const ProductSchema = new Schema({
|
||||
title: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
qty: {
|
||||
type: Number
|
||||
}
|
||||
});
|
||||
export default mongoose.model('product', ProductSchema);
|
||||
@@ -1,5 +1,4 @@
|
||||
// import Appointment from '../../client/src/components/Appointment.js';
|
||||
import Product from './models/product.js';
|
||||
import Appointment from './models/appointment.js';
|
||||
import User from './models/user.js'
|
||||
// import { createAppointment } from './resolvers/Mutation.js';
|
||||
@@ -18,9 +17,6 @@ export const resolvers = {
|
||||
_id: args._id
|
||||
});
|
||||
},
|
||||
async allProducts() {
|
||||
return await Product.find();
|
||||
},
|
||||
async allUsers() {
|
||||
return await User.find();
|
||||
},
|
||||
@@ -77,33 +73,7 @@ export const resolvers = {
|
||||
args
|
||||
}, args, {
|
||||
new: true
|
||||
})
|
||||
},
|
||||
async deleteAppointment(parent, args, context, info) {
|
||||
return await Appointment.findOneAndUpdate({ _id: args._id }, { deleted: true })
|
||||
// return await Appointment.deleteOne({ _id: args._id });
|
||||
},
|
||||
async createProduct(root, {
|
||||
input
|
||||
}) {
|
||||
return await Product.create(input);
|
||||
},
|
||||
async updateProduct(root, {
|
||||
_id,
|
||||
input
|
||||
}) {
|
||||
return await Product.findOneAndUpdate({
|
||||
_id
|
||||
}, input, {
|
||||
new: true
|
||||
})
|
||||
},
|
||||
async deleteProduct(root, {
|
||||
_id
|
||||
}) {
|
||||
return await Product.findOneAndRemove({
|
||||
_id
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -6,7 +6,6 @@ type Query {
|
||||
take: Int
|
||||
orderBy: AppointmentOrderByInput
|
||||
): Feed!
|
||||
allProducts: [Product]
|
||||
allAppointments: [Appointment]
|
||||
oneAppointment(
|
||||
_id: ID!
|
||||
@@ -42,16 +41,6 @@ type Mutation {
|
||||
deleteAppointment(
|
||||
_id: ID!
|
||||
) : Appointment
|
||||
createProduct(
|
||||
input: ProductInput
|
||||
) : Product
|
||||
updateProduct(
|
||||
_id: ID!,
|
||||
input: ProductInput
|
||||
): Product
|
||||
deleteProduct(
|
||||
_id: ID!
|
||||
) : Product
|
||||
signup(
|
||||
email: String!
|
||||
password: String!
|
||||
@@ -117,17 +106,6 @@ input AppointmentOrderByInput {
|
||||
# createdAt: Sort
|
||||
}
|
||||
|
||||
# Product schemas
|
||||
type Product {
|
||||
_id: ID!
|
||||
title: String!
|
||||
qty: Int
|
||||
}
|
||||
input ProductInput {
|
||||
title: String!
|
||||
qty: Int
|
||||
}
|
||||
|
||||
# Follow schemas
|
||||
type Follow {
|
||||
_id: ID!
|
||||
|
||||
12264
server/yarn.lock
12264
server/yarn.lock
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user