delete playlist modal

This commit is contained in:
2025-09-02 16:47:32 +02:00
parent 364dca526b
commit 88cb5fcdfb
2 changed files with 47 additions and 35 deletions
+30 -31
View File
@@ -1,17 +1,18 @@
import React, { useState } from "react";
import { View, Pressable, Image, Alert } from "react-native";
import { useGlobal } from "reactn";
import Page from "../../layouts/Page";
import { background, icons } from "../../assets";
import { gutters } from "../../styles";
import { useRoute } from "@react-navigation/native";
import React, { useState } from "react";
import { Image, Pressable, View } from "react-native";
import { SheetManager } from "react-native-actions-sheet";
import { useDataFromRef } from "react-native-minuit/src/hooks";
import useDataFromArrayId from "react-native-minuit/src/hooks/useDataFromArrayId";
import { playlistsRef, projectsRef } from "../../config/firebase";
import MusicCard from "./components/MusicCard";
import { useGlobal } from "reactn";
import { background, icons } from "../../assets";
import MoreMenu from "../../components/MoreMenu";
import { navigate, goBack } from "../../navigation/NavigationService";
import { playlistsRef, projectsRef } from "../../config/firebase";
import Page from "../../layouts/Page";
import { Routes } from "../../navigation";
import { goBack, navigate } from "../../navigation/NavigationService";
import { gutters } from "../../styles";
import MusicCard from "./components/MusicCard";
const PlaylistDetails = () => {
const [, setTooltip] = useGlobal("_tooltip");
@@ -40,30 +41,28 @@ const PlaylistDetails = () => {
const [selectedProjectId, setSelectedProjectId] = useState(null);
const confirmDelete = () => {
Alert.alert(
"Supprimer la playlist",
"Es-tu sûr de vouloir supprimer cette playlist ?",
[
{ text: "Annuler", style: "cancel" },
{
text: "Supprimer",
style: "destructive",
onPress: async () => {
try {
if (playlistId) {
await playlistsRef.doc(playlistId).delete();
setTooltip({ type: "success", text: "Playlist supprimée" });
}
} catch (e) {
console.log("Delete playlist error", e?.message);
setTooltip({ type: "error", text: e?.message || "Suppression impossible" });
} finally {
goBack();
SheetManager.show("Delete", {
payload: {
title: "Supprimer la playlist",
message: "Es-tu sûr de vouloir supprimer cette playlist ?",
onConfirm: async () => {
try {
if (playlistId) {
await playlistsRef.doc(playlistId).delete();
setTooltip({ type: "success", text: "Playlist supprimée" });
}
},
} catch (e) {
console.log("Delete playlist error", e?.message);
setTooltip({
type: "error",
text: e?.message || "Suppression impossible",
});
} finally {
goBack();
}
},
],
);
},
});
};
return (