Save and log set endpoint
This commit is contained in:
parent
2cedf0716d
commit
69a1de99e2
|
@ -44,6 +44,10 @@ const EndpointDialog = ({ endpoint }: EndpointDialogProps) => {
|
|||
return endpoint[0].startsWith("http://") || endpoint[0].startsWith("https://");
|
||||
}
|
||||
|
||||
const saveEndpoint = () => {
|
||||
localStorage.setItem("apiEndpoint", JSON.stringify(endpoint[0]));
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<IconButton aria-label="settings" onClick={openSettings}>
|
||||
|
@ -77,9 +81,15 @@ const EndpointDialog = ({ endpoint }: EndpointDialogProps) => {
|
|||
<Button onClick={closeSettings}>Close</Button>
|
||||
|
||||
<Button onClick={() => {
|
||||
isValidEndpoint()
|
||||
? closeSettings()! && closeTheError()
|
||||
: showTheError();
|
||||
if (isValidEndpoint()) {
|
||||
closeSettings();
|
||||
closeTheError();
|
||||
saveEndpoint();
|
||||
|
||||
console.log(`Endpoint set to ${endpoint[0]}.\n\nPOST URI: ${endpoint[0]}/post\nGET URI: ${endpoint[0]}/reviews`);
|
||||
} else {
|
||||
showTheError();
|
||||
}
|
||||
}}>Set</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
|
|
Loading…
Reference in a new issue