From 30b99374bafbce25303d612b0e674b765ad7b2f9 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 23 Sep 2020 17:28:12 -0300 Subject: [PATCH] Fix Compile errors. --- .vercelignore | 1 + lib/{cart.ts => cart.js} | 28 ++++++++++++++-------------- tsconfig.json | 1 - ui/Button/Button.tsx | 6 +++--- 4 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 .vercelignore rename lib/{cart.ts => cart.js} (76%) diff --git a/.vercelignore b/.vercelignore new file mode 100644 index 000000000..a65b41774 --- /dev/null +++ b/.vercelignore @@ -0,0 +1 @@ +lib diff --git a/lib/cart.ts b/lib/cart.js similarity index 76% rename from lib/cart.ts rename to lib/cart.js index a79e2110e..56ca447b1 100644 --- a/lib/cart.ts +++ b/lib/cart.js @@ -1,5 +1,5 @@ -import { useState, useCallback } from 'react'; -import useSWR, { mutate } from 'swr'; +import { useState, useCallback } from "react"; +import useSWR, { mutate } from "swr"; async function getText(res) { try { @@ -10,7 +10,7 @@ async function getText(res) { } async function getError(res) { - if (res.headers.get('Content-Type')?.includes('application/json')) { + if (res.headers.get("Content-Type")?.includes("application/json")) { const data = await res.json(); return data.errors[0]; } @@ -27,7 +27,7 @@ async function fetcher(url) { } export function useCart() { - return useSWR('/api/cart', fetcher); + return useSWR("/api/cart", fetcher); } export function useAddToCart() { @@ -37,10 +37,10 @@ export function useAddToCart() { const addToCart = useCallback(async ({ product }) => { setStatus({ addingToCart: true }); - const res = await fetch('/api/cart', { - method: 'POST', + const res = await fetch("/api/cart", { + method: "POST", headers: { - 'Content-Type': 'application/json', + "Content-Type": "application/json", }, body: JSON.stringify({ product }), }); @@ -48,12 +48,12 @@ export function useAddToCart() { // Product added as expected if (res.status === 200) { setStatus({ addingToCart: false }); - return mutate('/api/cart'); + return mutate("/api/cart"); } const error = await getError(res); - console.error('Adding product to cart failed with:', res.status, error); + console.error("Adding product to cart failed with:", res.status, error); setStatus({ addingToCart: false, error }); }, []); @@ -70,11 +70,11 @@ export function useUpdateCart() { const res = await fetch( `/api/cart?itemId=${item.id}`, product.quantity < 1 - ? { method: 'DELETE' } + ? { method: "DELETE" } : { - method: 'PUT', + method: "PUT", headers: { - 'Content-Type': 'application/json', + "Content-Type": "application/json", }, body: JSON.stringify({ product }), } @@ -83,12 +83,12 @@ export function useUpdateCart() { // Product updated as expected if (res.status === 200) { setStatus({ updatingCart: false }); - return mutate('/api/cart'); + return mutate("/api/cart"); } const error = await getError(res); - console.error('Update to cart failed with:', res.status, error); + console.error("Update to cart failed with:", res.status, error); setStatus({ updatingCart: false, error }); }, []); diff --git a/tsconfig.json b/tsconfig.json index 6cd5171d6..7a2d7ac8a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,7 +16,6 @@ "jsx": "preserve", "paths": { "@components/*": ["components/*"], - "@lib/*": ["lib/*"], "@styles/*": ["styles/*"] } }, diff --git a/ui/Button/Button.tsx b/ui/Button/Button.tsx index 0e2d78b3a..de1750838 100644 --- a/ui/Button/Button.tsx +++ b/ui/Button/Button.tsx @@ -7,7 +7,6 @@ interface Props extends ButtonHTMLAttributes { className?: string; variant?: "filled" | "outlined" | "flat" | "none"; active?: boolean; - disabled?: boolean; type?: "submit" | "reset" | "button"; } @@ -24,7 +23,9 @@ export default class Button extends React.Component { } = this.props; let Component: React.ComponentType< - React.ButtonHTMLAttributes & + React.AnchorHTMLAttributes< + HTMLAnchorElement | HTMLButtonElement | HTMLDivElement + > & React.ClassAttributes > = "a" as any; @@ -41,7 +42,6 @@ export default class Button extends React.Component { return (