{
  "appName": "Customer Feedback",
  "auth": {
    "multiUser": true,
    "selfRegistration": true,
    "defaultRole": "user"
  },
  "startPage": {
    "default": "feedbackFormPage",
    "admin": "viewFeedbackPage"
  },
  "menu": [
    {
      "label": "View Responses",
      "mapsTo": "viewFeedbackPage",
      "roles": [
        "admin"
      ]
    },
    {
      "label": "Submit Feedback",
      "mapsTo": "feedbackFormPage"
    }
  ],
  "pages": {
    "feedbackFormPage": {
      "component": "page",
      "title": "We Value Your Feedback",
      "content": [
        {
          "component": "text",
          "content": "Please let us know how we're doing. Your feedback helps us improve our service.",
          "styleHint": {
            "variant": "body"
          }
        },
        {
          "component": "form",
          "id": "feedbackForm",
          "fields": [
            {
              "name": "customerName",
              "label": "Your Name",
              "type": "text",
              "required": true,
              "placeholder": "e.g., Jane Smith",
              "default": "CURRENT_USER.NAME"
            },
            {
              "name": "customerEmail",
              "label": "Email Address",
              "type": "email",
              "required": true,
              "placeholder": "you@example.com",
              "default": "CURRENT_USER.EMAIL"
            },
            {
              "name": "date",
              "label": "Date",
              "type": "date",
              "default": "NOW"
            },
            {
              "name": "rating",
              "label": "Rating",
              "type": "select",
              "options": [
                "1 - Poor",
                "2 - Fair",
                "3 - Good",
                "4 - Very Good",
                "5 - Excellent"
              ],
              "required": true
            },
            {
              "name": "comments",
              "label": "Comments",
              "type": "multiline",
              "placeholder": "Tell us about your experience..."
            }
          ]
        },
        {
          "component": "button",
          "label": "Submit Feedback",
          "onClick": [
            {
              "action": "submit",
              "dataSource": "feedbackStore",
              "target": "feedbackForm"
            },
            {
              "action": "showMessage",
              "message": "Thank you for your feedback!"
            },
            {
              "action": "navigate",
              "target": "thankYouPage"
            }
          ],
          "styleHint": {
            "emphasis": "primary",
            "icon": "send"
          }
        }
      ]
    },
    "thankYouPage": {
      "component": "page",
      "title": "Thank You!",
      "content": [
        {
          "component": "text",
          "content": "Your feedback has been submitted successfully. We appreciate you taking the time to help us.",
          "styleHint": {
            "variant": "heading"
          }
        },
        {
          "component": "button",
          "label": "Submit Another Response",
          "onClick": [
            {
              "action": "navigate",
              "target": "feedbackFormPage"
            }
          ],
          "styleHint": {
            "emphasis": "primary",
            "icon": "send"
          }
        },
        {
          "component": "button",
          "label": "View All Responses",
          "roles": [
            "admin"
          ],
          "onClick": [
            {
              "action": "navigate",
              "target": "viewFeedbackPage"
            }
          ],
          "styleHint": {
            "emphasis": "secondary",
            "icon": "visibility",
            "variant": "outlined"
          }
        }
      ]
    },
    "viewFeedbackPage": {
      "component": "page",
      "title": "All Feedback",
      "roles": [
        "admin"
      ],
      "content": [
        {
          "component": "summary",
          "label": "Total Responses",
          "value": "{COUNT(feedbackReader)}",
          "icon": "people",
          "styleHint": {
            "color": "info"
          }
        },
        {
          "component": "summary",
          "label": "Average Rating",
          "value": "{AVG(feedbackReader, rating)}",
          "icon": "star",
          "styleHint": {
            "color": "success"
          }
        },
        {
          "component": "chart",
          "dataSource": "feedbackReader",
          "chartType": "pie",
          "labelField": "rating",
          "valueField": "rating",
          "aggregate": "count",
          "title": "Rating Distribution"
        },
        {
          "component": "text",
          "content": "No feedback yet. Share the feedback form to start collecting responses!",
          "styleHint": {
            "variant": "body",
            "align": "center",
            "color": "grey"
          },
          "visibleWhen": {
            "source": "feedbackReader",
            "countEquals": 0
          }
        },
        {
          "component": "list",
          "dataSource": "feedbackReader",
          "searchable": true,
          "columns": [
            {
              "header": "Date",
              "field": "date",
              "sortable": true
            },
            {
              "header": "Name",
              "field": "customerName",
              "sortable": true
            },
            {
              "header": "Rating",
              "field": "rating",
              "sortable": true,
              "filterable": true,
              "colorMap": {
                "5 - Excellent": "green",
                "4 - Very Good": "green",
                "3 - Good": "blue",
                "2 - Fair": "orange",
                "1 - Poor": "red"
              }
            }
          ],
          "defaultSort": {
            "field": "date",
            "direction": "desc"
          },
          "rowActions": [
            {
              "label": "Delete",
              "action": "delete",
              "dataSource": "feedbackDeleter",
              "matchField": "_id"
            }
          ],
          "onRowTap": {
            "action": "navigate",
            "target": "viewDetailPage",
            "populateForm": "detailForm"
          },
          "styleHint": {
            "density": "compact"
          }
        },
        {
          "component": "button",
          "label": "Collect More Feedback",
          "onClick": [
            {
              "action": "navigate",
              "target": "feedbackFormPage"
            }
          ],
          "styleHint": {
            "emphasis": "primary"
          }
        }
      ]
    },
    "viewDetailPage": {
      "component": "page",
      "title": "Feedback Detail",
      "roles": [
        "admin"
      ],
      "content": [
        {
          "component": "detail",
          "fromForm": "detailForm",
          "fields": [
            "customerName",
            "customerEmail",
            "date",
            "rating",
            "comments"
          ],
          "labels": {
            "customerName": "Name",
            "customerEmail": "Email",
            "rating": "Rating",
            "comments": "Comments"
          }
        },
        {
          "component": "form",
          "id": "detailForm",
          "fields": [
            {
              "name": "customerName",
              "label": "Name",
              "type": "text",
              "readOnly": true
            },
            {
              "name": "customerEmail",
              "label": "Email",
              "type": "email",
              "readOnly": true
            },
            {
              "name": "date",
              "label": "Date",
              "type": "date",
              "readOnly": true
            },
            {
              "name": "rating",
              "label": "Rating",
              "type": "select",
              "options": [
                "1 - Poor",
                "2 - Fair",
                "3 - Good",
                "4 - Very Good",
                "5 - Excellent"
              ],
              "readOnly": true
            },
            {
              "name": "comments",
              "label": "Comments",
              "type": "multiline",
              "readOnly": true
            }
          ]
        },
        {
          "component": "button",
          "label": "Back to Responses",
          "onClick": [
            {
              "action": "navigate",
              "target": "viewFeedbackPage"
            }
          ],
          "styleHint": {
            "emphasis": "secondary",
            "icon": "arrow_back",
            "variant": "outlined"
          }
        }
      ]
    }
  },
  "dataSources": {
    "feedbackStore": {
      "url": "local://feedback",
      "method": "POST"
    },
    "feedbackReader": {
      "url": "local://feedback",
      "method": "GET",
      "fields": [
        {
          "name": "customerName",
          "type": "text"
        },
        {
          "name": "customerEmail",
          "type": "email"
        },
        {
          "name": "date",
          "type": "date"
        },
        {
          "name": "rating",
          "type": "select"
        },
        {
          "name": "comments",
          "type": "multiline"
        }
      ],
      "seedData": [
        {
          "customerName": "Alice Johnson",
          "customerEmail": "alice@example.com",
          "date": "2026-03-10",
          "rating": "5 - Excellent",
          "comments": "Absolutely love the service! Fast response times and very helpful staff."
        },
        {
          "customerName": "Bob Martinez",
          "customerEmail": "bob@example.com",
          "date": "2026-03-11",
          "rating": "4 - Very Good",
          "comments": "Great overall experience. Would appreciate more options for scheduling."
        },
        {
          "customerName": "Carol Chen",
          "customerEmail": "carol@example.com",
          "date": "2026-03-12",
          "rating": "3 - Good",
          "comments": "Decent service but the wait time was longer than expected."
        }
      ]
    },
    "feedbackDeleter": {
      "url": "local://feedback",
      "method": "DELETE"
    }
  },
  "help": {
    "overview": "Customer Feedback lets you collect and review feedback from customers. Anyone can submit feedback — just sign up or continue as guest. Admins can view all responses, see rating charts, and manage feedback entries.",
    "pages": {
      "feedbackFormPage": "Fill in name, email, select a rating, and add comments. Press Submit Feedback.",
      "thankYouPage": "Your feedback has been recorded. Thank you!",
      "viewFeedbackPage": "All feedback in a table with color-coded ratings. Filter by rating. Tap any row to see the full comment. Delete responses you no longer need.",
      "viewDetailPage": "View the full feedback detail including comments."
    }
  },
  "tour": [
    {
      "title": "Welcome to Customer Feedback",
      "content": "Collect feedback from customers and review it all in one place. Sign up to submit feedback, or log in as admin to view results."
    },
    {
      "title": "Submit Feedback",
      "content": "Enter name, email, select a rating, and add comments. Email is validated automatically.",
      "page": "feedbackFormPage"
    },
    {
      "title": "View All Responses (Admin Only)",
      "content": "Browse feedback with color-coded ratings. Tap any row for full details. Filter by rating level. Only admins can access this page.",
      "page": "viewFeedbackPage"
    }
  ],
  "theme": {
    "base": "emerald",
    "headerStyle": "solid"
  }
}
