<script>
import { ref } from "vue";
import { authenticatedRequest } from "@/components/session/authenticatedRequest.vue";
import { parseError } from "@/components/request/HandleGlobalError.vue";

/**
 * The database system object
 */
export const DatabaseSystemObject = {
  status: ref(null),
};

/**
 * Get the system database status
 * @returns
 */
export const getSystemDatabaseStatus = async () => {
  return await authenticatedRequest("/superuser/system/database/status", "GET")
    .then((response) => {
      DatabaseSystemObject.status.value = response.data.data.status;
    })
    .catch((error) => {
      parseError(error, "superuser");
      console.error(error);
    });
};
</script>