Skip to content

Commit

Permalink
Updates to register
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariel Virgulto committed Nov 7, 2023
1 parent 9126fc7 commit d07686d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/views/Patient/PatientView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
11 changes: 6 additions & 5 deletions src/views/Register.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -11,12 +11,12 @@ const Register = (props: RegisterProps) => {
const [fhirUrl, setFhirUrl] = useState<string>('');
const [newSelection, setNewSelection] = useState<boolean>(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));
}
Expand All @@ -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) {
Expand Down

0 comments on commit d07686d

Please sign in to comment.