-
form.setValue('color', e.target.value)} style={{ width: 44, height: 38, border: '1px solid var(--border)', borderRadius: 'var(--r-sm)', background: 'none', cursor: 'pointer' }} />
-
{form.watch('color')}
+
+
+ {TAG_COLORS.map((c) => {
+ const selected = form.watch('color') === c;
+ return (
+
-
-
+
+
+
+
+
+ {form.watch('active') ? 'فعال' : 'غیرفعال'}
+
+
+
diff --git a/docs/api/tag.md b/docs/api/tag.md
index cb184c35..bb3c85bf 100644
--- a/docs/api/tag.md
+++ b/docs/api/tag.md
@@ -158,12 +158,13 @@ Without `sort`, the default ordering (weight/name) is unchanged.
### POST `/api/v1/tenant-tag`
```json
-{ "name": "فوری", "color": "#FF0000" }
+{ "name": "فوری", "color": "#FF0000", "active": true }
```
| Field | Type | Required | Validation |
|-------|------|----------|------------|
| `name` | string | ✅ | غیرخالی، حداکثر ۶۰ |
| `color` | string | ❌ | هگز `#RRGGBB` یا `#RRGGBBAA` (پیشفرض `#5559CE`) |
+| `active` | bool | ❌ | وضعیت اولیه (پیشفرض `true`) |
Response `201`: TenantTag object.
diff --git a/src/Tag/Controller/TenantTagController.php b/src/Tag/Controller/TenantTagController.php
index af3599d7..f3f1f78d 100644
--- a/src/Tag/Controller/TenantTagController.php
+++ b/src/Tag/Controller/TenantTagController.php
@@ -68,6 +68,9 @@ class TenantTagController extends BaseController
}
$tag = new TenantTag($type, $id, $name, $color);
+ if (array_key_exists('active', $data)) {
+ $tag->setActive((bool) $data['active']);
+ }
$this->tagRepo->save($tag);
return $this->success($tag->toArray(), 201);
diff --git a/tests/Tag/TenantTagTest.php b/tests/Tag/TenantTagTest.php
index f8e02b95..1573fc80 100644
--- a/tests/Tag/TenantTagTest.php
+++ b/tests/Tag/TenantTagTest.php
@@ -51,6 +51,24 @@ class TenantTagTest extends ApiTestCase
self::assertCount(0, $after['data']);
}
+ public function testCreateHonorsActiveFlag(): void
+ {
+ [$user] = $this->doctorUser();
+
+ // explicit active:false is persisted, not forced to the default true
+ $created = $this->authJson('POST', '/api/v1/tenant-tag', $user, [
+ 'name' => 'بایگانی', 'color' => '#123456', 'active' => false,
+ ]);
+ self::assertSame(201, $this->responseCode());
+ self::assertFalse($created['data']['active']);
+
+ // omitting active still defaults to true
+ $default = $this->authJson('POST', '/api/v1/tenant-tag', $user, [
+ 'name' => 'پیشفرض', 'color' => '#654321',
+ ]);
+ self::assertTrue($default['data']['active']);
+ }
+
public function testRejectsInvalidNameAndColor(): void
{
[$user] = $this->doctorUser();