move album header color methods to composables

This commit is contained in:
geoffrey45
2022-08-03 01:10:08 +03:00
parent c562e529fd
commit db81ee5de3
8 changed files with 100 additions and 119 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
import state from "../state";
import { AlbumInfo, Track } from "../../interfaces";
import useAxios from "../useAxios";
import useAxios from "./useAxios";
import { NotifType, useNotifStore } from "@/stores/notification";
const getAlbumData = async (hash: string, ToastStore: typeof useNotifStore) => {
+1 -1
View File
@@ -1,6 +1,6 @@
import { Folder, Track } from "@/interfaces";
import state from "../state";
import useAxios from "../useAxios";
import useAxios from "./useAxios";
export default async function (path: string) {
interface FolderData {
+1 -1
View File
@@ -2,7 +2,7 @@ import { Artist } from "../../interfaces";
import { Playlist, Track } from "../../interfaces";
import { Notification, NotifType } from "../../stores/notification";
import state from "../state";
import useAxios from "../useAxios";
import useAxios from "./useAxios";
/**
* Creates a new playlist on the server.
* @param playlist_name The name of the playlist to create.
+32
View File
@@ -0,0 +1,32 @@
import { FetchProps } from "../../interfaces";
import axios, { AxiosError, AxiosResponse } from "axios";
export default async (args: FetchProps) => {
let data: any = null;
let error: string = null;
let status: number = null;
function getAxios() {
if (args.get) {
return axios.get(args.url, args.props);
}
if (args.put) {
return axios.put(args.url, args.props, args.headers);
}
return axios.post(args.url, args.props);
}
await getAxios()
.then((res: AxiosResponse) => {
data = res.data;
status = res.status;
})
.catch((err: AxiosError) => {
error = err.message as string;
status = err.response.status as number;
});
return { data, error, status };
};