Some fixes
This commit is contained in:
@@ -14,6 +14,7 @@ const ONE_APPOINTMENT_QUERY = gql`
|
|||||||
_id
|
_id
|
||||||
title
|
title
|
||||||
description
|
description
|
||||||
|
type
|
||||||
start
|
start
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
@@ -24,14 +25,16 @@ const UPDATE_APPOINTMENT_MUTATION = gql`
|
|||||||
mutation UpdateAppointmentMutation(
|
mutation UpdateAppointmentMutation(
|
||||||
$_id: ID!
|
$_id: ID!
|
||||||
$title: String!
|
$title: String!
|
||||||
$description: String!
|
$description: String
|
||||||
$start: String!
|
$type: String!
|
||||||
$end: String!
|
$start: DateTime!
|
||||||
|
$end: DateTime!
|
||||||
) {
|
) {
|
||||||
updateAppointment(title: $title, description: $description, start: $start, end: $end) {
|
updateAppointment(title: $title, description: $description, start: $start, end: $end) {
|
||||||
_id
|
_id
|
||||||
title
|
title
|
||||||
description
|
description
|
||||||
|
type
|
||||||
start
|
start
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
@@ -48,11 +51,12 @@ const UpdateAppointment = ({ match: { params: { _id } } }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let [formState, setFormState] = useState({
|
let [formState, setFormState] = useState({
|
||||||
_id: '',
|
// _id: '',
|
||||||
title: '',
|
// title: '',
|
||||||
description: '',
|
// description: '',
|
||||||
start: '',
|
// type: '',
|
||||||
end: ''
|
// start: '',
|
||||||
|
// end: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
const [updateAppointment] = useMutation(UPDATE_APPOINTMENT_MUTATION, {
|
const [updateAppointment] = useMutation(UPDATE_APPOINTMENT_MUTATION, {
|
||||||
@@ -60,6 +64,7 @@ const UpdateAppointment = ({ match: { params: { _id } } }) => {
|
|||||||
_id: formState._id,
|
_id: formState._id,
|
||||||
title: formState.title,
|
title: formState.title,
|
||||||
description: formState.description,
|
description: formState.description,
|
||||||
|
type: formState.type,
|
||||||
start: formState.start,
|
start: formState.start,
|
||||||
end: formState.end
|
end: formState.end
|
||||||
},
|
},
|
||||||
@@ -69,6 +74,9 @@ const UpdateAppointment = ({ match: { params: { _id } } }) => {
|
|||||||
if (data === undefined) {
|
if (data === undefined) {
|
||||||
return <div>Loading...</div>
|
return <div>Loading...</div>
|
||||||
} else {
|
} else {
|
||||||
|
// setFormState({
|
||||||
|
// formState.title= data.oneAppointment.title
|
||||||
|
// })
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -88,7 +96,7 @@ const UpdateAppointment = ({ match: { params: { _id } } }) => {
|
|||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
className="mb2"
|
className="mb2"
|
||||||
value={data.oneAppointment.title}
|
value={formState.title}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
setFormState({
|
setFormState({
|
||||||
...formState,
|
...formState,
|
||||||
@@ -110,6 +118,18 @@ const UpdateAppointment = ({ match: { params: { _id } } }) => {
|
|||||||
type="text"
|
type="text"
|
||||||
placeholder="Input description"
|
placeholder="Input description"
|
||||||
/>
|
/>
|
||||||
|
<input
|
||||||
|
className="mb2"
|
||||||
|
value={data.oneAppointment.type}
|
||||||
|
onChange={(e) =>
|
||||||
|
setFormState({
|
||||||
|
...formState,
|
||||||
|
type: e.target.value
|
||||||
|
})
|
||||||
|
}
|
||||||
|
type="text"
|
||||||
|
placeholder="Input description"
|
||||||
|
/>
|
||||||
<Datetime
|
<Datetime
|
||||||
className="mb2"
|
className="mb2"
|
||||||
value={data.oneAppointment.start}
|
value={data.oneAppointment.start}
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ export const resolvers = {
|
|||||||
return await Appointment.create(args);
|
return await Appointment.create(args);
|
||||||
},
|
},
|
||||||
async updateAppointment(parent, args, context, info) {
|
async updateAppointment(parent, args, context, info) {
|
||||||
|
console.log(args);
|
||||||
return await Appointment.findOneAndUpdate({
|
return await Appointment.findOneAndUpdate({
|
||||||
args
|
args
|
||||||
}, args, {
|
}, args, {
|
||||||
|
|||||||
Reference in New Issue
Block a user