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

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

export const createNote = (customer_number, note) => {
  const token = localStorage.getItem('token');
  if (!token) {
    return null;
  }
  return axios.post(API_URL + '/customer/notes', {
    customer_number,
    note
  }, {
    headers: {
      Authorization: `Bearer ${token}`
    }
  });
};

export const deleteNote = (id) => {
  const token = localStorage.getItem('token');
  if (!token) {
    return null;
  }
  return axios.delete(API_URL + '/customer/notes?id=' + id, {
    headers: {
      Authorization: `Bearer ${token}`
    }
  });
};
</script>