import { useMutation, useQuery } from "@apollo/client/react"; import React, { useState } from "react"; import { Link, useNavigate } from "react-router-dom"; import styles from "./Inventory.module.css"; import { GQLError } from "../../components/GQLError"; import { useToast } from "../../hooks/useToast"; import { CreateInventoryTransactionDocument, InventoryProductsDocument } from "../../types"; const LOGIN_URL = `${import.meta.env.VITE_API_URL}/accounts/login/?next=/inventory/add`; const InventoryAdd = () => { const navigate = useNavigate(); const { showToast } = useToast(); const { data, loading, error } = useQuery(InventoryProductsDocument); const [createInventoryTransaction, { loading: saving }] = useMutation(CreateInventoryTransactionDocument); const [productId, setProductId] = useState(""); const [amount, setAmount] = useState(""); const [unitPrice, setUnitPrice] = useState(""); const [comment, setComment] = useState(""); const products = data?.allProducts || []; if (loading) return
Du må være innlogget for å registrere varer. Logg inn.
{!products.length &&Ingen aktive varer å registrere.
}