<div class="spt-container">
    <div class="spt-form">
        @if (data !== undefined) {
            <form [formGroup]="userZoneForm" (ngSubmit)="onSubmit()">
                @if (user) {
                    <div>{{ 'base_data.pilot' | translate }}: {{ user.fullName }}</div>
                } @else {
                    <div class="row">
                        <label for="userIri" class="form-label">{{ 'base_data.pilot' | translate }}*:</label>
                        <app-search-select #userSearchSelect
                                           [formId]="'userIri'"
                                           [formLabelLangKey]="'model.user'"
                                           [documentForm]="userZoneForm"
                                           [getDataFunction]="getUsers"
                                           [displayedDataField]="'fullName'"
                                           [listColDefinitions]="userColDefinitions"
                                           [dataSet]="user"
                        >
                        </app-search-select>
                        <input id="userIri" type="hidden" formControlName="userIri" required/>
                    </div>
                }
                @if (zone) {
                    <div>{{ 'model.zone' | translate }}: {{ zone.name }}</div>
                } @else {
                    <div class="col-12 mb-3">
                        <label for="zoneIri" class="form-label">{{ 'model.zone' | translate }}*:</label>
                        <app-search-select #zoneSearchSelect
                                           [formId]="'zoneIri'"
                                           [formLabelLangKey]="'model.zone'"
                                           [documentForm]="userZoneForm"
                                           [getDataFunction]="getZones"
                                           [displayedDataField]="'name'"
                                           [listColDefinitions]="zoneColDefinitions"
                                           [dataSet]="zone"
                        >
                        </app-search-select>
                        <input id="zoneIri" type="hidden" formControlName="zoneIri" required/>
                    </div>
                }
            </form>
        }
    </div>

    <div class="row">
        <div class="col-12 mb-3">
            <button type="submit" class="btn btn-primary" (click)="onSubmit()">
                {{ 'basic.save' | translate }}
            </button>

            @if (isEditMode()) {
                <button type="button" class="ms-3 btn btn-primary" (click)="onDelete()">
                    {{ 'basic.delete' | translate }} {{ 'model.user_trip' | translate }}
                </button>
            }
        </div>
    </div>
</div>