delete playlist modal
This commit is contained in:
@@ -7,11 +7,24 @@ import GradientButton from "../GradientButton";
|
|||||||
import { FONT_FAMILY } from "../../styles/Fonts";
|
import { FONT_FAMILY } from "../../styles/Fonts";
|
||||||
import AppActionSheet from "../AppActionSheet";
|
import AppActionSheet from "../AppActionSheet";
|
||||||
|
|
||||||
const DeleteModal = () => {
|
const DeleteModal = ({ payload }) => {
|
||||||
|
const {
|
||||||
|
title = "Supprimer ma playlist",
|
||||||
|
message = "Es-tu sur de vouloir supprimer ta playlist?",
|
||||||
|
onConfirm,
|
||||||
|
} = payload || {};
|
||||||
|
|
||||||
const onClose = () => {
|
const onClose = () => {
|
||||||
SheetManager.hide("Delete");
|
SheetManager.hide("Delete");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleConfirm = async () => {
|
||||||
|
if (onConfirm) {
|
||||||
|
await onConfirm();
|
||||||
|
}
|
||||||
|
onClose();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppActionSheet id="Delete">
|
<AppActionSheet id="Delete">
|
||||||
<View style={{ gap: 20 }}>
|
<View style={{ gap: 20 }}>
|
||||||
@@ -24,7 +37,7 @@ const DeleteModal = () => {
|
|||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Supprimer ma playlist
|
{title}
|
||||||
</Text>
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
@@ -34,11 +47,11 @@ const DeleteModal = () => {
|
|||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Es-tu sur de vouloir supprimer ta playlist?
|
{message}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ width: "80%", alignSelf: "center", gap: 12 }}>
|
<View style={{ width: "80%", alignSelf: "center", gap: 12 }}>
|
||||||
<BorderGradientButton title="Oui, supprimer" onPress={onClose} />
|
<BorderGradientButton title="Oui, supprimer" onPress={handleConfirm} />
|
||||||
<GradientButton title="Non, annuler" onPress={onClose} />
|
<GradientButton title="Non, annuler" onPress={onClose} />
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -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 { 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 { useDataFromRef } from "react-native-minuit/src/hooks";
|
||||||
import useDataFromArrayId from "react-native-minuit/src/hooks/useDataFromArrayId";
|
import useDataFromArrayId from "react-native-minuit/src/hooks/useDataFromArrayId";
|
||||||
import { playlistsRef, projectsRef } from "../../config/firebase";
|
import { useGlobal } from "reactn";
|
||||||
import MusicCard from "./components/MusicCard";
|
import { background, icons } from "../../assets";
|
||||||
import MoreMenu from "../../components/MoreMenu";
|
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 { Routes } from "../../navigation";
|
||||||
|
import { goBack, navigate } from "../../navigation/NavigationService";
|
||||||
|
import { gutters } from "../../styles";
|
||||||
|
import MusicCard from "./components/MusicCard";
|
||||||
|
|
||||||
const PlaylistDetails = () => {
|
const PlaylistDetails = () => {
|
||||||
const [, setTooltip] = useGlobal("_tooltip");
|
const [, setTooltip] = useGlobal("_tooltip");
|
||||||
@@ -40,15 +41,11 @@ const PlaylistDetails = () => {
|
|||||||
const [selectedProjectId, setSelectedProjectId] = useState(null);
|
const [selectedProjectId, setSelectedProjectId] = useState(null);
|
||||||
|
|
||||||
const confirmDelete = () => {
|
const confirmDelete = () => {
|
||||||
Alert.alert(
|
SheetManager.show("Delete", {
|
||||||
"Supprimer la playlist",
|
payload: {
|
||||||
"Es-tu sûr de vouloir supprimer cette playlist ?",
|
title: "Supprimer la playlist",
|
||||||
[
|
message: "Es-tu sûr de vouloir supprimer cette playlist ?",
|
||||||
{ text: "Annuler", style: "cancel" },
|
onConfirm: async () => {
|
||||||
{
|
|
||||||
text: "Supprimer",
|
|
||||||
style: "destructive",
|
|
||||||
onPress: async () => {
|
|
||||||
try {
|
try {
|
||||||
if (playlistId) {
|
if (playlistId) {
|
||||||
await playlistsRef.doc(playlistId).delete();
|
await playlistsRef.doc(playlistId).delete();
|
||||||
@@ -56,14 +53,16 @@ const PlaylistDetails = () => {
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("Delete playlist error", e?.message);
|
console.log("Delete playlist error", e?.message);
|
||||||
setTooltip({ type: "error", text: e?.message || "Suppression impossible" });
|
setTooltip({
|
||||||
|
type: "error",
|
||||||
|
text: e?.message || "Suppression impossible",
|
||||||
|
});
|
||||||
} finally {
|
} finally {
|
||||||
goBack();
|
goBack();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
});
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user