<script>
import Swal from "sweetalert2";
import { authenticatedRequest } from "@/components/session/authenticatedRequest.vue";
import { ObjectsGlobal } from "@/components/session/token/SessionUser/Objects/ObjectsGlobal.vue";
import { SessionUser } from "@/components/session/token/SessionUser.vue";
import {ref} from "vue";

/**
 * The Forms object
 */
export const Forms = {
  meta: {
    title: "Formularer",
    icon: "fas fa-list",
    description: "Oversigt over formularer",
    endpoint: "/form",
    labels: {
      single: "formular",
      multiple: "formularer",
      fields: {
        names: {
          customer_number: {
            label: "E-conomic kundenummer",
          },
          contact_email: {
            label: "Kontakt email",
          },
          reference: {
            label: "Reference",
          },
          registration_number_tractor: {
            label: "Reg. nr. trækker",
          },
          registration_number_trailer: {
            label: "Reg. nr. trailer",
          },
          wants_wash_certificate: {
            label: "Ønsker vaskecertifikat ( Safety Seal )",
          },
          wants_wash_certificate_email: {
            label: "Email til vaskecertifikat",
          },
          date: {
            label: "Dato",
          },
          department_id: {
            label: "Afdeling",
          },
          wants_pickup: {
            label: "Ønsker afhentning",
          },
          notes: {
            label: "Noter",
          },
        },
      }
    }
  },
  get: {
    single: async (identifier) => {
      return ObjectsGlobal.get.object(Forms.meta.endpoint, identifier, {authenticated: SessionUser.functions.hasToken()});
    }
  },
  functions: {
    submit: async (form) => {
      console.log(form);
      return ObjectsGlobal.add.object(Forms.meta.endpoint, form, {authenticated: SessionUser.functions.hasToken()});
    },
  },
};
</script>