{
  "$ref": {
    "calendarDataSchema": {
      "type": "object",
      "properties": {
        "_id": {
          "type": "string",
          "excludeFromSearch": true,
          "label": "ID",
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "startDate": {
          "type": "string",
          "format": "date-time",
          "excludeFromSearch": true,
          "label": {
            "it": "Inizio disponibilità",
            "en": "Availability start"
          },
          "dateOptions": {
            "displayFormat": "DD/MM/YYYY - HH:mm"
          },
          "formOptions": {
            "readOnlyOnUpdate": true
          }
        },
        "endDate": {
          "type": "string",
          "format": "date-time",
          "excludeFromSearch": true,
          "label": {
            "it": "Fine disponibilità",
            "en": "Availability end"
          },
          "dateOptions": {
            "displayFormat": "DD/MM/YYYY - HH:mm"
          },
          "formOptions": {
            "readOnly": true
          }
        },
        "slots": {
          "type": "array",
          "excludeFromSearch": true,
          "label": "Slots",
          "formOptions": {
            "hidden": true,
            "readOnly": true
          }
        },
        "doctor": {
          "type": "string",
          "excludeFromSearch": true,
          "label": "Dottore"
        },
        "title": {
          "type": "string",
          "excludeFromSearch": true,
          "label": "Titolo"
        },
        "eventType": {
          "type": "string",
          "excludeFromSearch": true,
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "resourceId": {
          "type": "number",
          "excludeFromSearch": true,
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "reason": {
          "type": "string",
          "excludeFromSearch": true,
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "address": {
          "type": "string",
          "excludeFromSearch": true,
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "isFlagged": {
          "type": "boolean",
          "excludeFromSearch": true,
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "client": {
          "type": "string",
          "excludeFromSearch": true,
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "performance": {
          "type": "string",
          "excludeFromSearch": true,
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "creatorId": {
          "type": "string",
          "excludeFromSearch": true,
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "createdAt": {
          "type": "string",
          "excludeFromSearch": true,
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "updaterId": {
          "type": "string",
          "excludeFromSearch": true,
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "updatedAt": {
          "type": "string",
          "excludeFromSearch": true,
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "__STATE__": {
          "type": "string",
          "label": "Stato",
          "enum": ["PUBLIC", "DRAFT"],
          "visualizationOptions": {
            "iconMap": {
              "PUBLIC": {
                "shape": "roundedSquare",
                "color": "#52C41A"
              },
              "DRAFT": {
                "shape": "roundedSquare",
                "color": "#CDCDCE"
              }
            }
          },
          "formOptions": {
            "hidden": true
          }
        }
      },
      "formLinks": [],
      "required": ["startDate", "endDate"]
    }, 
    "modalDataSchema": {
      "type": "object",
      "properties": {
        "_id": {
          "type": "string",
          "excludeFromSearch": true,
          "label": "ID",
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "resource": {
          "type": "string",
          "label": {
            "it": "Dottore",
            "en": "Doctor"
          },
          "formOptions": {
            "readOnly": true
          }
        },
        "address": {
          "type": "string",
          "label": {
            "it": "Sede",
            "en": "Site"
          },
          "formOptions": {
            "readOnly": true
          }
        },
        "startDate": {
          "type": "string",
          "format": "date-time",
          "excludeFromSearch": true,
          "label": {
            "it": "Inizio slot",
            "en": "Slot start"
          },
          "dateOptions": {
            "displayFormat": "DD/MM/YYYY - HH:mm"
          },
          "formOptions": {
            "readOnly": true
          }
        },
        "endDate": {
          "type": "string",
          "format": "date-time",
          "excludeFromSearch": true,
          "label": {
            "it": "Fine slot",
            "en": "Slot end"
          },
          "dateOptions": {
            "displayFormat": "DD/MM/YYYY - HH:mm"
          },
          "formOptions": {
            "readOnly": true
          }
        },
        "client": {
          "type": "string",
          "format": "lookup",
          "label": {
            "it": "Paziente",
            "en": "Patient"
          },
          "lookupOptions": {
            "lookupDataSource": "patients",
            "lookupValue": "_id",
            "lookupFields": ["firstName", "lastName"],
            "lookupDelimiter": " "
          },
          "unique": false,
          "formOptions": {
            "readOnly": false
          },
          "visualizationOptions": {
            "hidden": true
          }
        },
        "performance": {
          "type": "string",
          "format": "lookup",
          "label": {
            "it": "Prestazione",
            "en": "Performance"
          },
          "lookupOptions": {
            "lookupDataSource": "performances",
            "lookupValue": "_id",
            "lookupFields": ["name"]
          },
          "unique": false,
          "formOptions": {
            "readOnly": false
          },
          "visualizationOptions": {
            "hidden": true
          }
        },
        "description": {
          "type": "string",
          "format": "text-area",
          "label": {
            "it": "Note",
            "en": "Notes"
          },
          "unique": false,
          "formOptions": {
            "readOnly": false
          }
        }
      },
      "required": [
        "resource", 
        "address",
        "startDate", 
        "endDate", 
        "client", 
        "performance" 
      ]
    }, 
    "modalDataSchemaReadOnly": {
      "type": "object",
      "properties": {
        "_id": {
          "type": "string",
          "excludeFromSearch": true,
          "label": "ID",
          "visualizationOptions": {
            "hidden": true
          },
          "formOptions": {
            "hidden": true
          },
          "filtersOptions": {
            "hidden": true
          }
        },
        "resource": {
          "type": "string",
          "label": {
            "it": "Dottore",
            "en": "Doctor"
          },
          "formOptions": {
            "readOnly": true
          }
        },
        "address": {
          "type": "string",
          "label": {
            "it": "Sede",
            "en": "Site"
          },
          "formOptions": {
            "readOnly": true
          }
        },
        "startDate": {
          "type": "string",
          "format": "date-time",
          "excludeFromSearch": true,
          "label": {
            "it": "Inizio slot",
            "en": "Slot start"
          },
          "dateOptions": {
            "displayFormat": "DD/MM/YYYY - HH:mm"
          },
          "formOptions": {
            "readOnly": true
          }
        },
        "endDate": {
          "type": "string",
          "format": "date-time",
          "excludeFromSearch": true,
          "label": {
            "it": "Fine slot",
            "en": "Slot end"
          },
          "dateOptions": {
            "displayFormat": "DD/MM/YYYY - HH:mm"
          },
          "formOptions": {
            "readOnly": true
          }
        },
        "client": {
          "type": "string",
          "label": {
            "it": "Paziente",
            "en": "Patient"
          },
          "unique": false,
          "formOptions": {
            "readOnly": true
          },
          "visualizationOptions": {
            "hidden": true
          }
        },
        "performance": {
          "type": "string",
          "label": {
            "it": "Prestazione",
            "en": "Performance"
          },
          "unique": false,
          "formOptions": {
            "readOnly": true
          },
          "visualizationOptions": {
            "hidden": true
          }
        },
        "description": {
          "type": "string",
          "format": "text-area",
          "label": {
            "it": "Note",
            "en": "Notes"
          },
          "unique": false,
          "formOptions": {
            "readOnly": true
          }
        }
      },
      "required": [
        "resource", 
        "address",
        "startDate", 
        "endDate", 
        "client", 
        "performance" 
      ]
    }
  },
  "content": {
    "attributes": {
      "style": "height: calc(100vh - 64px);"
    },
    "type": "row",
    "content": [
      {
        "type": "element",
        "attributes": {
          "style": "background-color: white; padding: 1em; border-radius: 8px; margin-bottom: 2em; display:flex; flex-direction: column; flex-grow: 1"
        },
        "tag": "am-calendar",
        "properties": {
          "view": "day",
          "height": "90vh",
          "appointmentMode": true,
          "resourceId": "doctorId",
          "calendarEndpoint": "http://localhost:3456/v2/availabilities",
          "slotConfig": {
            "centeredPopover": false,
            "additionalProperty":[
              {
                "property": "performance",
                "label": {
                  "it": "Prestazione",
                  "en": "Performance"
                }
              }
            ]
          },
          "popoverConfig": {
            "details": [
              {
                "property": "status",
                "label": {
                  "it": "Stato",
                  "en": "Status"
                },
                "value": {
                  "AVAILABLE": {
                    "it": "Disponibile",
                    "en": "Available"
                  },
                  "BOOKED": {
                    "it": "Prenotato",
                    "en": "Booked"
                  },
                  "UNAVAILABLE": {
                    "it": "Non disponibile",
                    "en": "Unavailable"
                  }
                }
              }
            ]
          },
          "appointmentConfig": {
            "titleProperty": ["client", "performance"],
            "ownerProperty": "client",
            "additionalProperty": [
              {
                "property": "performance",
                "label": {
                  "it": "Prestazione",
                  "en": "Performance"
                }
              }
            ]
          },
          "resourceConfig": {
            "resourcesEndpoint": "http://localhost:3456/api/v1/resources",
            "delimiter": " - ",
            "details": [
              {
                "property": ["doctorId", "name"],
                "delimiter": " "
              },
              {
                "property": ["specialization"]
              }
            ]
          }
        }
      },            
      {
        "type": "element",
        "tag": "bk-form-modal",
        "properties": {
          "dataSchema": {
            "$ref": "modalDataSchema"
          },
          "width": "70vw",
          "requireConfirm": true,
          "customLabels": {
            "create": {
              "title": {
                "it": "Aggiungi appuntamento",
                "en": "Add appointment"
              },
              "ctaLabel": {
                "it": "Prenota appuntamento",
                "en": "Book appointment"
              }
            },
            "update": {
              "title": {
                "it": "Dettaglio appuntamento",
                "en": "Appointment details"
              },
              "ctaLabel": {
                "it": "Salva",
                "en": "Save"
              }
            }
          }
        }
      },
      {
        "type": "element",
        "tag": "bk-form-modal",
        "properties": {
          "dataSchema": {
            "$ref": "modalDataSchemaReadOnly"
          },
          "width": "70vw",
          "extraEndpoint": "/",
          "readonlyOnView": true,
          "customLabels": {
            "create": {
              "title": {
                "it": "Dettaglio appuntamento",
                "en": "Appointment details"
              },
              "ctaLabel": {
                "it": "",
                "en": ""
              }
            }
          }
        }
      },
      {
        "type": "element",
        "tag": "bk-confirmation-modal"
      },
      {
        "type": "element",
        "tag": "bk-crud-lookup-client",
        "properties": {
          "basePath": "/v2",
          "dataSchema": {
            "$ref": "modalDataSchema"
          }
        }
      },
      {
        "type": "element",
        "url": "/back-kit/latest/bk-web-components.esm.js",
        "tag": "bk-crud-client",
        "properties": {
          "basePath": "/v2/availabilities",
          "dataSchema": {
            "$ref": "calendarDataSchema"
          }
        }
      },
      {
        "type": "element",
        "tag": "bk-notifications",
        "properties": {
          "rootElementSelectors": "main.micro-lc-layout-content",
          "successEventMap": {
            "create-data": {
              "title": {
                "en": "Success",
                "it": "Successo"
              },
              "content": {
                "en": "Event successfully created",
                "it": "L'evento è stato creato correttamente"
              },
              "type": "success"
            },
            "update-data": {
              "title": {
                "en": "Success",
                "it": "Successo"
              },
              "content": {
                "en": "Event successfully updated",
                "it": "L'evento è stato aggiornato correttamente"
              },
              "type": "success"
            },
            "delete-data": {
              "title": {
                "en": "Success",
                "it": "Successo"
              },
              "content": {
                "en": "Event successfully deleted",
                "it": "L'evento è stato eliminato correttamente"
              },
              "type": "success"
            }
          },
          "errorEventMap": {
            "create-data": {
              "title": {
                "en": "Error",
                "it": "Errore"
              },
              "content": {
                "en": "An error occurred during event creation",
                "it": "C'è stato un errore durante la creazione dell'evento"
              },
              "type": "error"
            },
            "update-data": {
              "title": {
                "en": "Error",
                "it": "Errore"
              },
              "content": {
                "en": "An error occurred during event update",
                "it": "C'è stato un errore durante l'aggiornamento dell'evento"
              },
              "type": "error"
            },
            "delete-data": {
              "title": {
                "en": "Error",
                "it": "Errore"
              },
              "content": {
                "en": "An error occurred during event deletion",
                "it": "C'è stato un errore durante l'eliminazione dell'evento"
              },
              "type": "error"
            }
          }
        }
      }
    ]
  }
}


