<script>
import { ref } from 'vue'
import axios from 'axios'
import {API_URL} from "@/main.js";

export const getScanners = () => {
  const token = localStorage.getItem('token');
  if (!token) {
    return null;
  }
  return axios.get(API_URL + '/numberplatescanners', {
    headers: {
      Authorization: `Bearer ${token}`
    }
  });
};

export const createScanner = (department_id, name, notes) => {
  const token = localStorage.getItem('token');
  if (!token) {
    return null;
  }
  return axios.post(API_URL + '/numberplatescanners', {
    department_id,
    name,
    notes
  }, {
    headers: {
      Authorization: `Bearer ${token}`
    }
  });
};

export const editScanner = (id, department_id, name, notes) => {
  const token = localStorage.getItem('token');
  if (!token) {
    return null;
  }
  return axios.put(API_URL + '/numberplatescanners', {
    id,
    department_id,
    name,
    notes
  }, {
    headers: {
      Authorization: `Bearer ${token}`
    }
  });
};
</script>