fix(discount): correct edit-form data + calendar clipping + input styling

- List endpoint returned camelCase keys (getArrayResult) so the edit modal
  read empty discount_type/target_*; return toArray() (snake_case) instead.
- Portal the Persian date-picker calendar to body (fixed) so it no longer
  renders under the modal's overflow-scroll body.
- Style the PriceInput/number fields with cp-input in the rule modal.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-07-17 12:37:43 +03:30
co-authored by Claude Fable 5
parent 809ad11680
commit 204c7debe1
4 changed files with 35 additions and 17 deletions
@@ -49,7 +49,8 @@ class DiscountController extends BaseController
if ($ownerId === null) {
return $this->error(ErrorCodes::ERR_AUTH_006, 'دسترسی ممنوع', 403);
}
return $this->success(['data' => $this->ruleRepo->listForOwner($ownerType, $ownerId)]);
$items = array_map(fn(DiscountRule $r) => $r->toArray(), $this->ruleRepo->findAllForOwner($ownerType, $ownerId));
return $this->success(['data' => $items]);
}
#[Route('/api/v1/admin/discount-rules', methods: ['POST'])]
@@ -37,13 +37,17 @@ class DiscountRuleRepository extends ServiceEntityRepository
return $this->findBy(['ownerType' => $ownerType, 'ownerId' => $ownerId, 'active' => true], ['priority' => 'DESC']);
}
/** لیست ادمین به‌صورت آرایه (array hydration). */
public function listForOwner(string $ownerType, int $ownerId): array
/**
* لیست کامل قوانین یک owner (شامل غیرفعال‌ها) برای ادمین، مرتب بر priority.
* موجودیت‌ها برمی‌گردند تا کنترلر با toArray() قرارداد snake_case فرانت را بدهد.
* @return DiscountRule[]
*/
public function findAllForOwner(string $ownerType, int $ownerId): array
{
return $this->createQueryBuilder('r')
->where('r.ownerType = :t')->setParameter('t', $ownerType)
->andWhere('r.ownerId = :i')->setParameter('i', $ownerId)
->orderBy('r.priority', 'DESC')->addOrderBy('r.id', 'DESC')
->getQuery()->getArrayResult();
->getQuery()->getResult();
}
}