11import React , { useState } from "react" ;
2- import {
3- Button ,
4- Flex ,
5- Spinner
6- } from "@chakra-ui/react" ;
2+ import { Button , Flex , Spinner } from "@chakra-ui/react" ;
73
84import { useMutation , useQuery } from "@apollo/client" ;
95
@@ -20,7 +16,10 @@ type EditParticipantCardProps = {
2016 close : ( ) => void ;
2117} ;
2218
23- const EditParticipantCard = ( { selected, close} : EditParticipantCardProps ) : React . ReactElement => {
19+ const EditParticipantCard = ( {
20+ selected,
21+ close,
22+ } : EditParticipantCardProps ) : React . ReactElement => {
2423 const [ roomNumber , setRoomNumber ] = useState ( selected . roomNumber ) ;
2524 const [ arrivalDate , setArrivalDate ] = useState ( selected . arrival ) ;
2625 const [ departureDate , setDepartureDate ] = useState ( selected . departure ) ;
@@ -38,7 +37,7 @@ const EditParticipantCard = ({selected, close}: EditParticipantCardProps): React
3837 const reset = ( ) => {
3938 setRoomNumber ( selected . roomNumber ) ;
4039 setArrivalDate ( selected . arrival ) ;
41- setDepartureDate ( selected . departure )
40+ setDepartureDate ( selected . departure ) ;
4241 setPassword ( selected . password ) ;
4342 setError ( "" ) ;
4443 } ;
@@ -47,8 +46,13 @@ const EditParticipantCard = ({selected, close}: EditParticipantCardProps): React
4746 if ( ! roomNumber || ! arrivalDate || ! password ) {
4847 setError ( "Missing fields." ) ;
4948 return false ;
50- }
51- if ( roomNumber === selected . roomNumber && arrivalDate === selected . arrival && departureDate === selected . departure && password === selected . password ) {
49+ }
50+ if (
51+ roomNumber === selected . roomNumber &&
52+ arrivalDate === selected . arrival &&
53+ departureDate === selected . departure &&
54+ password === selected . password
55+ ) {
5256 setError ( "No changes made." ) ;
5357 return false ;
5458 }
@@ -73,7 +77,7 @@ const EditParticipantCard = ({selected, close}: EditParticipantCardProps): React
7377 reset ( ) ;
7478 close ( ) ;
7579 window . location . reload ( ) ;
76- }
80+ }
7781 } catch ( err ) {
7882 setError ( "Unable to update participant." ) ;
7983 console . log ( err ) ;
@@ -86,7 +90,9 @@ const EditParticipantCard = ({selected, close}: EditParticipantCardProps): React
8690 { error && < Flex textColor = "red.500" > { error } </ Flex > }
8791
8892 < Flex flexDir = "column" >
89- < Flex mb = "5px" color = "gray.main" fontWeight = "700" > ID Number</ Flex >
93+ < Flex mb = "5px" color = "gray.main" fontWeight = "700" >
94+ ID Number
95+ </ Flex >
9096 < Flex > { selected . participantId } </ Flex >
9197 </ Flex >
9298
@@ -106,7 +112,9 @@ const EditParticipantCard = ({selected, close}: EditParticipantCardProps): React
106112 display : `Room ${ room } ` ,
107113 } ) ,
108114 ) }
109- onChange = { ( e ) => setRoomNumber ( e . target . value || selected . roomNumber ) }
115+ onChange = { ( e ) =>
116+ setRoomNumber ( e . target . value || selected . roomNumber )
117+ }
110118 />
111119 ) }
112120
@@ -155,4 +163,4 @@ const EditParticipantCard = ({selected, close}: EditParticipantCardProps): React
155163 ) ;
156164} ;
157165
158- export default EditParticipantCard ;
166+ export default EditParticipantCard ;
0 commit comments