{
  "schemaVersion": "1.0",
  "id": "submission-redo",
  "title": "Nhắn con làm lại",
  "purpose": "Reject có lý do cụ thể, không điểm, cho child gửi cycle mới.",
  "roles": [
    "guardian"
  ],
  "group": "members-children",
  "variantOf": null,
  "layout": {
    "canvas": {
      "width": 390,
      "height": 844
    },
    "responsive": {
      "minimumWidth": 360,
      "maximumWidth": 430,
      "scroll": "vertical",
      "safeAreaBottom": true,
      "fontScale": "native dynamic type; reflow without clipping",
      "keyboard": "composer sticky within resized viewport; dialog scrolls; no fixed keyboard overlay"
    },
    "regions": [
      {
        "id": "header",
        "order": 0,
        "type": "safe-area/header",
        "height": "intrinsic"
      },
      {
        "id": "content",
        "order": 1,
        "type": "purpose-specific submission",
        "componentIds": [
          "screen-header",
          "submission-redo-0",
          "submission-redo-1",
          "submission-redo-2",
          "screen-actions"
        ]
      },
      {
        "id": "actions",
        "order": 2,
        "type": "one primary + secondary controls"
      },
      {
        "id": "navigation",
        "order": 3,
        "type": "none"
      }
    ]
  },
  "components": [
    {
      "id": "screen-header",
      "type": "Header",
      "props": {
        "homeLabel": "Nhà Lá",
        "scopeGate": "G exact child",
        "backTarget": "submission-review",
        "settingsTarget": "settings"
      },
      "tokens": {
        "foreground": "{semantic.light.fg}",
        "darkForeground": "{semantic.dark.fg}"
      },
      "accessibility": {
        "label": "Thanh đầu màn hình",
        "readingOrder": 0,
        "focusOrder": "back then settings"
      }
    },
    {
      "id": "submission-redo-0",
      "type": "DetailList",
      "props": {
        "items": [
          [
            "Bài gửi",
            "Tưới cây nhỏ · Bông"
          ],
          [
            "Trạng thái",
            "Đang chờ duyệt"
          ]
        ]
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Nhắn con làm lại · DetailList",
        "readingOrder": 1,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "submission-redo-1",
      "type": "Field",
      "props": {
        "name": "reason",
        "label": "Con cần làm lại gì?",
        "type": "textarea",
        "value": "Lau phần nước đọng trên đĩa lót nhé.",
        "required": true,
        "min": null,
        "max": null,
        "options": null,
        "hint": "Lời nhắn ngắn, rõ và không gây xấu hổ.",
        "pattern": null
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Con cần làm lại gì?",
        "readingOrder": 2,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "submission-redo-2",
      "type": "Notice",
      "props": {
        "text": "Gửi lời nhắn sẽ chuyển thành “Cần làm lại”, chưa cộng điểm.",
        "tone": ""
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Nhắn con làm lại · Notice",
        "readingOrder": 3,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "screen-actions",
      "type": "ActionGroup",
      "props": {
        "actions": [
          {
            "id": "reject",
            "label": "Gửi lời nhắn mẫu",
            "kind": "mutate",
            "target": null,
            "confirmationRequired": true
          },
          {
            "id": "navigate-1",
            "label": "Quay lại xem bài",
            "kind": "navigate",
            "target": "submission-review",
            "confirmationRequired": false
          },
          {
            "id": "link-settings",
            "label": "Cài đặt",
            "kind": "navigate",
            "target": "settings",
            "confirmationRequired": false
          }
        ],
        "primaryCount": 1
      },
      "tokens": {
        "lightBackground": "{component.light.button.background}",
        "lightForeground": "{component.light.button.foreground}",
        "darkBackground": "{component.dark.button.background}",
        "darkForeground": "{component.dark.button.foreground}",
        "height": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Hành động của màn hình",
        "keyboard": true,
        "focusVisible": true,
        "disabledOnlyLowContrast": true
      }
    }
  ],
  "fields": [
    {
      "id": "reason",
      "label": "Con cần làm lại gì?",
      "control": "textarea",
      "default": "Lau phần nước đọng trên đĩa lót nhé.",
      "options": null,
      "validation": {
        "required": true,
        "trim": true,
        "type": "textarea",
        "min": null,
        "max": null,
        "pattern": null,
        "serverAuthoritative": true,
        "errorMessage": "Kiểm tra con cần làm lại gì?."
      },
      "binding": "reason",
      "keyboard": "textarea",
      "accessibleErrorAssociation": "form error summary via role alert; native bind field-specific error ID"
    }
  ],
  "states": [
    {
      "id": "draft-reason",
      "when": "Latest pending cycle",
      "visibleUI": "Required nonblank reason",
      "availableActions": [
        "reject",
        "navigate-1",
        "link-settings"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    },
    {
      "id": "rejected",
      "when": "Server accepts reject",
      "visibleUI": "needs_redo +0, child can submit again",
      "availableActions": [
        "reject",
        "navigate-1",
        "link-settings"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    },
    {
      "id": "stale",
      "when": "Submission đã đổi",
      "visibleUI": "Không gửi reject cho cycle khác",
      "availableActions": [
        "navigate-1",
        "link-settings"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    }
  ],
  "actions": [
    {
      "id": "reject",
      "label": "Gửi lời nhắn mẫu",
      "kind": "mutate",
      "targetScreenId": null,
      "permission": "G exact child",
      "confirmationRequired": true,
      "contractRef": "POST /v1/households/{hid}/occurrences/{oid}/reject",
      "localBehavior": "Only validated draft/local domain where supported; remote adapters never report success.",
      "idempotency": "Stable actor/household/command key and canonical body; changed payload is a new confirmed intent."
    },
    {
      "id": "navigate-1",
      "label": "Quay lại xem bài",
      "kind": "navigate",
      "targetScreenId": "submission-review",
      "permission": "G exact child",
      "confirmationRequired": false,
      "contractRef": "local draft/navigation",
      "localBehavior": "Only validated draft/local domain where supported; remote adapters never report success.",
      "idempotency": null
    },
    {
      "id": "link-settings",
      "label": "Cài đặt",
      "kind": "navigate",
      "targetScreenId": "settings",
      "permission": "G exact child",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    }
  ],
  "dataBindings": [
    {
      "source": "POST /v1/households/{hid}/occurrences/{oid}/reject",
      "shape": {
        "expected_version": "integer (GuardianReviewInput)",
        "submission_event_id": "current latest submission event ID",
        "reason": "string required reject only",
        "occurrence": "ChildOccurrenceDto response"
      },
      "sample": {
        "expected_version": 2,
        "submission_event_id": "submission-plants-example",
        "reason": "Lau đĩa lót nhé.",
        "occurrence": {
          "occurrence_id": "occ-blanket",
          "task_id": "blanket",
          "task_title": "Gấp chăn, xếp gối",
          "instructions": "Gấp chăn rồi xếp gối.",
          "room_id": "living",
          "room_name": "Phòng khách",
          "due_local_date": "2026-10-14",
          "due_timezone": "Asia/Ho_Chi_Minh",
          "snoozed_until_local_date": null,
          "effort_snapshot": 1,
          "status": "open",
          "version": 1,
          "latest_submission_event_id": null,
          "can_submit": true
        }
      },
      "sampleOnly": true,
      "actorConstraint": "exact actor allowlist",
      "envelope": "API refs use CommandEnvelope; local review context is not an API property."
    }
  ],
  "copy": {
    "heading": "Nhắn con làm lại",
    "primary": "Gửi lời nhắn mẫu",
    "empty": null,
    "notices": [
      "Gửi lời nhắn sẽ chuyển thành “Cần làm lại”, chưa cộng điểm."
    ],
    "locale": "vi",
    "demoLabel": "Bản thiết kế · dữ liệu mẫu · không kết nối dịch vụ"
  },
  "implementation": {
    "nativeRoute": "/design/submission-redo",
    "nativeRouteStatus": "proposed mapping, verify against implementing native navigator",
    "apiRefs": [
      "POST /v1/households/{hid}/occurrences/{oid}/reject"
    ],
    "newContractRefs": [],
    "notes": [
      "Tất cả ví dụ là dữ liệu thiết kế, không bằng chứng native/API/store đã chạy.",
      "Native route dưới đây là đề xuất mapping cho agent, không tuyên bố route source đã tồn tại.",
      "Mọi mutation dùng envelope {data,version,household_revision,replayed}, stable Idempotency-Key và expected_version khi sửa.",
      "Accepted-day recurrence; occurrence due/effort snapshot bất biến; snooze không đổi anchor; pending không reassign; undo điều chỉnh ledger đúng một lần."
    ],
    "integrationStatus": "design complete; local static/draft interactions; native/API adapters pending",
    "sourceAuthority": [
      "docs/product-brief.md",
      "plans/261013-1409-sweepy-vietnam-mobile/mobile-flows.md",
      "plans/261013-1409-sweepy-vietnam-mobile/api-contracts.md",
      "packages/domain/src/contracts/phase2.ts",
      "packages/domain/src/index.ts",
      "packages/domain/src/contracts/phase3.ts",
      "packages/domain/src/contracts/billing.ts",
      "apps/mobile/src/lib/api.ts"
    ],
    "capability": "G exact child",
    "errors": {
      "401": "Stop queue; adult login or child re-pair without parent account.",
      "403": "Do not retry lost capability. FEATURE_REQUIRED never grants Pro.",
      "409": "Fetch canonical scoped state; review/reconfirm new intent, do not rewrite old replay payload.",
      "422": "Field error with retained draft.",
      "429": "Respect Retry-After.",
      "503": "Backoff only retryable commands with original key."
    }
  }
}
