diff --git a/app/auth/login/page.tsx b/app/auth/login/page.tsx index f4bdf93..4066e29 100644 --- a/app/auth/login/page.tsx +++ b/app/auth/login/page.tsx @@ -1,5 +1,5 @@ -import dataService from '@/lib/data-service'; "use client"; +import { fetchData } from "@/lib/data-service"; import { useState } from "react"; import { useRouter } from "next/navigation"; @@ -13,7 +13,6 @@ import { Label } from "@/components/ui/label"; export default function LoginPage() { const [username, setUsername] = useState(""); // ✅ Fixed incorrect state name const [password, setPassword] = useState(""); - const [rememberMe, setRememberMe] = useState(false); // ✅ Fixed missing state const [error, setError] = useState(""); const router = useRouter(); @@ -21,18 +20,14 @@ export default function LoginPage() { e.preventDefault(); setError(""); - const res = await dataService.fetchData("https://internal-api.inboxi.ng/api/auth/login", { + const res = await fetchData("https://internal-api.inboxi.ng/api/auth/login", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ username, password }), }); - if (res.ok) { - const data = await res.json(); - console.log(data); - - document.cookie = `Authorization=${data.token}; path=/; Secure; SameSite=Strict; max-age=604800`; - + if (res.token) { + document.cookie = `Authorization=${res.token}; path=/; Secure; SameSite=Strict; max-age=604800`; router.push("/dashboard"); } else { const data = await res.json(); diff --git a/app/auth/register/page.tsx b/app/auth/register/page.tsx index 041b449..330c783 100644 --- a/app/auth/register/page.tsx +++ b/app/auth/register/page.tsx @@ -1,6 +1,5 @@ -import dataService from '@/lib/data-service'; "use client"; - +import { fetchData } from "@/lib/data-service"; import { useState } from "react"; import { useRouter } from "next/navigation"; import Image from "next/image"; @@ -22,17 +21,19 @@ export default function RegisterPage() { setError(""); setLoading(true); - const res = await dataService.fetchData("https://internal-api.inboxi.ng/api/auth/register", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ username, password, invitationCode }), - }); + const res = await fetchData( + "https://internal-api.inboxi.ng/api/auth/register", + { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ username, password, invitationCode }), + } + ); - const data = await res.json(); - - if (res.ok) { + const data = await res; + + if (res) { console.log("Registered successfully:", data); - router.push("/login"); } else { setError(data.error || "Registration failed"); @@ -45,8 +46,12 @@ export default function RegisterPage() {
-

Create an Account

-

Sign up to start selling

+

+ Create an Account +

+

+ Sign up to start selling +

{error &&

{error}

} @@ -100,11 +105,14 @@ export default function RegisterPage() {

Already have an account?{" "} - + Sign in

); -} \ No newline at end of file +} diff --git a/components/ui/accordion.tsx b/components/ui/accordion.tsx index 24c788c..f5b49e4 100644 --- a/components/ui/accordion.tsx +++ b/components/ui/accordion.tsx @@ -4,7 +4,7 @@ import * as React from "react" import * as AccordionPrimitive from "@radix-ui/react-accordion" import { ChevronDown } from "lucide-react" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; const Accordion = AccordionPrimitive.Root diff --git a/components/ui/alert-dialog.tsx b/components/ui/alert-dialog.tsx index 25e7b47..bb747d1 100644 --- a/components/ui/alert-dialog.tsx +++ b/components/ui/alert-dialog.tsx @@ -3,7 +3,7 @@ import * as React from "react" import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; import { buttonVariants } from "@/components/ui/button" const AlertDialog = AlertDialogPrimitive.Root diff --git a/components/ui/alert.tsx b/components/ui/alert.tsx index 41fa7e0..a8c94c8 100644 --- a/components/ui/alert.tsx +++ b/components/ui/alert.tsx @@ -1,7 +1,7 @@ import * as React from "react" import { cva, type VariantProps } from "class-variance-authority" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; const alertVariants = cva( "relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground", diff --git a/components/ui/avatar.tsx b/components/ui/avatar.tsx index 51e507b..e47fd7d 100644 --- a/components/ui/avatar.tsx +++ b/components/ui/avatar.tsx @@ -3,7 +3,7 @@ import * as React from "react" import * as AvatarPrimitive from "@radix-ui/react-avatar" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; const Avatar = React.forwardRef< React.ElementRef, diff --git a/components/ui/breadcrumb.tsx b/components/ui/breadcrumb.tsx index 60e6c96..6ff0e4a 100644 --- a/components/ui/breadcrumb.tsx +++ b/components/ui/breadcrumb.tsx @@ -2,7 +2,7 @@ import * as React from "react" import { Slot } from "@radix-ui/react-slot" import { ChevronRight, MoreHorizontal } from "lucide-react" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; const Breadcrumb = React.forwardRef< HTMLElement, diff --git a/components/ui/button.tsx b/components/ui/button.tsx index 3842446..5c63761 100644 --- a/components/ui/button.tsx +++ b/components/ui/button.tsx @@ -2,7 +2,7 @@ import * as React from "react" import { Slot } from "@radix-ui/react-slot" import { cva, type VariantProps } from "class-variance-authority" -import { cn } from '@/lib/styles'; +import { cn } from "@/lib/styles"; const buttonVariants = cva( "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", diff --git a/components/ui/calendar.tsx b/components/ui/calendar.tsx index 61d2b45..6a1ccf9 100644 --- a/components/ui/calendar.tsx +++ b/components/ui/calendar.tsx @@ -4,7 +4,7 @@ import * as React from "react" import { ChevronLeft, ChevronRight } from "lucide-react" import { DayPicker } from "react-day-picker" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; import { buttonVariants } from "@/components/ui/button" export type CalendarProps = React.ComponentProps diff --git a/components/ui/carousel.tsx b/components/ui/carousel.tsx index ec505d0..75ced14 100644 --- a/components/ui/carousel.tsx +++ b/components/ui/carousel.tsx @@ -6,7 +6,7 @@ import useEmblaCarousel, { } from "embla-carousel-react" import { ArrowLeft, ArrowRight } from "lucide-react" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; import { Button } from "@/components/ui/button" type CarouselApi = UseEmblaCarouselType[1] diff --git a/components/ui/chart.tsx b/components/ui/chart.tsx index 8620baa..1b1ff89 100644 --- a/components/ui/chart.tsx +++ b/components/ui/chart.tsx @@ -3,7 +3,7 @@ import * as React from "react" import * as RechartsPrimitive from "recharts" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; // Format: { THEME_NAME: CSS_SELECTOR } const THEMES = { light: "", dark: ".dark" } as const diff --git a/components/ui/checkbox.tsx b/components/ui/checkbox.tsx index 9cfca2c..8d8d005 100644 --- a/components/ui/checkbox.tsx +++ b/components/ui/checkbox.tsx @@ -4,7 +4,7 @@ import * as React from "react" import * as CheckboxPrimitive from "@radix-ui/react-checkbox" import { Check } from "lucide-react" -import { cn } from '@/lib/styles'; +import { cn } from "@/lib/styles"; const Checkbox = React.forwardRef< React.ElementRef, diff --git a/components/ui/command.tsx b/components/ui/command.tsx index 59a2645..745fba7 100644 --- a/components/ui/command.tsx +++ b/components/ui/command.tsx @@ -5,7 +5,7 @@ import { type DialogProps } from "@radix-ui/react-dialog" import { Command as CommandPrimitive } from "cmdk" import { Search } from "lucide-react" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; import { Dialog, DialogContent } from "@/components/ui/dialog" const Command = React.forwardRef< diff --git a/components/ui/context-menu.tsx b/components/ui/context-menu.tsx index 93ef37b..3eee764 100644 --- a/components/ui/context-menu.tsx +++ b/components/ui/context-menu.tsx @@ -4,7 +4,7 @@ import * as React from "react" import * as ContextMenuPrimitive from "@radix-ui/react-context-menu" import { Check, ChevronRight, Circle } from "lucide-react" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; const ContextMenu = ContextMenuPrimitive.Root diff --git a/components/ui/dialog.tsx b/components/ui/dialog.tsx index d20e012..478c72b 100644 --- a/components/ui/dialog.tsx +++ b/components/ui/dialog.tsx @@ -4,7 +4,7 @@ import * as React from "react" import * as DialogPrimitive from "@radix-ui/react-dialog" import { X } from "lucide-react" -import { cn } from '@/lib/styles'; +import { cn } from "@/lib/styles"; const Dialog = DialogPrimitive.Root diff --git a/components/ui/drawer.tsx b/components/ui/drawer.tsx index 6a0ef53..d678328 100644 --- a/components/ui/drawer.tsx +++ b/components/ui/drawer.tsx @@ -3,7 +3,7 @@ import * as React from "react" import { Drawer as DrawerPrimitive } from "vaul" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; const Drawer = ({ shouldScaleBackground = true, diff --git a/components/ui/dropdown-menu.tsx b/components/ui/dropdown-menu.tsx index 0fc4c0e..61cd595 100644 --- a/components/ui/dropdown-menu.tsx +++ b/components/ui/dropdown-menu.tsx @@ -4,7 +4,7 @@ import * as React from "react" import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu" import { Check, ChevronRight, Circle } from "lucide-react" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; const DropdownMenu = DropdownMenuPrimitive.Root diff --git a/components/ui/form.tsx b/components/ui/form.tsx index ce264ae..975f29d 100644 --- a/components/ui/form.tsx +++ b/components/ui/form.tsx @@ -12,7 +12,7 @@ import { useFormContext, } from "react-hook-form" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; import { Label } from "@/components/ui/label" const Form = FormProvider diff --git a/components/ui/input.tsx b/components/ui/input.tsx index 4579129..9dbdb50 100644 --- a/components/ui/input.tsx +++ b/components/ui/input.tsx @@ -1,6 +1,6 @@ import * as React from "react" -import { cn } from '@/lib/styles'; +import { cn } from "@/lib/styles"; const Input = React.forwardRef>( ({ className, type, ...props }, ref) => { diff --git a/components/ui/menubar.tsx b/components/ui/menubar.tsx index 5586fa9..1052dc2 100644 --- a/components/ui/menubar.tsx +++ b/components/ui/menubar.tsx @@ -4,7 +4,7 @@ import * as React from "react" import * as MenubarPrimitive from "@radix-ui/react-menubar" import { Check, ChevronRight, Circle } from "lucide-react" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; const MenubarMenu = MenubarPrimitive.Menu diff --git a/components/ui/navigation-menu.tsx b/components/ui/navigation-menu.tsx index 1419f56..d0ff4ac 100644 --- a/components/ui/navigation-menu.tsx +++ b/components/ui/navigation-menu.tsx @@ -3,7 +3,7 @@ import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu" import { cva } from "class-variance-authority" import { ChevronDown } from "lucide-react" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; const NavigationMenu = React.forwardRef< React.ElementRef, diff --git a/components/ui/pagination.tsx b/components/ui/pagination.tsx index ea40d19..eed0b30 100644 --- a/components/ui/pagination.tsx +++ b/components/ui/pagination.tsx @@ -1,7 +1,7 @@ import * as React from "react" import { ChevronLeft, ChevronRight, MoreHorizontal } from "lucide-react" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; import { ButtonProps, buttonVariants } from "@/components/ui/button" const Pagination = ({ className, ...props }: React.ComponentProps<"nav">) => ( diff --git a/components/ui/popover.tsx b/components/ui/popover.tsx index a0ec48b..97b3c09 100644 --- a/components/ui/popover.tsx +++ b/components/ui/popover.tsx @@ -3,7 +3,7 @@ import * as React from "react" import * as PopoverPrimitive from "@radix-ui/react-popover" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; const Popover = PopoverPrimitive.Root diff --git a/components/ui/progress.tsx b/components/ui/progress.tsx index 5c87ea4..76d388b 100644 --- a/components/ui/progress.tsx +++ b/components/ui/progress.tsx @@ -3,7 +3,7 @@ import * as React from "react" import * as ProgressPrimitive from "@radix-ui/react-progress" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; const Progress = React.forwardRef< React.ElementRef, diff --git a/components/ui/radio-group.tsx b/components/ui/radio-group.tsx index e9bde17..638ab40 100644 --- a/components/ui/radio-group.tsx +++ b/components/ui/radio-group.tsx @@ -4,7 +4,7 @@ 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/styles"; const RadioGroup = React.forwardRef< React.ElementRef, diff --git a/components/ui/resizable.tsx b/components/ui/resizable.tsx index f4bc558..4c4323d 100644 --- a/components/ui/resizable.tsx +++ b/components/ui/resizable.tsx @@ -3,7 +3,7 @@ import { GripVertical } from "lucide-react" import * as ResizablePrimitive from "react-resizable-panels" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; const ResizablePanelGroup = ({ className, diff --git a/components/ui/scroll-area.tsx b/components/ui/scroll-area.tsx index 0b4a48d..666de88 100644 --- a/components/ui/scroll-area.tsx +++ b/components/ui/scroll-area.tsx @@ -3,7 +3,7 @@ import * as React from "react" import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; const ScrollArea = React.forwardRef< React.ElementRef, diff --git a/components/ui/select.tsx b/components/ui/select.tsx index fc49086..e232114 100644 --- a/components/ui/select.tsx +++ b/components/ui/select.tsx @@ -4,7 +4,7 @@ import * as React from "react" import * as SelectPrimitive from "@radix-ui/react-select" import { Check, ChevronDown, ChevronUp } from "lucide-react" -import { cn } from '@/lib/styles'; +import { cn } from "@/lib/styles"; const Select = SelectPrimitive.Root diff --git a/components/ui/separator.tsx b/components/ui/separator.tsx index 12d81c4..ec48df4 100644 --- a/components/ui/separator.tsx +++ b/components/ui/separator.tsx @@ -3,7 +3,7 @@ import * as React from "react" import * as SeparatorPrimitive from "@radix-ui/react-separator" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; const Separator = React.forwardRef< React.ElementRef, diff --git a/components/ui/sheet.tsx b/components/ui/sheet.tsx index a37f17b..f00ad45 100644 --- a/components/ui/sheet.tsx +++ b/components/ui/sheet.tsx @@ -5,7 +5,7 @@ import * as SheetPrimitive from "@radix-ui/react-dialog" import { cva, type VariantProps } from "class-variance-authority" import { X } from "lucide-react" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; const Sheet = SheetPrimitive.Root diff --git a/components/ui/sidebar.tsx b/components/ui/sidebar.tsx index eeb2d7a..91eaad6 100644 --- a/components/ui/sidebar.tsx +++ b/components/ui/sidebar.tsx @@ -6,7 +6,7 @@ import { VariantProps, cva } from "class-variance-authority" import { PanelLeft } from "lucide-react" import { useIsMobile } from "@/hooks/use-mobile" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Separator } from "@/components/ui/separator" diff --git a/components/ui/skeleton.tsx b/components/ui/skeleton.tsx index c4281b2..6795fc9 100644 --- a/components/ui/skeleton.tsx +++ b/components/ui/skeleton.tsx @@ -1,4 +1,4 @@ -import { cn } from "@/lib/styles" +import { cn } from "@/lib/styles"; function Skeleton({ className, diff --git a/components/ui/slider.tsx b/components/ui/slider.tsx index c31c2b3..ecba997 100644 --- a/components/ui/slider.tsx +++ b/components/ui/slider.tsx @@ -3,7 +3,7 @@ import * as React from "react" import * as SliderPrimitive from "@radix-ui/react-slider" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; const Slider = React.forwardRef< React.ElementRef, diff --git a/components/ui/switch.tsx b/components/ui/switch.tsx index bc69cf2..9e253a3 100644 --- a/components/ui/switch.tsx +++ b/components/ui/switch.tsx @@ -3,7 +3,7 @@ import * as React from "react" import * as SwitchPrimitives from "@radix-ui/react-switch" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; const Switch = React.forwardRef< React.ElementRef, diff --git a/components/ui/table.tsx b/components/ui/table.tsx index c8c6390..2f38f8c 100644 --- a/components/ui/table.tsx +++ b/components/ui/table.tsx @@ -1,6 +1,6 @@ import * as React from "react" -import { cn } from '@/lib/styles'; +import { cn } from "@/lib/styles"; const Table = React.forwardRef< HTMLTableElement, diff --git a/components/ui/tabs.tsx b/components/ui/tabs.tsx index 26eb109..6f62573 100644 --- a/components/ui/tabs.tsx +++ b/components/ui/tabs.tsx @@ -3,7 +3,7 @@ import * as React from "react" import * as TabsPrimitive from "@radix-ui/react-tabs" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; const Tabs = TabsPrimitive.Root diff --git a/components/ui/textarea.tsx b/components/ui/textarea.tsx index 5ca2c05..374b8ac 100644 --- a/components/ui/textarea.tsx +++ b/components/ui/textarea.tsx @@ -1,6 +1,6 @@ import * as React from "react" -import { cn } from '@/lib/styles'; +import { cn } from "@/lib/styles"; const Textarea = React.forwardRef< HTMLTextAreaElement, diff --git a/components/ui/toast.tsx b/components/ui/toast.tsx index 521b94b..ec64bfc 100644 --- a/components/ui/toast.tsx +++ b/components/ui/toast.tsx @@ -5,7 +5,7 @@ import * as ToastPrimitives from "@radix-ui/react-toast" import { cva, type VariantProps } from "class-variance-authority" import { X } from "lucide-react" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; const ToastProvider = ToastPrimitives.Provider diff --git a/components/ui/toggle-group.tsx b/components/ui/toggle-group.tsx index 1c876bb..df1b9e5 100644 --- a/components/ui/toggle-group.tsx +++ b/components/ui/toggle-group.tsx @@ -4,7 +4,7 @@ import * as React from "react" import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group" import { type VariantProps } from "class-variance-authority" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; import { toggleVariants } from "@/components/ui/toggle" const ToggleGroupContext = React.createContext< diff --git a/components/ui/toggle.tsx b/components/ui/toggle.tsx index c19bea3..2b28c1f 100644 --- a/components/ui/toggle.tsx +++ b/components/ui/toggle.tsx @@ -4,7 +4,7 @@ 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/styles"; 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 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 gap-2", diff --git a/components/ui/tooltip.tsx b/components/ui/tooltip.tsx index 30fc44d..60c9bf9 100644 --- a/components/ui/tooltip.tsx +++ b/components/ui/tooltip.tsx @@ -3,7 +3,7 @@ import * as React from "react" import * as TooltipPrimitive from "@radix-ui/react-tooltip" -import { cn } from "@/lib/utils" +import { cn } from "@/lib/styles"; const TooltipProvider = TooltipPrimitive.Provider