aceite-edit.component.html 8.88 KB
<div mat-dialog-title>
  <h1>Editar Aceite</h1>
</div>

<form [formGroup]="empForm" (ngSubmit)="onFormSubmit()">
  <div mat-dialog-content class="content">
    <div class="row">
      <mat-form-field class="field full-width" appearance="outline">
        <mat-label>IMO</mat-label>
        <input matInput type="number" (keydown)="preventNegative($event)" min="0" formControlName="imo">
        <mat-error>
          <ng-container *ngIf="empForm.get('imo')?.invalid">
            <ng-container *ngIf="getErrorMessage('imo') === 'Esse imo não existe'">
              {{ getErrorMessage('imo') }}, se desejar soliciatar a criação de um novo navio,
              <a (click)="exibirFormNavio()" style="text-decoration: underline">clique aqui!</a>
            </ng-container>
            <ng-container *ngIf="getErrorMessage('imo') !== 'Esse imo não existe'">
              {{ getErrorMessage('imo') }}
            </ng-container>
          </ng-container>
        </mat-error>
      </mat-form-field>
      <mat-form-field class="field full-width" appearance="outline">
        <mat-label>MMSI</mat-label>
        <input matInput type="text" formControlName="mmsi" (keydown)="preventNegative($event)">
        <mat-error *ngIf="empForm.get('mmsi')?.invalid">{{ getErrorMessage('mmsi') }}</mat-error>
      </mat-form-field>
    </div>
    <div class="row">
      <mat-form-field class="field large" appearance="outline">
        <mat-label>Nome</mat-label>
        <input matInput type="text" formControlName="nome">
        <mat-error *ngIf="empForm.get('nome')?.invalid">{{ getErrorMessage('nome') }}</mat-error>
      </mat-form-field>
      <mat-form-field class="field medium" appearance="outline">
        <mat-label>LOA (m)</mat-label>
        <input matInput type="text" [currencyMask]="{ prefix: '', thousands: '.', decimal: ',' }" formControlName="loa">
        <mat-error *ngIf="empForm.get('loa')?.invalid">{{ getErrorMessage('loa') }}</mat-error>
      </mat-form-field>
      <mat-form-field class="field small" appearance="outline">
        <mat-label>Boca (m)</mat-label>
        <input matInput type="text" [currencyMask]="{ prefix: '', thousands: '.', decimal: ',' }" formControlName="boca">
        <mat-error *ngIf="empForm.get('boca')?.invalid">{{ getErrorMessage('boca') }}</mat-error>
      </mat-form-field>
    </div>
    <div class="row">
      <mat-form-field class="field medium" appearance="outline">
        <mat-label>Calado de Entrada</mat-label>
        <input matInput type="text" [currencyMask]="{ prefix: '', thousands: '.', decimal: ',' }" formControlName="calado_entrada">
        <mat-error *ngIf="empForm.get('calado_entrada')?.invalid">{{ getErrorMessage('calado_entrada') }}</mat-error>
      </mat-form-field>
      <mat-form-field class="field medium" appearance="outline">
        <mat-label>Calado de Saída</mat-label>
        <input matInput type="text" [currencyMask]="{ prefix: '', thousands: '.', decimal: ',' }" formControlName="calado_saida">
        <mat-error *ngIf="empForm.get('calado_saida')?.invalid">{{ getErrorMessage('calado_saida') }}</mat-error>
      </mat-form-field>
    </div>
    <div class="row">
      <mat-form-field class="field large" appearance="outline">
        <mat-label>DWT (Atual)</mat-label>
        <input matInput type="text" [currencyMask]="{ prefix: '', thousands: '.', decimal: ',' }" formControlName="dwt">
        <mat-error *ngIf="empForm.get('dwt')?.invalid">{{ getErrorMessage('dwt') }}</mat-error>
      </mat-form-field>
      <mat-form-field class="field medium" appearance="outline">
        <mat-label>Pontal (m)</mat-label>
        <input matInput type="text" [currencyMask]="{ prefix: '', thousands: '.', decimal: ',' }" formControlName="pontal">
        <mat-error *ngIf="empForm.get('pontal')?.invalid">{{ getErrorMessage('pontal') }}</mat-error>
      </mat-form-field>
      <mat-form-field class="field small" appearance="outline">
        <mat-label>Ponte Mfold (m)</mat-label>
        <input matInput type="text" [currencyMask]="{ prefix: '', thousands: '.', decimal: ',' }" formControlName="ponte_mfold">
        <mat-error *ngIf="empForm.get('ponte_mfold')?.invalid">{{ getErrorMessage('ponte_mfold') }}</mat-error>
      </mat-form-field>
    </div>
    <div class="row">
      <mat-form-field class="field large" appearance="outline">
        <mat-label>Mfold Quilha (m)</mat-label>
        <input matInput type="text" [currencyMask]="{ prefix: '', thousands: '.', decimal: ',' }" formControlName="mfold_quilha">
        <mat-error *ngIf="empForm.get('mfold_quilha')?.invalid">{{ getErrorMessage('mfold_quilha') }}</mat-error>
      </mat-form-field>
      <mat-form-field class="field medium" appearance="outline">
        <mat-label>Categoria</mat-label>
        <mat-select formControlName="categoria">
          <mat-option *ngFor="let cat of categoria" [value]="cat.id">
            {{ cat.nome }}
          </mat-option>
        </mat-select>
        <mat-error *ngIf="empForm.get('categoria')?.invalid">{{ getErrorMessage('categoria') }}</mat-error>
      </mat-form-field>
      <mat-form-field class="field small" appearance="outline">
        <mat-label>Flag</mat-label>
        <mat-select formControlName="flag">
          <mat-select-trigger>
            <img
              *ngIf="selectedCountry"
              [src]="selectedCountry.flagUrl"
              width="20"
              height="15"
              alt="{{ selectedCountry.name }} flag"
              style="margin-right: 8px"
            />
            {{ selectedCountry?.name }}
          </mat-select-trigger>
          <mat-option
            *ngFor="let country of countries"
            [value]="country.id"
            (onSelectionChange)="onCountrySelected(country)"
          >
            <img
              [src]="country.flagUrl"
              width="20"
              height="15"
              alt="{{ country.name }} flag"
              style="margin-right: 8px"
            />
            {{ country.name }}
          </mat-option>
        </mat-select>
        <mat-error *ngIf="empForm.get('flag')?.invalid">
          {{ getErrorMessage("flag") }}
        </mat-error>
      </mat-form-field>
    </div>
  
    <div class="row">
      <mat-form-field class="field full-width" appearance="outline">
        <mat-label>Observação</mat-label>
        <input matInput type="text" formControlName="obs">
        <mat-error *ngIf="empForm.get('obs')?.invalid">{{ getErrorMessage('obs') }}</mat-error>
      </mat-form-field>
    </div>
    
    <!-- Sexta Linha: Status -->
    <div class="row">
      <mat-form-field class="field large" appearance="outline">
        <mat-label>Status</mat-label>
        <mat-select formControlName="status" (selectionChange)="onStatusChange($event.value)">
          <mat-option value="Y">Aceito</mat-option>
          <mat-option value="NE">Negado</mat-option>
          <mat-option value="N">Em Processamento</mat-option>
        </mat-select>
        <mat-error *ngIf="empForm.get('status')?.invalid">{{ getErrorMessage('status') }}</mat-error>
      </mat-form-field>
    </div>
    <div *ngIf="empForm.get('status')?.value === 'Y' || empForm.get('status')?.value === 'NE'" class="field large">
      <mat-form-field class="field large" appearance="outline">
        <mat-label>Comentários sobre o aceite:</mat-label>
        <input matInput type="text" formControlName="restricoes">
        <mat-error *ngIf="empForm.get('restricoes')?.invalid">
          {{ getErrorMessage('restricoes') }}
        </mat-error>
      </mat-form-field>
      <div class="row file-upload-container">
        <mat-label style="color:cadetblue">Adicione o documente Q88 da embarcação</mat-label>
        <input
          type="file"
          class="file-input"
          (change)="onFileSelected($event)"
          #fileUpload
          style="display: none"
        />

        <div class="file-upload-content">
          <div class="file-info">
            <span>{{ fileName || "No file uploaded yet." }}</span>
          </div>

          <div class="upload-button-wrapper">
            <button
              mat-mini-fab
              color="primary"
              class="upload-btn"
              (click)="fileUpload.click()"
              type="button"
            >
              <mat-icon>attach_file</mat-icon>
            </button>
          </div>
        </div>

        <div class="uploaded-image-container" *ngIf="imageUrl">
          <img [src]="imageUrl" alt="Uploaded Image" class="uploaded-image" />
          <button
            mat-mini-fab
            color="warn"
            class="remove-image-btn"
            (click)="removeImage()"
            type="button"
          >
            <mat-icon>close</mat-icon>
          </button>
        </div>
      </div>
    </div>
  </div>
  
  <!-- Ações do Diálogo -->
  <div mat-dialog-actions class="action">
    <button mat-raised-button type="button" color="warn" [mat-dialog-close]="false">Cancelar</button>
    <button mat-raised-button color="primary" type="submit">Salvar</button>
  </div>
</form>