diff --git a/client/src/components/UpdateAppointment.js b/client/src/components/UpdateAppointment.js
new file mode 100644
index 0000000..acdcb7b
--- /dev/null
+++ b/client/src/components/UpdateAppointment.js
@@ -0,0 +1,185 @@
+import React, { useState } from 'react';
+import { useHistory } from 'react-router';
+import { useMutation, gql, useQuery } from '@apollo/client';
+import { APPOINTMENTS_PER_PAGE } from '../constants';
+import { APPOINTMENTS_QUERY } from './AppointmentList';
+import Datetime from 'react-datetime';
+import "react-datetime/css/react-datetime.css";
+
+const ONE_APPOINTMENT_QUERY = gql`
+ query OneAppointmentQuery(
+ $_id: ID!
+ ){
+ oneAppointments(_id: $id){
+ _id
+ title
+ description
+ start
+ end
+ }
+ }
+`;
+
+const UPDATE_APPOINTMENT_MUTATION = gql`
+ mutation UpdateAppointmentMutation(
+ $_id: ID!
+ $title: String!
+ $description: String!
+ $start: String!
+ $end: String!
+ ) {
+ updateAppointment(title: $title, description: $description, start: $start, end: $end) {
+ _id
+ title
+ description
+ start
+ end
+ }
+ }
+`;
+
+const UpdateAppointment = ({ match: { params: { _id } } }) => {
+ console.log(_id);
+ const history = useHistory();
+
+ // const { data } = useQuery(ONE_APPOINTMENT_QUERY, {
+ // variables: {
+ // _id: _id
+ // }
+ // });
+
+ let [formState, setFormState] = useState({
+ _id: '',
+ title: '',
+ description: '',
+ start: '',
+ end: ''
+ });
+
+ const {
+ data,
+ loading,
+ error
+ } = useQuery(ONE_APPOINTMENT_QUERY, {
+ variables: {
+ _id: _id
+ }
+ });
+
+ if (loading) {
+ console.log("yes")
+ } else {
+ console.log(data);
+ // [formState, setFormState] = useState({
+ // _id: data._id,
+ // title: data.title,
+ // description: data.description,
+ // start: data.start,
+ // end: data.end
+ // });
+ // formState.setFormState({
+ // title: "ykkg"
+ // })
+ }
+
+
+ const [updateAppointment] = useMutation(UPDATE_APPOINTMENT_MUTATION, {
+ variables: {
+ _id: formState._id,
+ title: formState.title,
+ description: formState.description,
+ start: formState.start,
+ end: formState.end
+ },
+ // update: (cache, { data: { createAppointment } }) => {
+ // const take = APPOINTMENTS_PER_PAGE;
+ // const skip = 0;
+ // const orderBy = { createdAt: 'desc' };
+
+ // const data = cache.readQuery({
+ // query: APPOINTMENTS_QUERY,
+ // variables: {
+ // take,
+ // skip,
+ // orderBy
+ // }
+ // });
+
+ // cache.writeQuery({
+ // query: APPOINTMENTS_QUERY,
+ // data: {
+ // allAppointments: {
+ // appointments: [createAppointment, ...data.allAppointments]
+ // }
+ // },
+ // variables: {
+ // take,
+ // skip,
+ // orderBy
+ // }
+ // });
+ // },
+ onCompleted: () => history.push('/')
+ });
+
+ return (
+
+ );
+};
+
+export default UpdateAppointment;
\ No newline at end of file
diff --git a/server/src/resolvers.js b/server/src/resolvers.js
index 1d389ed..208da0e 100644
--- a/server/src/resolvers.js
+++ b/server/src/resolvers.js
@@ -12,6 +12,12 @@ export const resolvers = {
async allAppointments() {
return await Appointment.find();
},
+ async oneAppointment(root, args, context, info) {
+ console.log(args);
+ return await Appointment.findOne({
+ _id: args._id
+ });
+ },
async allProducts() {
return await Product.find();
},
diff --git a/server/src/schema.graphql b/server/src/schema.graphql
index fc420a0..bbf4ebc 100644
--- a/server/src/schema.graphql
+++ b/server/src/schema.graphql
@@ -8,6 +8,9 @@ type Query {
): Feed!
allProducts: [Product]
allAppointments: [Appointment]
+ oneAppointment(
+ _id: ID!
+ ): Appointment
allUsers: [User]
users: [User!]!
}