Fix grabbing endpoint from localStorage

This commit is contained in:
powermaker450 2024-09-11 23:53:54 -04:00
parent ca4afb1896
commit c74a7b80ed
5 changed files with 8 additions and 10 deletions

View file

@ -1,4 +1,3 @@
import React from "react";
import "./App.css";
import { Route, Routes } from "react-router-dom";
import Home from "./pages/Home";

View file

@ -1,4 +1,3 @@
import React from "react";
import { Button, Grid2 } from "@mui/material";
export interface ActionProps {

View file

@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import { useEffect, useState } from "react";
import { Button, ButtonGroup, Tooltip, Zoom } from "@mui/material";
import { Link } from "react-router-dom";

View file

@ -1,4 +1,3 @@
import React from "react";
import {
List,
ListItem,
@ -30,7 +29,7 @@ function ShowReviews({ reviews }: ShowReviewsProps) {
return (
<List sx={{ width: "100%", maxWidth: 460 }}>
{reviews.map((review, index) => {
{reviews.map((review) => {
return (
<Slide direction="up" in mountOnEnter key={review.id}>
<Paper elevation={2} sx={{ width: "100%", maxWidth: 460 }}>

View file

@ -11,7 +11,7 @@ import {
import "../App.css";
import ButtonRow, { ActionProps } from "../components/ButtonRow";
import ReviewField, { ReviewFieldProps } from "../components/ReviewField";
import { useState } from "react";
import { useEffect, useState } from "react";
import EndpointDialog from "../components/EndpointDialong";
import PageSwitcher from "../components/PageSwitcher";
@ -125,9 +125,7 @@ function Home({ endpoint, setEndpoint, secure, setSecure }: HomeProps) {
};
const getEmptyFields = () => {
return !endpoint
? "Endpoint is not set!"
: !rating
return !rating
? "You must input a rating!"
: fields[0].dynamicState[0].length < 2
? "You must enter a username at least 2 characters long!"
@ -150,7 +148,10 @@ function Home({ endpoint, setEndpoint, secure, setSecure }: HomeProps) {
const info = <Alert severity="info">{infoText}</Alert>;
const alert = <Alert severity="error">{alertText}</Alert>;
setEndpoint(JSON.parse(localStorage.getItem("apiEndpoint")!) || "");
useEffect(() => {
setEndpoint(JSON.parse(localStorage.getItem("apiEndpoint")!) || "");
}, []);
return (
<>