Vitron-Front/app/routes/profile.location.add.tsx
Arda Samadi 16389fdd85 fix(desktop): lay out dashboard sub-pages + form pages for wide screens
- HeaderWithSupport is now lg:hidden (all its callers are desktop-full-width
  store/profile pages), removing the stray mobile back+support bar on desktop.
- Constrain + title the previously mobile-only pages so their content doesn't
  stretch edge-to-edge on desktop: store edit/create form (StoreForm), add
  product, shipping method, financial sub-pages (cash-funds/reports/
  transactions), order detail, instagram auth; and profile add/edit address,
  set detail, and payment result. Forms use a narrow centered column, lists/
  details a wider one. Transactions keeps its filter button (header restyled,
  not hidden).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-09 12:06:13 +03:30

130 lines
4.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import type { MetaFunction } from "@remix-run/node";
import { ClientOnly } from "../components/ClientOnly";
import { Suspense, useState } from "react";
import ProfilePagesHeader from "../components/ProfilePagesHeader";
import { lazyWithPreload } from "~/utils/lazy-import";
import { MapPin } from "lucide-react";
export const meta: MetaFunction = () => {
return [
{ title: "افزودن آدرس" },
{
name: "description",
content: "افزودن آدرس برای انتخاب موقعیت و دریافت آدرس",
},
];
};
export default function AddLocation() {
const [showMap, setShowMap] = useState(false);
return (
<div className="flex flex-col gap-2 w-full lg:max-w-[820px] lg:mx-auto lg:pt-6">
<ProfilePagesHeader title="افزودن آدرس" />
<h1 className="hidden lg:block text-[28px] font-extrabold px-4 mb-2">
افزودن آدرس
</h1>
{!showMap ? (
// Show form first with option to use map
<ClientOnly
fallback={
<div className="h-[200px] w-full bg-WHITE3 flex items-center justify-center">
در حال بارگذاری...
</div>
}
>
{() => {
const InteractiveMap = lazyWithPreload(
() => import("../components/InteractiveMap")
);
return (
<Suspense
fallback={
<div className="h-[200px] w-full bg-WHITE3 flex items-center justify-center animate-pulse">
<div className="flex flex-col items-center gap-2">
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-primary"></div>
<span className="text-GRAY">در حال بارگذاری...</span>
</div>
</div>
}
>
<div className="flex flex-col gap-4">
{/* Button to show map */}
<div className="px-4">
<button
onClick={() => setShowMap(true)}
className="w-full flex items-center justify-center gap-2 py-3 px-4 border-2 border-dashed border-GRAY2 rounded-lg text-GRAY hover:border-primary hover:text-primary transition-colors"
>
<MapPin className="w-5 h-5" />
<span>انتخاب آدرس از روی نقشه</span>
</button>
</div>
{/* Form only mode */}
<InteractiveMap formOnly={true} />
</div>
</Suspense>
);
}}
</ClientOnly>
) : (
// Show map when user clicks the button
<ClientOnly
fallback={
<div className="h-[500px] w-full bg-WHITE3 flex items-center justify-center">
در حال بارگذاری نقشه...
</div>
}
>
{() => {
const InteractiveMap = lazyWithPreload(
() => import("../components/InteractiveMap")
);
return (
<Suspense
fallback={
<div className="h-[500px] w-full bg-WHITE3 flex items-center justify-center animate-pulse">
<div className="flex flex-col items-center gap-2">
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-primary"></div>
<span className="text-GRAY">
در حال بارگذاری نقشه...
</span>
</div>
</div>
}
>
<div className="flex flex-col gap-2">
{/* Back button */}
<div className="px-4">
<button
onClick={() => setShowMap(false)}
className="flex items-center gap-2 text-GRAY hover:text-primary transition-colors"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<polyline points="9 18 15 12 9 6"></polyline>
</svg>
<span>بازگشت به فرم</span>
</button>
</div>
<InteractiveMap />
</div>
</Suspense>
);
}}
</ClientOnly>
)}
</div>
);
}