Migrace klienta na OpenAPI
All checks were successful
ci/woodpecker/push/workflow Pipeline was successful

This commit is contained in:
2025-03-19 23:08:46 +01:00
parent f09bc44d63
commit d366882f6b
45 changed files with 1068 additions and 890 deletions

View File

@@ -4,12 +4,10 @@ import { useAuth } from "../context/auth";
import SettingsModal from "./modals/SettingsModal";
import { useSettings } from "../context/settings";
import FeaturesVotingModal from "./modals/FeaturesVotingModal";
import { errorHandler } from "../api/Api";
import { getFeatureVotes, updateFeatureVote } from "../api/VotingApi";
import PizzaCalculatorModal from "./modals/PizzaCalculatorModal";
import { useNavigate } from "react-router";
import { STATS_URL } from "../AppRoutes";
import { FeatureRequest } from "../../../types";
import { FeatureRequest, getVotes, updateVote } from "../../../types";
export default function Header() {
const auth = useAuth();
@@ -18,12 +16,12 @@ export default function Header() {
const [settingsModalOpen, setSettingsModalOpen] = useState<boolean>(false);
const [votingModalOpen, setVotingModalOpen] = useState<boolean>(false);
const [pizzaModalOpen, setPizzaModalOpen] = useState<boolean>(false);
const [featureVotes, setFeatureVotes] = useState<FeatureRequest[]>([]);
const [featureVotes, setFeatureVotes] = useState<FeatureRequest[] | undefined>([]);
useEffect(() => {
if (auth?.login) {
getFeatureVotes().then(votes => {
setFeatureVotes(votes);
getVotes().then(response => {
setFeatureVotes(response.data);
})
}
}, [auth?.login]);
@@ -99,8 +97,8 @@ export default function Header() {
}
const saveFeatureVote = async (option: FeatureRequest, active: boolean) => {
await errorHandler(() => updateFeatureVote(option, active));
const votes = [...featureVotes];
await updateVote({ body: { option, active } });
const votes = [...featureVotes || []];
if (active) {
votes.push(option);
} else {