terraform {
  required_providers {
    zitadel = {
      source  = "zitadel/zitadel"
      version = "2.0.2"
    }
  }
}

resource "zitadel_org" "default" {
  depends_on = [var.wait_on]
  name       = var.name
  is_default = true
}

// resource "zitadel_action" "groups-claim" {
//   org_id          = zitadel_org.default.id
//   name            = "groupsClaim"
//   script = templatefile("${path.module}/groupsClaim.action.tftpl", {})
//   allowed_to_fail = true
//   timeout         = "10s"
// }
//
// resource "zitadel_trigger_actions" "groups-claim-pre-user-info" {
//   org_id       = zitadel_org.default.id
//   flow_type    = "FLOW_TYPE_CUSTOMISE_TOKEN"
//   trigger_type = "TRIGGER_TYPE_PRE_USERINFO_CREATION"
//   action_ids = [zitadel_action.groups-claim.id]
// }
//
// resource "zitadel_trigger_actions" "groups-claim-pre-access-token" {
//   org_id       = zitadel_org.default.id
//   flow_type    = "FLOW_TYPE_CUSTOMISE_TOKEN"
//   trigger_type = "TRIGGER_TYPE_PRE_ACCESS_TOKEN_CREATION"
//   action_ids = [zitadel_action.groups-claim.id]
// }


output "org_id" {
  value = zitadel_org.default.id
}

output "installed" {
  value = true
  depends_on = [zitadel_org.default]
}
