source: frontend/src/components/search/SongResult.tsx@ c8baad1

main
Last change on this file since c8baad1 was 1579b4f, checked in by Filip Gavrilovski <filipgavrilovski28@…>, 5 months ago

refactor artist, collection, listener components to have similar style as other components; refactor some dto-s

  • Property mode set to 100644
File size: 737 bytes
Line 
1import axiosInstance from "../../api/axiosInstance";
2import type { Song } from "../../utils/types";
3import SongItem from "../SongItem";
4
5interface SongResultProps {
6 song: Song;
7 /** Propagate like state change upward if needed */
8 onLikeToggled?: (songId: number, isLiked: boolean) => void;
9}
10
11const SongResult = ({ song, onLikeToggled }: SongResultProps) => {
12 const handleLike = async (songId: number) => {
13 try {
14 const response = await axiosInstance.post(
15 `/musical-entity/${songId}/like`,
16 );
17 onLikeToggled?.(songId, response.data.isLiked);
18 } catch (err) {
19 console.error("Error toggling like:", err);
20 }
21 };
22
23 return <SongItem song={song} label="Song" onLikeToggle={handleLike} />;
24};
25
26export default SongResult;
Note: See TracBrowser for help on using the repository browser.