# Add Feature Checklist

Copy and track when adding a new admin section (e.g. `coupons`):

```
- [ ] Pages.ts paths
- [ ] types/{Feature}Types.ts
- [ ] service/{Feature}Service.ts
- [ ] hooks/use{Feature}Data.ts
- [ ] List.tsx (+ Create/Update if CRUD)
- [ ] components/ (Delete, filters, etc.)
- [ ] Main.tsx routes + imports
- [ ] SideBar.tsx (+ SubMenu if multi-page)
- [ ] fa.json translations
```

## 1. Pages.ts

```typescript
coupons: {
  list: "/coupons/list",
  create: "/coupons/create",
  detail: "/coupons/detail/",
},
```

Use kebab-case URL segments consistent with existing routes.

## 2. Service + hooks + types

Copy structure from `src/pages/customer/` or `src/pages/ads/`. Adjust API paths to match backend.

## 3. Main.tsx

Add import at top, then route(s):

```tsx
import CouponsList from "../pages/coupons/List";
// ...
<Route path={Pages.coupons.list} element={<CouponsList />} />
<Route path={Pages.coupons.create} element={<CreateCoupon />} />
<Route path={Pages.coupons.detail + ":id"} element={<UpdateCoupon />} />
```

## 4. Sidebar (optional)

**Single-page feature** — add `SideBarItem`:

```tsx
<SideBarItem
  icon={<TicketDiscount variant={isActive("coupons") ? "Bold" : "Outline"} color={isActive("coupons") ? "black" : "#8C90A3"} size={iconSizeSideBar} />}
  title={t("sidebar.coupons")}
  isActive={isActive("coupons")}
  link={Pages.coupons.list}
  activeName="coupons"
/>
```

**Multi-page feature** — also:

1. Add the feature’s URL segment → group mapping in `getSubMenuNameFromPath` / `pathSegmentToSubMenu` (`src/config/SideBarSubMenu.ts`)
2. Add links under the matching group SubMenu (e.g. `MenuSubMenu.tsx`) using `SubMenuItem`
3. If the feature has nested pages, wrap them in `SubMenuAccordion` (arrow open/close) inside that group SubMenu
4. Do not add a new top-level sidebar group unless the feature is a new section (reseller/dmenu-style)

## 5. Translations

Add keys under logical groups in `src/langs/fa.json`:

```json
"sidebar": { "coupons": "کوپن‌ها" },
"submenu": { "coupon_list": "لیست کوپن‌ها" },
"coupon": { "coupon_list": "لیست کوپن‌ها", "add_coupon": "افزودن کوپن" }
```

Use `t('coupon.add_coupon')` in components.

## 6. Verify

- `npm run build` passes
- List loads, create/update navigate correctly
- Sidebar highlights on correct routes
- Mutation invalidates list query cache
