import {service , newsService} from ".";
import { Job } from "./types";
import {filter, from, map} from "rxjs"
import { AxiosResponse } from "axios";
export const getJobsByDept = async (department: string) => {
  return service.get<unknown, Job[]>(
    '/jobs',
    {
      params: {
        department: department
      }
    }
  )
}

export const getJobsById = async (id: string) => {
  return service.get<unknown, Job>(
    `/jobs/${id}`,
  )
}

export const getNews = () => {
  const res = newsService.get(`news/newsList`)
  const observable = from(res).pipe(filter(r=>r.data))
  return observable
}

export const getNewsDetail = (id:string)=>{
  const res =newsService.get(`news/news?id=${id}`)
  const ob = from(res).pipe(map(v=>v.data))
  return ob
}