import { Component, inject, OnInit } from '@angular/core';
import { ButtonModule } from 'primeng/button';
import { FileUploadEvent, FileUploadModule } from 'primeng/fileupload';
import { MessageService } from 'primeng/api';
import { FileUpload } from 'primeng/fileupload';
import { ToastModule } from 'primeng/toast';
import { AppSettingService } from '../shares';
/*
interface UploadEvent {
    originalEvent: Event;
    files: File[];
}*/

@Component({
  selector: 'app-import.com',
  imports: [FileUploadModule, ButtonModule,ToastModule,FileUpload],
  templateUrl: './import.com.html',
  styleUrl: './import.com.css'
})
export class ImportCom implements OnInit {
   uploadedFiles: any[] = [];
   baseUrl = "";
   private appSetting = inject(AppSettingService);
  constructor(private messageService: MessageService) {}
ngOnInit(): void
  { 
    const cbaseUrl = this.appSetting.appSetting.baseUrl;     
        //http://localhost:5015/api/FileUpload/UploadFile" 
    this.baseUrl = cbaseUrl + "/api/FileUpload/UploadFile";
  }
onUpload(event:FileUploadEvent) {
        for(let file of event.files) {
            this.uploadedFiles.push(file);
        }

        this.messageService.add({severity: 'info', summary: 'File Uploaded', detail: ''});
    }
}
