gesJav-wocxo3-vedgyg
This commit is contained in:
@@ -6,7 +6,6 @@ import CreateAppointment from './appointment/CreateAppointment';
|
|||||||
import UpdateAppointemnt from './appointment/UpdateAppointment';
|
import UpdateAppointemnt from './appointment/UpdateAppointment';
|
||||||
import Calendar from './Calendar';
|
import Calendar from './Calendar';
|
||||||
import { Switch, Route } from 'react-router-dom';
|
import { Switch, Route } from 'react-router-dom';
|
||||||
// import ProductList from './ProductList';
|
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
return (
|
return (
|
||||||
@@ -14,7 +13,6 @@ const App = () => {
|
|||||||
<Header />
|
<Header />
|
||||||
<div className="ph3 pv1 background-gray">
|
<div className="ph3 pv1 background-gray">
|
||||||
<Switch>
|
<Switch>
|
||||||
{/* <Route exact path="/" component={ProductList} /> */}
|
|
||||||
<Route exact path="/" component={AppointmentList} />
|
<Route exact path="/" component={AppointmentList} />
|
||||||
<Route exact path="/create" component={CreateAppointment} />
|
<Route exact path="/create" component={CreateAppointment} />
|
||||||
<Route exact path="/update/:_id" component={UpdateAppointemnt} />
|
<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('/')
|
onCompleted: () => history.push('/')
|
||||||
})
|
})
|
||||||
|
|
||||||
const updateAppointment = () => {
|
// const updateAppointment = () => {
|
||||||
let path = `/update/${appointment._id}`;
|
// let path = `/update/${appointment._id}`;
|
||||||
history.push(path);
|
// history.push(path);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<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>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -23,14 +23,14 @@
|
|||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"esm": "^3.2.25",
|
"esm": "^3.2.25",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"express-graphql": "^0.12.0",
|
"express-graphql": "*",
|
||||||
"graphql": "^15.4.0",
|
"graphql": "*",
|
||||||
"graphql-compose": "^7.23.0",
|
"graphql-compose": "*",
|
||||||
"graphql-compose-connection": "^8.0.1",
|
"graphql-compose-connection": "*",
|
||||||
"graphql-compose-mongoose": "^9.0.0",
|
"graphql-compose-mongoose": "*",
|
||||||
"graphql-depth-limit": "^1.1.0",
|
"graphql-depth-limit": "*",
|
||||||
"graphql-middleware": "^6.0.0",
|
"graphql-middleware": "*",
|
||||||
"graphql-tools": "^7.0.2",
|
"graphql-tools": "*",
|
||||||
"jsonwebtoken": "8.5.1",
|
"jsonwebtoken": "8.5.1",
|
||||||
"migrate": "^1.7.0",
|
"migrate": "^1.7.0",
|
||||||
"mocha": "^8.2.1",
|
"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 Appointment from '../../client/src/components/Appointment.js';
|
||||||
import Product from './models/product.js';
|
|
||||||
import Appointment from './models/appointment.js';
|
import Appointment from './models/appointment.js';
|
||||||
import User from './models/user.js'
|
import User from './models/user.js'
|
||||||
// import { createAppointment } from './resolvers/Mutation.js';
|
// import { createAppointment } from './resolvers/Mutation.js';
|
||||||
@@ -18,9 +17,6 @@ export const resolvers = {
|
|||||||
_id: args._id
|
_id: args._id
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async allProducts() {
|
|
||||||
return await Product.find();
|
|
||||||
},
|
|
||||||
async allUsers() {
|
async allUsers() {
|
||||||
return await User.find();
|
return await User.find();
|
||||||
},
|
},
|
||||||
@@ -77,33 +73,7 @@ export const resolvers = {
|
|||||||
args
|
args
|
||||||
}, args, {
|
}, args, {
|
||||||
new: true
|
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
|
take: Int
|
||||||
orderBy: AppointmentOrderByInput
|
orderBy: AppointmentOrderByInput
|
||||||
): Feed!
|
): Feed!
|
||||||
allProducts: [Product]
|
|
||||||
allAppointments: [Appointment]
|
allAppointments: [Appointment]
|
||||||
oneAppointment(
|
oneAppointment(
|
||||||
_id: ID!
|
_id: ID!
|
||||||
@@ -42,16 +41,6 @@ type Mutation {
|
|||||||
deleteAppointment(
|
deleteAppointment(
|
||||||
_id: ID!
|
_id: ID!
|
||||||
) : Appointment
|
) : Appointment
|
||||||
createProduct(
|
|
||||||
input: ProductInput
|
|
||||||
) : Product
|
|
||||||
updateProduct(
|
|
||||||
_id: ID!,
|
|
||||||
input: ProductInput
|
|
||||||
): Product
|
|
||||||
deleteProduct(
|
|
||||||
_id: ID!
|
|
||||||
) : Product
|
|
||||||
signup(
|
signup(
|
||||||
email: String!
|
email: String!
|
||||||
password: String!
|
password: String!
|
||||||
@@ -117,17 +106,6 @@ input AppointmentOrderByInput {
|
|||||||
# createdAt: Sort
|
# createdAt: Sort
|
||||||
}
|
}
|
||||||
|
|
||||||
# Product schemas
|
|
||||||
type Product {
|
|
||||||
_id: ID!
|
|
||||||
title: String!
|
|
||||||
qty: Int
|
|
||||||
}
|
|
||||||
input ProductInput {
|
|
||||||
title: String!
|
|
||||||
qty: Int
|
|
||||||
}
|
|
||||||
|
|
||||||
# Follow schemas
|
# Follow schemas
|
||||||
type Follow {
|
type Follow {
|
||||||
_id: ID!
|
_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