import React from "react"; import basket from "../assets/icons/cart/basket.svg"; import paper from "../assets/icons/profile/orders/paper.svg"; import location from "../assets/icons/profile/location/location.svg"; import messageBox from "../assets/icons/profile/threads/messageBox.svg"; import { Button } from "./ui/button"; import { RefreshCw } from "lucide-react"; import { Skeleton } from "./ui/skeleton"; import { useNavigate } from "@remix-run/react"; import { safeGoBack } from "~/utils/helpers"; export default function UiProvider({ children, isLoading, isError, isEmpty, onRetry, type, }: { children: React.ReactNode; isLoading: boolean; isError: boolean; isEmpty: boolean; onRetry?: () => void; type: | "cart" | "following" | "location" | "order" | "product" | "threads" | "seller" | "wallet" | "locationEdit"; }) { return ( <> {isLoading ? ( ) : isError ? ( ) : isEmpty ? ( ) : ( children )} ); } const LoadingState = ({ type }: { type: string }) => { if (type === "following") return (
{[...Array(3)].map((_, index) => ( ))}
); if (type === "location") return (
); if (type === "threads") return (
{[...Array(3)].map((_, index) => (
))}
); if (type === "wallet") return (
); return (

در حال بارگذاری...

); }; export const ErrorState = ({ onRetry }: { onRetry?: () => void }) => { return (

مشکلی در دریافت اطلاعات پیش آمده است

{onRetry && ( )}
); }; export const EmptyState = ({ type, mondrianImage, mondrianTitle, mondrianDescription, }: { type: string; mondrianImage?: React.ReactNode; mondrianTitle?: string; mondrianDescription?: string; }) => { const navigate = useNavigate(); return ( <> {type === "cart" && (
cartBanner

سبد خرید شما خالی است

در سبد خرید، جای انتخاب‌های خاص شما خالی‌ست.

)} {type === "following" && (
cartBanner

فروشگاهی دنبال نشده است.

تمام فروشگاه‌هایی که دنبال می‌کنید در این قسمت قابل مشاهده است.

)} {type === "location" && (

هنوز آدرسی ثبت نشده است

اولین آدرس خود را ثبت کنید

)} {type === "locationEdit" && (

آدرس مورد نظر یافت نشد

)} {type === "threads" && (
messageBox

لیست پیام‌ها خالی است.

هنوز پیامی دریافت یا ارسال نکرده‌اید

)} {type === "orders" && (
cartBanner

هنوز سفارشی ثبت نشده است

از محصولات دیدن کنید و سفارش خود را ثبت کنید.

)} {type === "mondrian" && (
{mondrianImage}

{mondrianTitle}

{mondrianDescription}

)} ); };