import { Injectable, inject } from '@angular/core';
import { Query } from '@datorama/akita';
import { AdminStore, AdminState } from './admin.store';

@Injectable({ providedIn: 'root' })
export class AdminQuery extends Query<AdminState> {
  protected override store = inject(AdminStore);

  constructor() {
    super(inject(AdminStore));
  }

  // About
  about$ = this.select('about');
  aboutLoading$ = this.select(s => s.loading.about);
  aboutError$ = this.select(s => s.error.about);

  // Contact
  contact$ = this.select('contact');
  contactLoading$ = this.select(s => s.loading.contact);
  contactError$ = this.select(s => s.error.contact);

  // Projects
  projects$ = this.select('projects');
  projectsLoading$ = this.select(s => s.loading.projects);
  projectsError$ = this.select(s => s.error.projects);

  // Resume
  resume$ = this.select('resume');
  resumeLoading$ = this.select(s => s.loading.resume);
  resumeError$ = this.select(s => s.error.resume);

  getAbout() {
    return this.getValue().about;
  }

  getContact() {
    return this.getValue().contact;
  }

  getProjects() {
    return this.getValue().projects;
  }

  getResume() {
    return this.getValue().resume;
  }
}
