check existing song url before navigating
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { useCallback } from "react";
|
||||
import { useGlobal } from "reactn";
|
||||
import { Routes } from "../navigation";
|
||||
import { navigate } from "../navigation/NavigationService";
|
||||
|
||||
const useNavigateToMusicDetails = () => {
|
||||
const [, setTooltip] = useGlobal("_tooltip");
|
||||
|
||||
return useCallback(
|
||||
({ projectId, songUrl }) => {
|
||||
if (!projectId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (songUrl != null && songUrl !== "") {
|
||||
navigate(Routes.MusicDetails, { projectId });
|
||||
return true;
|
||||
}
|
||||
|
||||
setTooltip({
|
||||
type: "error",
|
||||
text: "Les paroles pour cette musique n'ont pas été générées",
|
||||
});
|
||||
return false;
|
||||
},
|
||||
[setTooltip]
|
||||
);
|
||||
};
|
||||
|
||||
export default useNavigateToMusicDetails;
|
||||
Reference in New Issue
Block a user