@@ -18,14 +18,20 @@ import { DateTimePicker } from "@mantine/dates";
1818import { useForm , zodResolver } from "@mantine/form" ;
1919import { notifications } from "@mantine/notifications" ;
2020import dayjs from "dayjs" ;
21- import React , { useEffect , useState } from "react" ;
21+ import React , { FC , useEffect , useState } from "react" ;
2222import { useNavigate , useParams } from "react-router-dom" ;
2323import { z } from "zod" ;
2424import { AuthGuard } from "@ui/components/AuthGuard" ;
2525import { getRunEnvironmentConfig } from "@ui/config" ;
2626import { useApi } from "@ui/util/api" ;
2727import { AppRoles } from "@common/roles" ;
28- import { SigDetailRecord , SigMemberRecord } from "@common/types/siglead.js" ;
28+ import {
29+ SigDetailRecord ,
30+ SigMemberRecord ,
31+ SigMemberUpdateRecord ,
32+ } from "@common/types/siglead.js" ;
33+ import { getTimeInFormat } from "@common/utils" ;
34+ import { orgIds2Name } from "@common/orgs" ;
2935
3036export const ViewSigLeadPage : React . FC = ( ) => {
3137 const [ isSubmitting , setIsSubmitting ] = useState < boolean > ( false ) ;
@@ -162,7 +168,9 @@ export const ViewSigLeadPage: React.FC = () => {
162168 < Stack >
163169 < Button variant = "white" > Member Count: { sigMembers . length } </ Button >
164170
165- < Button > Add Member</ Button >
171+ < Button onClick = { ( ) => navigate ( "./addMember" ) } >
172+ Add Member
173+ </ Button >
166174 < Button
167175 onClick = { ( ) => navigate ( "../siglead-management" ) }
168176 variant = "outline"
@@ -191,3 +199,59 @@ export const ViewSigLeadPage: React.FC = () => {
191199 </ AuthGuard >
192200 ) ;
193201} ;
202+
203+ export const AddMemberToSigPage : FC = ( ) => {
204+ const { sigId } = useParams ( ) ;
205+ const api = useApi ( "core" ) ;
206+
207+ async function handleSubmit ( event : React . FormEvent < HTMLFormElement > ) {
208+ event . preventDefault ( ) ;
209+ const formData = new FormData ( event . currentTarget ) ;
210+ // console.log(formData)
211+ const data = Object . fromEntries (
212+ formData . entries ( ) ,
213+ ) as SigMemberUpdateRecord ;
214+ data . designation = "M" ;
215+ data . sigGroupId = sigId || "" ;
216+ data . createdAt = getTimeInFormat ( ) ;
217+ data . updatedAt = data . createdAt ;
218+ // console.log(data)
219+ await api . post ( `/api/v1/siglead/addMember` , data ) ;
220+ }
221+
222+ return (
223+ < AuthGuard
224+ resourceDef = { { service : "core" , validRoles : [ AppRoles . SIGLEAD_MANAGER ] } }
225+ >
226+ < h1 > Add Member to { orgIds2Name [ sigId || "acm" ] } </ h1 >
227+ < form id = "form" onSubmit = { handleSubmit } >
228+ < label htmlFor = "email" > email: </ label >
229+ < input
230+ type = "email"
231+ name = "email"
232+ id = "email"
233+ 234+ />
235+ < br />
236+ < label htmlFor = "id" > uuid: </ label >
237+ < input
238+ type = "text"
239+ name = "id"
240+ id = "id"
241+ placeholder = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
242+ />
243+ < br />
244+ < label htmlFor = "memberName" > name: </ label >
245+ < input
246+ type = "text"
247+ name = "memberName"
248+ id = "memberName"
249+ placeholder = "John Doe"
250+ />
251+ < br />
252+ { /* <button type="submit" onSubmit={handleSubmit}>Submit</button> */ }
253+ < button type = "submit" > Submit</ button >
254+ </ form >
255+ </ AuthGuard >
256+ ) ;
257+ } ;
0 commit comments