diff --git a/src/views/Patient/PatientView.tsx b/src/views/Patient/PatientView.tsx index 1555510..6882078 100644 --- a/src/views/Patient/PatientView.tsx +++ b/src/views/Patient/PatientView.tsx @@ -73,6 +73,7 @@ function PatientView(props: PatientViewProps) { function onSubmit(clientId: string, fhirUrl: string) { console.log('client id -- > ', clientId); console.log('fhirUrl -- > ', fhirUrl); + handleCloseRegisterPage(); } return ( diff --git a/src/views/Register.tsx b/src/views/Register.tsx index 3a0ea0d..4a1a04a 100644 --- a/src/views/Register.tsx +++ b/src/views/Register.tsx @@ -1,5 +1,5 @@ import { Button, IconButton } from '@mui/material'; -import React, { memo, useState } from 'react'; +import React, { memo, useEffect, useState } from 'react'; import CloseIcon from '@mui/icons-material/Close'; interface RegisterProps { @@ -11,12 +11,12 @@ const Register = (props: RegisterProps) => { const [fhirUrl, setFhirUrl] = useState(''); const [newSelection, setNewSelection] = useState(true); - const currentClients = JSON.parse(localStorage.getItem('clients') || '[]'); - console.log('current clients -- > ', currentClients); + const [currentClients, setCurrentClients] = useState(JSON.parse(localStorage.getItem('clients') || '[]')); function submit() { console.log('wants to submit --> ', { name: fhirUrl, client: clientId }); if (newSelection) { + console.log('new selection add to LS'); currentClients.push({name: fhirUrl, client: clientId }); localStorage.setItem('clients', JSON.stringify(currentClients)); } @@ -30,8 +30,9 @@ const Register = (props: RegisterProps) => { } function deleteClient(client: any) { - console.log('client to delete is-- > ', client); - + const newClients = currentClients.filter((c: { name: any; client: any; }) => !(c.name === client.name && c.client === client.client)); + localStorage.setItem('clients', JSON.stringify(newClients)); + setCurrentClients(newClients); } function selectClient(client: any) {