Migrace klienta na OpenAPI
All checks were successful
ci/woodpecker/push/workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/workflow Pipeline was successful
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Table } from "react-bootstrap";
|
||||
import PizzaOrderRow from "./PizzaOrderRow";
|
||||
import { updatePizzaFee } from "../api/PizzaDayApi";
|
||||
import { PizzaDayState, PizzaOrder, PizzaVariant } from "../../../types";
|
||||
import { PizzaDayState, PizzaOrder, PizzaVariant, updatePizzaFee } from "../../../types";
|
||||
|
||||
type Props = {
|
||||
state: PizzaDayState,
|
||||
@@ -12,7 +11,7 @@ type Props = {
|
||||
|
||||
export default function PizzaOrderList({ state, orders, onDelete, creator }: Readonly<Props>) {
|
||||
const saveFees = async (customer: string, text?: string, price?: number) => {
|
||||
await updatePizzaFee(customer, text, price);
|
||||
await updatePizzaFee({ body: { login: customer, text, price } });
|
||||
}
|
||||
|
||||
if (!orders?.length) {
|
||||
|
||||
Reference in New Issue
Block a user