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:
Alireza Hassani
2026-08-03 00:06:44 +03:30
co-authored by Cursor
parent 66004a0fba
commit 672091d1f5
113 changed files with 4154 additions and 1451 deletions
@@ -7,6 +7,7 @@ import { StoreSpecialModal } from '../components/StoreSpecialModal'
import { WebsiteGroupCarousel } from '../components/WebsiteGroupCarousel'
import { WebsiteGroupItemCard } from '../components/WebsiteGroupItemCard'
import { useToast } from '../context/ToastContext'
import { useT } from '../i18n/useT'
import { ApiError } from '../lib/api'
import {
createWebsiteBrandGroup,
@@ -20,6 +21,7 @@ import fabStyles from './StoreItemsPage.module.css'
import styles from './StoreSpecialsPage.module.css'
export function WebsiteSpecialBrandsPage() {
const t = useT()
const { showToast } = useToast()
const [groups, setGroups] = useState<WebsiteBrandGroup[]>([])
const [isLoading, setIsLoading] = useState(true)
@@ -54,7 +56,7 @@ export function WebsiteSpecialBrandsPage() {
if (err instanceof ApiError) {
setError(err.message)
} else {
setError('Unable to load special brand groups.')
setError(t('website.specialBrands.errorLoad'))
}
} finally {
setIsLoading(false)
@@ -65,45 +67,49 @@ export function WebsiteSpecialBrandsPage() {
setGroups((prev) => prev.map((entry) => (entry.id === updated.id ? updated : entry)))
}
async function handleCreateGroup(title: string) {
async function handleCreateGroup(values: { key: string; title: string }) {
setIsSaving(true)
setError('')
try {
const result = await createWebsiteBrandGroup({
title,
key: values.key,
title: values.title,
sortOrder: groups.length,
})
setGroups((prev) => [...prev, result.group])
setCreateOpen(false)
showToast('Special brand group created.', 'success')
showToast(t('website.specialBrands.toastCreated'), 'success')
} catch (err) {
if (err instanceof ApiError) {
setError(err.message)
} else {
setError('Unable to create special brand group.')
setError(t('website.specialBrands.errorCreate'))
}
} finally {
setIsSaving(false)
}
}
async function handleEditGroup(title: string) {
async function handleEditGroup(values: { key: string; title: string }) {
if (!editGroupTarget) return
setIsSaving(true)
setError('')
try {
const result = await updateWebsiteBrandGroup(editGroupTarget.id, { title })
const result = await updateWebsiteBrandGroup(editGroupTarget.id, {
key: values.key,
title: values.title,
})
replaceGroup(result.group)
setEditGroupTarget(null)
showToast('Special brand group updated.', 'success')
showToast(t('website.specialBrands.toastUpdated'), 'success')
} catch (err) {
if (err instanceof ApiError) {
setError(err.message)
} else {
setError('Unable to update special brand group.')
setError(t('website.specialBrands.errorUpdate'))
}
} finally {
setIsSaving(false)
@@ -120,12 +126,12 @@ export function WebsiteSpecialBrandsPage() {
await deleteWebsiteBrandGroup(deleteGroupTarget.id)
setGroups((prev) => prev.filter((entry) => entry.id !== deleteGroupTarget.id))
setDeleteGroupTarget(null)
showToast('Special brand group deleted.', 'success')
showToast(t('website.specialBrands.toastDeleted'), 'success')
} catch (err) {
if (err instanceof ApiError) {
setError(err.message)
} else {
setError('Unable to delete special brand group.')
setError(t('website.specialBrands.errorDelete'))
}
} finally {
setIsSaving(false)
@@ -147,12 +153,12 @@ export function WebsiteSpecialBrandsPage() {
})
replaceGroup(result.group)
setPickItemsTarget(null)
showToast('Brands added to group.', 'success')
showToast(t('website.specialBrands.toastAdded'), 'success')
} catch (err) {
if (err instanceof ApiError) {
setError(err.message)
} else {
setError('Unable to add brands.')
setError(t('website.specialBrands.errorAdd'))
}
} finally {
setIsSaving(false)
@@ -174,12 +180,12 @@ export function WebsiteSpecialBrandsPage() {
})
replaceGroup(result.group)
setRemoveTarget(null)
showToast('Removed from special brand group.', 'success')
showToast(t('website.specialBrands.toastRemoved'), 'success')
} catch (err) {
if (err instanceof ApiError) {
setError(err.message)
} else {
setError('Unable to remove brand.')
setError(t('website.specialBrands.errorRemove'))
}
} finally {
setIsSaving(false)
@@ -198,22 +204,17 @@ export function WebsiteSpecialBrandsPage() {
<div className={pageStyles.pageHeader}>
<div>
<h2 className={pageStyles.pageTitle}>Special Brands</h2>
<p className={pageStyles.pageSubtitle}>
Curate featured brands into groups for your website homepage.
</p>
<h2 className={pageStyles.pageTitle}>{t('title.specialBrands')}</h2>
<p className={pageStyles.pageSubtitle}>{t('website.specialBrands.subtitle')}</p>
</div>
</div>
{error && <p className={styles.error}>{error}</p>}
{isLoading ? (
<p className={styles.empty}>Loading special brand groups...</p>
<p className={styles.empty}>{t('website.specialBrands.loading')}</p>
) : groups.length === 0 ? (
<p className={styles.empty}>
No special brand groups yet. Use the + button to create one, then add brands to each
carousel.
</p>
<p className={styles.empty}>{t('website.specialBrands.empty')}</p>
) : (
<div className={styles.carousels}>
{groups.map((group) => (
@@ -225,9 +226,7 @@ export function WebsiteSpecialBrandsPage() {
onAddItems={() => setPickItemsTarget(group)}
onEditGroup={() => setEditGroupTarget(group)}
onDeleteGroup={() => setDeleteGroupTarget(group)}
addTooltip={`Add brands to ${group.title}`}
editTooltip="Edit group"
deleteTooltip="Delete group"
addTooltip={t('website.specialBrands.addTooltip', { title: group.title })}
renderItem={(item) => (
<WebsiteGroupItemCard
title={item.nameEn}
@@ -240,7 +239,6 @@ export function WebsiteSpecialBrandsPage() {
brandName: item.nameEn,
})
}
removeTooltip="Remove from group"
/>
)}
/>
@@ -253,7 +251,7 @@ export function WebsiteSpecialBrandsPage() {
type="button"
className={fabStyles.addFab}
onClick={() => setCreateOpen(true)}
aria-label="Add special brand group"
aria-label={t('website.specialBrands.addFab')}
>
<Plus size={24} />
</button>
@@ -263,7 +261,8 @@ export function WebsiteSpecialBrandsPage() {
open={createOpen}
onClose={() => !isSaving && setCreateOpen(false)}
onSubmit={handleCreateGroup}
title="Add Special Brand Group"
title={t('website.specialBrands.createTitle')}
submitLabel={t('website.create')}
isSubmitting={isSaving}
/>
@@ -271,9 +270,10 @@ export function WebsiteSpecialBrandsPage() {
open={!!editGroupTarget}
onClose={() => !isSaving && setEditGroupTarget(null)}
onSubmit={handleEditGroup}
initialKey={editGroupTarget?.key ?? ''}
initialTitle={editGroupTarget?.title ?? ''}
title="Edit Special Brand Group"
submitLabel="Save"
title={t('website.specialBrands.editTitle')}
submitLabel={t('website.save')}
isSubmitting={isSaving}
/>
@@ -288,10 +288,10 @@ export function WebsiteSpecialBrandsPage() {
<ConfirmDeleteModal
open={!!deleteGroupTarget}
title="Delete Special Brand Group"
title={t('website.specialBrands.deleteTitle')}
message={
deleteGroupTarget
? `Delete "${deleteGroupTarget.title}"? Brands will remain in your catalog.`
? t('website.specialBrands.deleteMessage', { title: deleteGroupTarget.title })
: ''
}
onConfirm={() => void confirmDeleteGroup()}
@@ -300,10 +300,13 @@ export function WebsiteSpecialBrandsPage() {
<ConfirmDeleteModal
open={!!removeTarget}
title="Remove from Group"
title={t('website.removeFromGroupTitle')}
message={
removeTarget
? `Remove "${removeTarget.brandName}" from "${removeTarget.group.title}"?`
? t('website.removeFromGroupMessage', {
name: removeTarget.brandName,
group: removeTarget.group.title,
})
: ''
}
onConfirm={() => void confirmRemoveFromGroup()}