Localize order modals, add dual logos, and improve admin order tools.
Farsi business order/variation UI, light/dark logo upload on business profile, payment order steps, variation editing, super-admin site links, and checkout/auth fixes. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
dc570c1e7f
commit
5e799eddf9
@@ -1,6 +1,15 @@
|
||||
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { Eraser, MoreHorizontal, Trash2, Users } from 'lucide-react'
|
||||
import {
|
||||
Building2,
|
||||
Eraser,
|
||||
ExternalLink,
|
||||
Globe,
|
||||
MoreHorizontal,
|
||||
Trash2,
|
||||
UserRound,
|
||||
Users,
|
||||
} from 'lucide-react'
|
||||
import { fitFixedPopover } from '../utils/fitFixedPopover'
|
||||
import styles from './BusinessActionsOverflowMenu.module.css'
|
||||
|
||||
@@ -11,13 +20,32 @@ type PopoverPosition = {
|
||||
|
||||
interface BusinessActionsOverflowMenuProps {
|
||||
businessName: string
|
||||
/** Primary apex domain host when set — enables website / dashboard links. */
|
||||
host?: string | null
|
||||
onAllUsers: () => void
|
||||
onWipeData: () => void
|
||||
onRemove: () => void
|
||||
}
|
||||
|
||||
function apexHost(host: string) {
|
||||
return host.trim().replace(/^www\./i, '')
|
||||
}
|
||||
|
||||
function siteProtocol(host: string) {
|
||||
return /\.local$/i.test(host) ? 'http:' : 'https:'
|
||||
}
|
||||
|
||||
function siteUrl(host: string) {
|
||||
return `${siteProtocol(host)}//${host}`
|
||||
}
|
||||
|
||||
function openHost(host: string) {
|
||||
window.open(siteUrl(host), '_blank', 'noopener,noreferrer')
|
||||
}
|
||||
|
||||
export function BusinessActionsOverflowMenu({
|
||||
businessName,
|
||||
host,
|
||||
onAllUsers,
|
||||
onWipeData,
|
||||
onRemove,
|
||||
@@ -28,13 +56,40 @@ export function BusinessActionsOverflowMenu({
|
||||
const popoverRef = useRef<HTMLDivElement>(null)
|
||||
const triggerRef = useRef<HTMLButtonElement>(null)
|
||||
|
||||
const apex = host?.trim() ? apexHost(host) : null
|
||||
const linkItems = apex
|
||||
? ([
|
||||
{
|
||||
key: 'website',
|
||||
label: 'باز کردن وبسایت',
|
||||
detail: apex,
|
||||
icon: Globe,
|
||||
onClick: () => openHost(apex),
|
||||
},
|
||||
{
|
||||
key: 'business',
|
||||
label: 'داشبورد کسبوکار',
|
||||
detail: `business.${apex}`,
|
||||
icon: Building2,
|
||||
onClick: () => openHost(`business.${apex}`),
|
||||
},
|
||||
{
|
||||
key: 'customer',
|
||||
label: 'داشبورد مشتری',
|
||||
detail: `customer.${apex}`,
|
||||
icon: UserRound,
|
||||
onClick: () => openHost(`customer.${apex}`),
|
||||
},
|
||||
] as const)
|
||||
: []
|
||||
|
||||
function updatePopoverPosition() {
|
||||
const rect = triggerRef.current?.getBoundingClientRect()
|
||||
if (!rect) return
|
||||
|
||||
const size = popoverRef.current
|
||||
? { width: popoverRef.current.offsetWidth, height: popoverRef.current.offsetHeight }
|
||||
: { width: 220, height: 160 }
|
||||
: { width: 220, height: linkItems.length ? 280 : 160 }
|
||||
|
||||
setPopoverPos(fitFixedPopover(rect, size, 'end'))
|
||||
}
|
||||
@@ -96,8 +151,8 @@ export function BusinessActionsOverflowMenu({
|
||||
e.stopPropagation()
|
||||
toggleOpen()
|
||||
}}
|
||||
title="More actions"
|
||||
aria-label={`More actions for ${businessName}`}
|
||||
title="عملیات بیشتر"
|
||||
aria-label={`عملیات بیشتر برای ${businessName}`}
|
||||
aria-haspopup="menu"
|
||||
aria-expanded={open}
|
||||
>
|
||||
@@ -111,12 +166,36 @@ export function BusinessActionsOverflowMenu({
|
||||
ref={popoverRef}
|
||||
className={styles.menu}
|
||||
role="menu"
|
||||
aria-label={`More actions for ${businessName}`}
|
||||
aria-label={`عملیات بیشتر برای ${businessName}`}
|
||||
lang="fa"
|
||||
dir="rtl"
|
||||
style={{
|
||||
top: popoverPos.top,
|
||||
left: popoverPos.left,
|
||||
}}
|
||||
>
|
||||
{linkItems.map(({ key, label, detail, icon: Icon, onClick }) => (
|
||||
<button
|
||||
key={key}
|
||||
type="button"
|
||||
className={styles.item}
|
||||
role="menuitem"
|
||||
onClick={() => {
|
||||
setOpen(false)
|
||||
onClick()
|
||||
}}
|
||||
>
|
||||
<Icon size={16} />
|
||||
<span className={styles.itemText}>
|
||||
<span>{label}</span>
|
||||
<span className={styles.itemDetail} dir="ltr">
|
||||
{detail}
|
||||
<ExternalLink size={12} aria-hidden="true" />
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
{linkItems.length > 0 && <div className={styles.menuDivider} role="separator" />}
|
||||
<button
|
||||
type="button"
|
||||
className={styles.item}
|
||||
@@ -127,7 +206,7 @@ export function BusinessActionsOverflowMenu({
|
||||
}}
|
||||
>
|
||||
<Users size={16} />
|
||||
<span>All users</span>
|
||||
<span>همه کاربران</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
@@ -141,7 +220,7 @@ export function BusinessActionsOverflowMenu({
|
||||
}}
|
||||
>
|
||||
<Eraser size={16} />
|
||||
<span>Wipe data</span>
|
||||
<span>پاکسازی داده</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
@@ -153,7 +232,7 @@ export function BusinessActionsOverflowMenu({
|
||||
}}
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
<span>Remove</span>
|
||||
<span>حذف</span>
|
||||
</button>
|
||||
</div>,
|
||||
document.body,
|
||||
|
||||
@@ -109,21 +109,21 @@ export function DomainLinksOverflowMenu({ host, onRemove }: DomainLinksOverflowM
|
||||
const items = [
|
||||
{
|
||||
key: 'website',
|
||||
label: 'Open website',
|
||||
label: 'باز کردن وبسایت',
|
||||
detail: websiteHost,
|
||||
icon: Globe,
|
||||
onClick: () => openHost(websiteHost),
|
||||
},
|
||||
{
|
||||
key: 'business',
|
||||
label: 'Business dashboard',
|
||||
label: 'داشبورد کسبوکار',
|
||||
detail: businessHost,
|
||||
icon: Building2,
|
||||
onClick: () => openHost(businessHost),
|
||||
},
|
||||
{
|
||||
key: 'customer',
|
||||
label: 'Customer dashboard',
|
||||
label: 'داشبورد مشتری',
|
||||
detail: customerHost,
|
||||
icon: UserRound,
|
||||
onClick: () => openHost(customerHost),
|
||||
@@ -141,8 +141,8 @@ export function DomainLinksOverflowMenu({ host, onRemove }: DomainLinksOverflowM
|
||||
e.stopPropagation()
|
||||
toggleOpen()
|
||||
}}
|
||||
title="More actions"
|
||||
aria-label={`More actions for ${apex}`}
|
||||
title="عملیات بیشتر"
|
||||
aria-label={`عملیات بیشتر برای ${apex}`}
|
||||
aria-haspopup="menu"
|
||||
aria-expanded={open}
|
||||
>
|
||||
@@ -156,7 +156,9 @@ export function DomainLinksOverflowMenu({ host, onRemove }: DomainLinksOverflowM
|
||||
ref={popoverRef}
|
||||
className={styles.menu}
|
||||
role="menu"
|
||||
aria-label={`More actions for ${apex}`}
|
||||
aria-label={`عملیات بیشتر برای ${apex}`}
|
||||
lang="fa"
|
||||
dir="rtl"
|
||||
style={{
|
||||
top: popoverPos.top,
|
||||
left: popoverPos.left,
|
||||
@@ -176,7 +178,7 @@ export function DomainLinksOverflowMenu({ host, onRemove }: DomainLinksOverflowM
|
||||
<Icon size={16} />
|
||||
<span className={styles.itemText}>
|
||||
<span>{label}</span>
|
||||
<span className={styles.itemDetail}>
|
||||
<span className={styles.itemDetail} dir="ltr">
|
||||
{detail}
|
||||
<ExternalLink size={12} aria-hidden="true" />
|
||||
</span>
|
||||
@@ -194,7 +196,7 @@ export function DomainLinksOverflowMenu({ host, onRemove }: DomainLinksOverflowM
|
||||
}}
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
<span>Remove</span>
|
||||
<span>حذف</span>
|
||||
</button>
|
||||
</div>,
|
||||
document.body,
|
||||
|
||||
Reference in New Issue
Block a user