rewrite some fetch methods to use the useAxios hook

This commit is contained in:
geoffrey45
2022-06-16 14:18:45 +03:00
parent 600b267ce4
commit 92e2420174
17 changed files with 305 additions and 284 deletions
+5 -5
View File
@@ -18,7 +18,7 @@
<script setup lang="ts">
import { onMounted } from "vue";
import { useRoute } from "vue-router";
import { createNewPlaylist } from "../../composables/playlists";
import { createNewPlaylist } from "../../composables/fetch/playlists";
import { Track } from "../../interfaces";
import { Notification, NotifType } from "../../stores/notification";
import usePlaylistStore from "@/stores/pages/playlists";
@@ -43,22 +43,22 @@ emit("title", "New Playlist");
/**
* Create a new playlist. If this modal is called with a track,
* add the track to the new playlist.
* @param e Event
* @param {Event} e
*/
function create(e: Event) {
e.preventDefault();
const name = (e.target as HTMLFormElement).elements["name"].value;
if (name.trim()) {
createNewPlaylist(name, props.track).then((status) => {
createNewPlaylist(name, props.track).then(({ success, playlist }) => {
emit("hideModal");
if (!status.success) return;
if (!success) return;
if (route.name !== "Playlists") return;
setTimeout(() => {
playlistStore.addPlaylist(status.playlist);
playlistStore.addPlaylist(playlist);
}, 600);
});
} else {
+12 -4
View File
@@ -41,7 +41,13 @@
/>
</div>
<div class="submit">
<input type="submit" id="updateplaylistsubmit" class="rounded" value="Update" @click="" />
<input
type="submit"
id="updateplaylistsubmit"
class="rounded"
value="Update"
@click=""
/>
</div>
</form>
</template>
@@ -49,7 +55,7 @@
<script setup lang="ts">
import usePStore from "@/stores/pages/playlist";
import { onMounted } from "vue";
import { updatePlaylist } from "../../composables/playlists";
import { updatePlaylist } from "../../composables/fetch/playlists";
import { Playlist } from "../../interfaces";
const pStore = usePStore();
@@ -105,8 +111,10 @@ function update_playlist(e: Event) {
if (!clicked) {
clicked = true;
const elem = document.getElementById("updateplaylistsubmit") as HTMLFormElement
elem.value = "Updating"
const elem = document.getElementById(
"updateplaylistsubmit"
) as HTMLFormElement;
elem.value = "Updating";
} else {
return;
}