Skip to content

Commit

Permalink
allow users to add to on queue from song page
Browse files Browse the repository at this point in the history
  • Loading branch information
ddusichka committed Dec 5, 2024
1 parent 3380de3 commit 1f42820
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions frontend/components/media/MediaCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import {
Dimensions,
TouchableWithoutFeedback,
} from "react-native";
import axios from "axios";
import { Button, IconButton } from "react-native-paper";
import { LinearGradient } from "expo-linear-gradient";
import { useAuthContext } from "../AuthProvider";

type MediaCardProps = {
media: Media;
Expand All @@ -29,6 +31,14 @@ const MediaCard = ({
showTopBar = true,
showRateButton = true,
}: MediaCardProps) => {
const BASE_URL = process.env.EXPO_PUBLIC_BASE_URL;
const { userId } = useAuthContext();
const addToOnQueue = async () => {
await axios.post(`${BASE_URL}/playlist/on_queue/${userId}`, {
...media,
});
};

return (
<TouchableWithoutFeedback>
<View style={styles.container}>
Expand Down Expand Up @@ -60,12 +70,14 @@ const MediaCard = ({
size={24}
onPress={() => console.log("More options pressed")}
/>
<IconButton
icon="bookmark-outline"
iconColor="white"
size={24}
onPress={() => console.log("More options pressed")}
/>
{media?.media_type === "track" && (
<IconButton
icon="bookmark-outline"
iconColor="white"
size={24}
onPress={() => addToOnQueue()}
/>
)}
</View>
</View>
)}
Expand Down

0 comments on commit 1f42820

Please sign in to comment.