mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 12:33:03 +00:00
rewrite some fetch methods to use the useAxios hook
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user