@@ -3,13 +3,12 @@ import { useForm } from 'react-hook-form'
33import { useMutation , useQueryClient } from 'react-query'
44import toast , { Toaster } from 'react-hot-toast'
55import { useEffect , useRef , useState } from 'react'
6- import { useSession } from 'next-auth/client'
7- import { User } from 'src/pages/members'
86import { Markdown , GoalType } from '@/components'
97
108type Inputs = {
119 title : string
1210 description : string
11+ deadline : Date
1312}
1413
1514export default function EditGoal ( {
@@ -26,7 +25,6 @@ export default function EditGoal({
2625 const queryClient = useQueryClient ( )
2726 const { register, handleSubmit, errors, trigger } = useForm < Inputs > ( )
2827 const toastId = useRef ( '' )
29- const [ session ] = useSession ( )
3028 const { mutate } = useMutation (
3129 ( data : Inputs ) =>
3230 fetch ( `/api/fauna/goals/update-goal` , {
@@ -39,6 +37,7 @@ export default function EditGoal({
3937 title : data . title ,
4038 description : data . description ,
4139 creatorId : goal . creatorId ,
40+ deadline : data . deadline ,
4241 } ) ,
4342 } ) . then ( ( res ) => {
4443 if ( ! res . ok ) {
@@ -71,7 +70,7 @@ export default function EditGoal({
7170 < div className = "mt-6" >
7271 < div className = "flex space-x-3" >
7372 < div className = "min-w-0 flex-1" >
74- < form onSubmit = { handleSubmit ( onSubmit ) } >
73+ < form onSubmit = { handleSubmit ( onSubmit ) } className = "space-y-3" >
7574 < Input
7675 ref = { register ( { required : true , maxLength : 50 } ) }
7776 defaultValue = { goal . title }
@@ -87,6 +86,16 @@ export default function EditGoal({
8786 }
8887 />
8988
89+ < Input
90+ type = "date"
91+ label = "Goal Deadline"
92+ ref = { register ( { valueAsDate : true , required : true } ) }
93+ name = "deadline"
94+ defaultValue = { goal . deadline . toISODate ( ) }
95+ hasError = { Boolean ( errors . deadline ) }
96+ errorMessage = "You must set the deadline."
97+ />
98+
9099 < TextArea
91100 ref = { register }
92101 defaultValue = { goal . description }
0 commit comments