import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { environment } from '../../environments/environment'; import { Observable } from 'rxjs'; export interface QAItem { label: string; input_type: 'text' | 'date' | 'select' | 'radio' | 'multiselect' | 'checkbox' | 'textarea' | 'number'; options?: string[]; column_key: string; category: string; required?: boolean; placeholder?: string; } export interface CategoryMeta { key: string; title: string; } @Injectable({ providedIn: 'root' }) export class QuestionAnswerService { private baseUrl: string; constructor(private http: HttpClient) { this.baseUrl = typeof location !== 'undefined' && location.hostname.endsWith('hf.space') ? 'https://pykara-py-match-backend.hf.space/api/questions' : 'http://127.0.0.1:5000/api/questions'; } getQuestions(role: string): Observable { return this.http.get(`${this.baseUrl}/${role}`); } getCategories(role: string): Observable { return this.http.get(`${this.baseUrl}/categories/${role}`); } getExistingProfile(role: string, userId: number): Observable { return this.http.get(`${this.baseUrl}/existing-profile/${role}/${userId}`); } submitAnswers(role: string, userId: number, fields: Record): Observable { const payload = { user_id: userId, ...fields }; return this.http.post(`${this.baseUrl}/submit-answers/${role}`, payload); } updateAnswers(role: string, userId: number, fields: Record): Observable { const payload = { user_id: userId, ...fields }; return this.http.put(`${this.baseUrl}/update-answers/${role}`, payload); } }