From 02d92fc4654fe02463ca5b0b8336359d0fd7fedf Mon Sep 17 00:00:00 2001 From: "s.esmaeili" Date: Mon, 14 Sep 2026 15:18:17 +0330 Subject: [PATCH] admin-panel: add shared modal/header/icon/delete-handler components MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New src/components/common/: - BaseFormModal.vue — the standard shell every converted add/edit modal will use: header=title, footer=buttons, body=form. Replaces the ad-hoc 60%/70%/80% widths used across the codebase with 4 named sizes. - ListPageHeader.vue — the add button that goes above every list page, gated on the same rid the create route used (modelled on the one place this already existed, ListUser.vue's add-user button). New src/components/icons.ts: the legacy-Feather-name -> ant-icon map, extracted out of TooltipBtn.vue so the sidebar can resolve the same names through the same map instead of a second copy. New src/composables/useDeleteHandler.ts: the delete-then-refetch-then-toast handler that was copy-pasted verbatim in 6 list views (city/cityList.vue, user/ListUser.vue, apps/category/List.vue, finical/list.vue, apps/product/ProductList.vue, manage/Const.vue). Preserves each site's exact success-message wording and message.success/info choice, and ProductList's irregular POST-based delete endpoint. Verified: pnpm build passes. Co-Authored-By: Claude Sonnet 5 --- .../src/components/common/BaseFormModal.vue | 76 +++++++++++++++++ .../src/components/common/ListPageHeader.vue | 42 ++++++++++ apps/admin-panel/src/components/icons.ts | 81 +++++++++++++++++++ .../src/components/tooltip-btn/TooltipBtn.vue | 35 ++------ .../src/composables/useDeleteHandler.ts | 51 ++++++++++++ .../src/views/apps/category/List.vue | 22 +++-- .../src/views/apps/product/ProductList.vue | 27 +++---- apps/admin-panel/src/views/city/cityList.vue | 21 +++-- apps/admin-panel/src/views/finical/list.vue | 23 +++--- apps/admin-panel/src/views/manage/Const.vue | 21 ++--- apps/admin-panel/src/views/user/ListUser.vue | 23 +++--- 11 files changed, 321 insertions(+), 101 deletions(-) create mode 100644 apps/admin-panel/src/components/common/BaseFormModal.vue create mode 100644 apps/admin-panel/src/components/common/ListPageHeader.vue create mode 100644 apps/admin-panel/src/components/icons.ts create mode 100644 apps/admin-panel/src/composables/useDeleteHandler.ts diff --git a/apps/admin-panel/src/components/common/BaseFormModal.vue b/apps/admin-panel/src/components/common/BaseFormModal.vue new file mode 100644 index 0000000..8d516c6 --- /dev/null +++ b/apps/admin-panel/src/components/common/BaseFormModal.vue @@ -0,0 +1,76 @@ + + + diff --git a/apps/admin-panel/src/components/common/ListPageHeader.vue b/apps/admin-panel/src/components/common/ListPageHeader.vue new file mode 100644 index 0000000..426aa02 --- /dev/null +++ b/apps/admin-panel/src/components/common/ListPageHeader.vue @@ -0,0 +1,42 @@ + + + + + diff --git a/apps/admin-panel/src/components/icons.ts b/apps/admin-panel/src/components/icons.ts new file mode 100644 index 0000000..42f05b2 --- /dev/null +++ b/apps/admin-panel/src/components/icons.ts @@ -0,0 +1,81 @@ +// Shared legacy-Feather-name -> ant-design-vue icon map. +// +// Originally lived only inside TooltipBtn.vue (row-action icons). Extracted +// here so the sidebar (navMenuItems.ts icon: values) can resolve the SAME +// names through the SAME map instead of duplicating it — one source of +// truth for "legacy Feather icon name" -> "ant component" across the app. +import { + AppstoreOutlined, + BarChartOutlined, + BellOutlined, + BlockOutlined, + BookOutlined, + CameraOutlined, + CheckOutlined, + CloseOutlined, + CreditCardOutlined, + DeleteOutlined, + DollarOutlined, + EditOutlined, + EyeOutlined, + FileOutlined, + FileTextOutlined, + GiftOutlined, + HomeOutlined, + InboxOutlined, + MailOutlined, + MessageOutlined, + PercentageOutlined, + PlusOutlined, + SettingOutlined, + ShoppingOutlined, + StopOutlined, + TeamOutlined, + UnorderedListOutlined, + UserAddOutlined, + UserOutlined, +} from '@ant-design/icons-vue'; + +/** legacy Feather name -> ant component. */ +export const ICONS: Record = { + // row-action icons (TooltipBtn.vue's original set) + ListIcon: UnorderedListOutlined, + FileIcon: FileOutlined, + TrashIcon: DeleteOutlined, + EditIcon: EditOutlined, + CheckIcon: CheckOutlined, + CameraIcon: CameraOutlined, + EyeIcon: EyeOutlined, + PlusIcon: PlusOutlined, + XIcon: CloseOutlined, + FileTextIcon: FileTextOutlined, + + // sidebar icons (navMenuItems.ts), added when the sidebar started + // rendering them for the first time + HomeIcon: HomeOutlined, + PackageIcon: InboxOutlined, + UserIcon: UserOutlined, + UsersIcon: TeamOutlined, + UserPlusIcon: UserAddOutlined, + ShoppingBagIcon: ShoppingOutlined, + BoxIcon: InboxOutlined, + GridIcon: AppstoreOutlined, + LayersIcon: BlockOutlined, + CreditCardIcon: CreditCardOutlined, + DollarSignIcon: DollarOutlined, + PercentIcon: PercentageOutlined, + GiftIcon: GiftOutlined, + SlashIcon: StopOutlined, + BookIcon: BookOutlined, + MessageSquareIcon: MessageOutlined, + MailIcon: MailOutlined, + BellIcon: BellOutlined, + BarChartIcon: BarChartOutlined, + SettingsIcon: SettingOutlined, + InboxIcon: InboxOutlined, +}; + +export function resolveIcon(name: string | undefined): unknown | undefined { + if (!name) return undefined; + return ICONS[name]; +} diff --git a/apps/admin-panel/src/components/tooltip-btn/TooltipBtn.vue b/apps/admin-panel/src/components/tooltip-btn/TooltipBtn.vue index 921a926..42ee035 100644 --- a/apps/admin-panel/src/components/tooltip-btn/TooltipBtn.vue +++ b/apps/admin-panel/src/components/tooltip-btn/TooltipBtn.vue @@ -5,8 +5,9 @@ it confirms first, without it fires immediately. Legacy rendered . vue-feather has no Vue 3 - build, so the feather NAME is mapped to an ant-design icon here. Ported views - keep writing icon="ListIcon" unchanged. + build, so the feather NAME is mapped to an ant-design icon via the shared + map in components/icons.ts (also used by the sidebar). Ported views keep + writing icon="ListIcon" unchanged. -->
@@ -33,18 +34,8 @@ diff --git a/apps/admin-panel/src/views/finical/list.vue b/apps/admin-panel/src/views/finical/list.vue index 2ca8934..716dffb 100644 --- a/apps/admin-panel/src/views/finical/list.vue +++ b/apps/admin-panel/src/views/finical/list.vue @@ -64,7 +64,7 @@