mirror of
https://git.meshkee.com/Meshkee/dashboards.git
synced 2026-08-12 06:40:57 +04:30
Polish business FA layout and wire special-group keys plus SSL sync.
RTL carousels/FABs, special key+title fields, slider gallery fixes, and dashboard SSL sync agent for super-admin. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
66004a0fba
commit
672091d1f5
@@ -16,14 +16,16 @@ import {
|
||||
toBrandFormPayload,
|
||||
updateBrand,
|
||||
} from '../services/brandService'
|
||||
import { useT } from '../i18n/useT'
|
||||
import pageStyles from '../components/PageContent.module.css'
|
||||
import styles from './BrandsPage.module.css'
|
||||
|
||||
export function BrandsPage() {
|
||||
const t = useT()
|
||||
const { showToast } = useToast()
|
||||
const [brands, setBrands] = useState<Brand[]>([])
|
||||
const [modalOpen, setModalOpen] = useState(false)
|
||||
const [modalTitle, setModalTitle] = useState('Add Brand')
|
||||
const [modalTitle, setModalTitle] = useState(() => t('brands.add'))
|
||||
const [editingBrand, setEditingBrand] = useState<Brand | null>(null)
|
||||
const [isLoading, setIsLoading] = useState(true)
|
||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||
@@ -47,7 +49,7 @@ export function BrandsPage() {
|
||||
if (err instanceof ApiError) {
|
||||
setError(err.message)
|
||||
} else {
|
||||
setError('Unable to load brands.')
|
||||
setError(t('brands.errorLoad'))
|
||||
}
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
@@ -56,13 +58,13 @@ export function BrandsPage() {
|
||||
|
||||
function openCreateModal() {
|
||||
setEditingBrand(null)
|
||||
setModalTitle('Add Brand')
|
||||
setModalTitle(t('brands.add'))
|
||||
setModalOpen(true)
|
||||
}
|
||||
|
||||
function openEditModal(brand: Brand) {
|
||||
setEditingBrand(brand)
|
||||
setModalTitle('Edit Brand')
|
||||
setModalTitle(t('brands.edit'))
|
||||
setModalOpen(true)
|
||||
}
|
||||
|
||||
@@ -87,11 +89,11 @@ export function BrandsPage() {
|
||||
brand.id === editingBrand.id ? mapBrandApiToUi(result.brand) : brand,
|
||||
),
|
||||
)
|
||||
showToast('Brand updated.', 'success')
|
||||
showToast(t('brands.toast.updated'), 'success')
|
||||
} else {
|
||||
const result = await createBrand(toBrandFormPayload(data, resolvedImageMediaId))
|
||||
setBrands((prev) => [...prev, mapBrandApiToUi(result.brand)])
|
||||
showToast('Brand created.', 'success')
|
||||
showToast(t('brands.toast.created'), 'success')
|
||||
}
|
||||
|
||||
setModalOpen(false)
|
||||
@@ -100,7 +102,7 @@ export function BrandsPage() {
|
||||
if (err instanceof ApiError) {
|
||||
setError(err.message)
|
||||
} else {
|
||||
setError('Unable to save brand.')
|
||||
setError(t('brands.errorSave'))
|
||||
}
|
||||
} finally {
|
||||
setIsSubmitting(false)
|
||||
@@ -117,12 +119,12 @@ export function BrandsPage() {
|
||||
await deleteBrand(deleteTarget.id)
|
||||
setBrands((prev) => prev.filter((brand) => brand.id !== deleteTarget.id))
|
||||
setDeleteTarget(null)
|
||||
showToast('Brand deleted.', 'success')
|
||||
showToast(t('brands.toast.deleted'), 'success')
|
||||
} catch (err) {
|
||||
if (err instanceof ApiError) {
|
||||
setError(err.message)
|
||||
} else {
|
||||
setError('Unable to delete brand.')
|
||||
setError(t('brands.errorDelete'))
|
||||
}
|
||||
} finally {
|
||||
setIsSubmitting(false)
|
||||
@@ -140,10 +142,8 @@ export function BrandsPage() {
|
||||
/>
|
||||
<div className={pageStyles.pageHeader}>
|
||||
<div>
|
||||
<h2 className={pageStyles.pageTitle}>Brands</h2>
|
||||
<p className={pageStyles.pageSubtitle}>
|
||||
Manage product brands for your store catalog.
|
||||
</p>
|
||||
<h2 className={pageStyles.pageTitle}>{t('title.brands')}</h2>
|
||||
<p className={pageStyles.pageSubtitle}>{t('brands.page.subtitle')}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -155,9 +155,9 @@ export function BrandsPage() {
|
||||
|
||||
<div className={styles.list}>
|
||||
{isLoading ? (
|
||||
<p className={styles.empty}>Loading brands...</p>
|
||||
<p className={styles.empty}>{t('brands.loading')}</p>
|
||||
) : brands.length === 0 ? (
|
||||
<p className={styles.empty}>No brands yet. Click + to add one.</p>
|
||||
<p className={styles.empty}>{t('brands.empty')}</p>
|
||||
) : (
|
||||
brands.map((brand) => (
|
||||
<BrandRow
|
||||
@@ -192,10 +192,12 @@ export function BrandsPage() {
|
||||
|
||||
<ConfirmDeleteModal
|
||||
open={!!deleteTarget}
|
||||
title="Delete Brand"
|
||||
title={t('brands.deleteTitle')}
|
||||
message={
|
||||
deleteTarget
|
||||
? `Are you sure you want to delete "${deleteTarget.nameEn}"? Products linked to this brand will have their brand cleared.`
|
||||
? t('brands.deleteMessage', {
|
||||
name: deleteTarget.nameFa || deleteTarget.nameEn,
|
||||
})
|
||||
: ''
|
||||
}
|
||||
onConfirm={confirmDelete}
|
||||
@@ -207,7 +209,7 @@ export function BrandsPage() {
|
||||
type="button"
|
||||
className={styles.addFab}
|
||||
onClick={openCreateModal}
|
||||
aria-label="Add brand"
|
||||
aria-label={t('brands.add')}
|
||||
>
|
||||
<Plus size={24} />
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user