You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

63 lines
1.8 KiB

  1. import {Component, Input, OnInit} from '@angular/core';
  2. import {FormGroup} from "@angular/forms";
  3. import {contactForm} from "@app/_forms/apiForms";
  4. import {ContactJsonld, ContactService} from "@app/core/api/v1";
  5. import {Subscription} from "rxjs";
  6. import {ModalContent} from "@app/_interfaces/modalContent";
  7. @Component({
  8. selector: 'app-new-contact',
  9. templateUrl: './new-contact.component.html',
  10. styleUrl: './new-contact.component.scss'
  11. })
  12. export class NewContactComponent implements ModalContent, OnInit {
  13. @Input() public inputData: any;
  14. protected contactForm: FormGroup;
  15. protected selectedImage: File | null;
  16. protected contactSub: Subscription;
  17. constructor(
  18. private contactService: ContactService,
  19. ) {
  20. this.contactForm = contactForm;
  21. this.selectedImage = null;
  22. this.contactSub = new Subscription();
  23. }
  24. ngOnInit(): void {
  25. console.log(this.inputData);
  26. }
  27. onSubmit() {
  28. //console.log(this.partnerId);
  29. if (this.contactForm.valid) {
  30. // Hier können Sie die Daten senden oder weitere Aktionen durchführen
  31. console.log(this.selectedImage);
  32. console.log('Formular wurde gesendet:', this.contactForm.value);
  33. let newContact: ContactJsonld = this.contactForm.value as ContactJsonld;
  34. newContact.postings = [];
  35. this.contactSub = this.contactService.contactsPost(
  36. this.contactForm.value as ContactJsonld
  37. ).subscribe(
  38. data => {
  39. console.log(data);
  40. }
  41. );
  42. }
  43. }
  44. onFileSelected(event: any) {
  45. const file: File = event.target.files[0];
  46. if (file) {
  47. this.selectedImage = file;
  48. }
  49. }
  50. }