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 "./App.css";
import { Route, Routes } from "react-router-dom"; import { Route, Routes } from "react-router-dom";
import Home from "./pages/Home"; import Home from "./pages/Home";

View file

@ -1,4 +1,3 @@
import React from "react";
import { Button, Grid2 } from "@mui/material"; import { Button, Grid2 } from "@mui/material";
export interface ActionProps { 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 { Button, ButtonGroup, Tooltip, Zoom } from "@mui/material";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";

View file

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

View file

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