Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
goncy committed Feb 17, 2024
1 parent a192582 commit 2289b1e
Show file tree
Hide file tree
Showing 16 changed files with 158 additions and 124 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ module.exports = {
],
"@next/next/no-img-element": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-confusing-void-expression": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/prefer-promise-reject-errors": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unused-vars": [
Expand Down
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"name": "almacency",
"name": "store",
"version": "0.1.0",
"private": true,
"packageManager": "[email protected]",
"engines": {
"node": "18.x"
},
"scripts": {
"dev": "next dev",
"build": "next build",
Expand Down
40 changes: 19 additions & 21 deletions src/components/ui/input.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import * as React from "react"
import * as React from "react";

import { cn } from "@/lib/utils"
import {cn} from "@/lib/utils";

export interface InputProps
extends React.InputHTMLAttributes<HTMLInputElement> {}
export type InputProps = React.InputHTMLAttributes<HTMLInputElement>;

const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ className, type, ...props }, ref) => {
return (
<input
type={type}
className={cn(
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
className
)}
ref={ref}
{...props}
/>
)
}
)
Input.displayName = "Input"
const Input = React.forwardRef<HTMLInputElement, InputProps>(({className, type, ...props}, ref) => {
return (
<input
ref={ref}
className={cn(
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
className,
)}
type={type}
{...props}
/>
);
});

export { Input }
Input.displayName = "Input";

export {Input};
32 changes: 14 additions & 18 deletions src/components/ui/label.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
"use client"
"use client";

import * as React from "react"
import * as LabelPrimitive from "@radix-ui/react-label"
import { cva, type VariantProps } from "class-variance-authority"
import * as React from "react";
import * as LabelPrimitive from "@radix-ui/react-label";
import {cva, type VariantProps} from "class-variance-authority";

import { cn } from "@/lib/utils"
import {cn} from "@/lib/utils";

const labelVariants = cva(
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
)
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
);

const Label = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
VariantProps<typeof labelVariants>
>(({ className, ...props }, ref) => (
<LabelPrimitive.Root
ref={ref}
className={cn(labelVariants(), className)}
{...props}
/>
))
Label.displayName = LabelPrimitive.Root.displayName
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants>
>(({className, ...props}, ref) => (
<LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />
));

export { Label }
Label.displayName = LabelPrimitive.Root.displayName;

export {Label};
38 changes: 17 additions & 21 deletions src/components/ui/radio-group.tsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,40 @@
"use client"
"use client";

import * as React from "react"
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"
import { Circle } from "lucide-react"
import * as React from "react";
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
import {Circle} from "lucide-react";

import { cn } from "@/lib/utils"
import {cn} from "@/lib/utils";

const RadioGroup = React.forwardRef<
React.ElementRef<typeof RadioGroupPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
>(({ className, ...props }, ref) => {
return (
<RadioGroupPrimitive.Root
className={cn("grid gap-2", className)}
{...props}
ref={ref}
/>
)
})
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName
>(({className, ...props}, ref) => {
return <RadioGroupPrimitive.Root className={cn("grid gap-2", className)} {...props} ref={ref} />;
});

RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;

const RadioGroupItem = React.forwardRef<
React.ElementRef<typeof RadioGroupPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
>(({ className, ...props }, ref) => {
>(({className, ...props}, ref) => {
return (
<RadioGroupPrimitive.Item
ref={ref}
className={cn(
"aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
className
className,
)}
{...props}
>
<RadioGroupPrimitive.Indicator className="flex items-center justify-center">
<Circle className="h-2.5 w-2.5 fill-current text-current" />
</RadioGroupPrimitive.Indicator>
</RadioGroupPrimitive.Item>
)
})
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName
);
});

RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;

export { RadioGroup, RadioGroupItem }
export {RadioGroup, RadioGroupItem};
16 changes: 4 additions & 12 deletions src/components/ui/skeleton.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import { cn } from "@/lib/utils"
import {cn} from "@/lib/utils";

function Skeleton({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) {
return (
<div
className={cn("animate-pulse rounded-md bg-muted", className)}
{...props}
/>
)
function Skeleton({className, ...props}: React.HTMLAttributes<HTMLDivElement>) {
return <div className={cn("animate-pulse rounded-md bg-muted", className)} {...props} />;
}

export { Skeleton }
export {Skeleton};
30 changes: 14 additions & 16 deletions src/components/ui/toggle.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
"use client"
"use client";

import * as React from "react"
import * as TogglePrimitive from "@radix-ui/react-toggle"
import { cva, type VariantProps } from "class-variance-authority"
import * as React from "react";
import * as TogglePrimitive from "@radix-ui/react-toggle";
import {cva, type VariantProps} from "class-variance-authority";

import { cn } from "@/lib/utils"
import {cn} from "@/lib/utils";

const toggleVariants = cva(
"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",
{
variants: {
variant: {
default: "bg-transparent",
outline:
"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground",
outline: "border border-input bg-transparent hover:bg-accent hover:text-accent-foreground",
},
size: {
default: "h-10 px-3",
Expand All @@ -25,21 +24,20 @@ const toggleVariants = cva(
variant: "default",
size: "default",
},
}
)
},
);

const Toggle = React.forwardRef<
React.ElementRef<typeof TogglePrimitive.Root>,
React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> &
VariantProps<typeof toggleVariants>
>(({ className, variant, size, ...props }, ref) => (
React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>
>(({className, variant, size, ...props}, ref) => (
<TogglePrimitive.Root
ref={ref}
className={cn(toggleVariants({ variant, size, className }))}
className={cn(toggleVariants({variant, size, className}))}
{...props}
/>
))
));

Toggle.displayName = TogglePrimitive.Root.displayName
Toggle.displayName = TogglePrimitive.Root.displayName;

export { Toggle, toggleVariants }
export {Toggle, toggleVariants};
6 changes: 3 additions & 3 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"
import {type ClassValue, clsx} from "clsx";
import {twMerge} from "tailwind-merge";

export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
return twMerge(clsx(inputs));
}
16 changes: 11 additions & 5 deletions src/modules/cart/components/CartDrawer/CartDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ function CartDrawer({

function handleUpdateCart(id: number, item: CartItem) {
if (!item.quantity) {
return removeItem(id);
removeItem(id);

return;
}

return updateItem(id, item);
updateItem(id, item);
}

function handleUpdateField(id: string, value: string) {
return updateField(id, value);
updateField(id, value);
}

useEffect(() => {
Expand Down Expand Up @@ -82,7 +84,9 @@ function CartDrawer({
data-testid="continue-order"
size="lg"
variant="brand"
onClick={() => setCurrentStep("fields")}
onClick={() => {
setCurrentStep("fields");
}}
>
Continuar
</Button>
Expand All @@ -95,7 +99,9 @@ function CartDrawer({
className="w-full"
size="lg"
variant="ghost"
onClick={() => setCurrentStep("details")}
onClick={() => {
setCurrentStep("details");
}}
>
Revisar pedido
</Button>
Expand Down
13 changes: 8 additions & 5 deletions src/modules/cart/components/CartDrawer/Details.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type {Cart, CartItem} from "../../types";

import {Button} from "@/components/ui/button";
import {parseCurrency} from "~/currency/utils";

import {Button} from "@/components/ui/button";

import {getCartItemPrice, getCartItemOptionsSummary} from "../../utils";

function Details({cart, onChange}: {cart: Cart; onChange: (id: number, item: CartItem) => void}) {
Expand All @@ -26,9 +27,10 @@ function Details({cart, onChange}: {cart: Cart; onChange: (id: number, item: Car
<Button
className="text-md h-6 w-6 rounded-full"
data-testid="decrement"
size="xs"
variant="brand"
onClick={() => onChange(id, {...item, quantity: item.quantity - 1})}
onClick={() => {
onChange(id, {...item, quantity: item.quantity - 1});
}}
>
{" "}
-{" "}
Expand All @@ -39,9 +41,10 @@ function Details({cart, onChange}: {cart: Cart; onChange: (id: number, item: Car
<Button
className="text-md h-6 w-6 rounded-full"
data-testid="increment"
size="xs"
variant="brand"
onClick={() => onChange(id, {...item, quantity: item.quantity + 1})}
onClick={() => {
onChange(id, {...item, quantity: item.quantity + 1});
}}
>
{" "}
+{" "}
Expand Down
18 changes: 15 additions & 3 deletions src/modules/cart/components/CartDrawer/Fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ function TextField({
}: Omit<React.ComponentProps<typeof Input>, "onChange"> & {
onChange: (value: string) => void;
}) {
return <Input value={value} onChange={(e) => onChange(e.target.value)} {...props} />;
return (
<Input
value={value}
onChange={(e) => {
onChange(e.target.value);
}}
{...props}
/>
);
}

function RadioField({
Expand Down Expand Up @@ -59,14 +67,18 @@ function Fields({
<TextField
placeholder={field.placeholder}
value={checkout.get(field.title) || ""}
onChange={(value: string) => onChange(field.title, value)}
onChange={(value: string) => {
onChange(field.title, value);
}}
/>
)}
{field.type === "radio" && (
<RadioField
options={field.options}
value={checkout.get(field.title) || ""}
onChange={(value: string) => onChange(field.title, value)}
onChange={(value: string) => {
onChange(field.title, value);
}}
/>
)}
{field.note ? <Alert>{field.note}</Alert> : null}
Expand Down
Loading

0 comments on commit 2289b1e

Please sign in to comment.