-
Notifications
You must be signed in to change notification settings - Fork 0
/
temp.txt
184 lines (154 loc) · 9.3 KB
/
temp.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
const format = (date) => {
const [dd, mm, yyyy] = date.split('-');
return (correctDate(yyyy) + '-' + correctDate(mm) + '-' + correctDate(dd));
}
const correctDate = (value) => {
if (parseInt(value, 10) >= 10)
return value;
else
return '0' + value;
}
const checkDateRange = (date) => {
const taskTimestamp = (new Date(format(date))).getTime();
const startTimestamp = ((new Date(startDate)).getTime());
const endTimestamp = ((new Date(endDate)).getTime());
return taskTimestamp >= startTimestamp && taskTimestamp <= endTimestamp;
}
const [startDate, setStartDate] = useState('');
const [endDate, setEndDate] = useState('');
<div className=" w-24 h-24 mt-3">
<img
src={`${eachEpisode.images[0].url}`} width="100" height="100" style={{
minWidth: '80px',
minHeight: '80px'
}}
alt="cover-page"></img>
</div>
<div className="episode-details w-3/4 mt-1">
<div className=" overflow-hidden w-full">
<p className=" text-base sm:text-lg font-semibold hover:underline cursor-pointer text-twoline-wrap">{eachEpisode.name}</p>
<div className=" sm:flex gap-1 hidden ">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor" className="w-5 h-5 mt-1">
<path strokeLinecap="round" strokeLinejoin="round" d="m15.75 10.5 4.72-4.72a.75.75 0 0 1 1.28.53v11.38a.75.75 0 0 1-1.28.53l-4.72-4.72M4.5 18.75h9a2.25 2.25 0 0 0 2.25-2.25v-9a2.25 2.25 0 0 0-2.25-2.25h-9A2.25 2.25 0 0 0 2.25 7.5v9a2.25 2.25 0 0 0 2.25 2.25Z" />
</svg>
<span>Video<span className= " font-extrabold mr-2 ml-2">.</span><a href={`${data.external_urls.spotify}`} className=" hover:underline cursor-pointer">{data.name}</a></span>
</div>
</div>
<div className="episode-description mt-3">
<div className="text">{eachEpisode.description}</div>
</div>
<div className=" w-full h-auto flex flex-col">
<div className=" mt-2">
<span>{eachEpisode.release_date}<span className=" font-extrabold ml-1 mr-1">.</span><span>{formatDuration(eachEpisode.duration_ms)}</span></span>
</div>
<div className="tools-section flex min-w-fit gap-8 items-center mt-5 mb-5 hover">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="currentColor" className="w-8 h-8">
<path strokeLinecap="round" stroke-linejoin="round" d="M12 9v6m3-3H9m12 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
</svg>
<div className=" flex gap-8 items-center" >
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="currentColor" className="w-8 h-8">
<path strokeLinecap="round" strokeLinejoin="round" d="m9 12.75 3 3m0 0 3-3m-3 3v-7.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="currentColor" className="w-6 h-6">
<path strokeLinecap="round" strokeLinejoin="round" d="M7.217 10.907a2.25 2.25 0 1 0 0 2.186m0-2.186c.18.324.283.696.283 1.093s-.103.77-.283 1.093m0-2.186 9.566-5.314m-9.566 7.5 9.566 5.314m0 0a2.25 2.25 0 1 0 3.935 2.186 2.25 2.25 0 0 0-3.935-2.186Zm0-12.814a2.25 2.25 0 1 0 3.933-2.185 2.25 2.25 0 0 0-3.933 2.185Z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="currentColor" className="w-8 h-8">
<path strokeLinecap="round" strokeLinejoin="round" d="M6.75 12a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM12.75 12a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM18.75 12a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0Z" />
</svg>
</div>
</div>
</div>
</div>
http://localhost:3000/#
access_token=BQBlXbeRgO84jMA5bC8Xt1AUbLin17_F-Wuvj3z3KTcMkP61cuwsfIM_T6CHjNat7imkHqKPF0g_pKFh-L0N1MQmEnfHrU2XUEJJ_i33Lbv2q3wpsoWv5JweJGOtWRUO22bzaBoKK6NXRrSypXt4eimE52-pj8AvCAFSSU4g4BUkgQ8qKR78qijXpW-ZhWpEsbXxdys021eZ8tQiAgYaFQFCQv0oKw&
token_type=Bearer&
expires_in=3600
import { useEffect, useState } from "react";
import { CloseIcon, PlusIcon } from "./Icons/Icons";
export const DisplaySong = ({user, playlistId, setAddStatus}) => {
const [recTracl, setRecTrack] = useState(null);
const user_token = window.localStorage.getItem("user_token");
const addSong = (songIndex, uris) => {
setRecTrack(prev => {
const newTracks = [...prev.items.slice(0, songIndex), ...prev.items.slice(songIndex + 1)];
return{...prev, items: newTracks};
})
fetch(`https://api.spotify.com/v1/playlists/${playlistId}/tracks`,{
method: 'POST',
headers: {
'Authorization': `Bearer ${user_token}`,
},
body: JSON.stringify({
uris: [uris]
})
})
.then( (res) => {
if (!res.ok) {
throw new Error("Can't add song ");
}
console.log("song added");
})
.catch( (e) => {
console.log(e.message);
})
};
useEffect ( () => {
fetch(`https://api.spotify.com/v1/me/player/recently-played?limit=24`,{
method: 'GET',
headers: {
'Authorization': `Bearer ${user_token}`,
}
})
.then( (res) => {
if (!res.ok) {
throw new Error("Can't fetch user details");
}
console.log("user details fetched");
return res.json();
})
.then( (data) => {
setRecTrack(data);
})
.catch( (e) => {
console.log(e.message);
})
}, [user_token]);
return(
<div className=" fixed z-10 left-2/4 top-2/4 -translate-x-2/4 -translate-y-2/4 flex p-4 justify-center items-center w-11/12 h-3/4 bg-zinc-900 rounded-lg">
<span className=" absolute left-2 top-2" onClick={() => {
setAddStatus(false);
}}><CloseIcon /></span>
<div className=" flex flex-col gap-4 w-full h-full p-4 overflow-y-auto ">
<h1 className=" font-bold text-lg">Recently played</h1>
hello
{recTracl && recTracl.items.map( (eachItem, index) => (
<div className=" w-full grid grid-cols-3 " key={index + "" + eachItem.track.id}>
<div>
<img src={eachItem.track.album.images[0].url} width={40} className=" rounded-md"></img>
</div>
<div className=" w-full flex flex-col text-twoline-wrap ">
<div><span className=" text-sm">{eachItem.track.name}</span></div>
<div><span className=" text-xs opacity-60">{eachItem.track.artists[0].name}</span></div>
</div>
<div onClick={() => {
addSong(index, eachItem.track.uri);
}}
className=" w-full flex justify-center items-center">{<PlusIcon />}</div>
</div>
))}
</div>
</div>
);
}
import { ExpandIcon, HomeIcon, LibraryIcon, SearchIcon } from "./Icons/Icons";
import { Link } from "react-router-dom/cjs/react-router-dom.min";
export const BottomNav = () => {
return (
<div className=" fixed w-full h-14 top-section z-10 bottom-0 left-0 flex items-center justify-around sm:hidden text-xs">
<Link className=" flex flex-col items-center gap-1 " to="/"> <HomeIcon className=" ml-2" /><span>Home</span></Link>
<Link className="flex flex-col items-center gap-1" to="/search"><SearchIcon /><span>Search</span></Link>
<Link className="flex flex-col items-center gap-1" to="/library"><LibraryIcon /><span>Your Library</span></Link>
<Link className=" flex flex-col items-center gap-1" to="/premium"><ExpandIcon className="ml-2" /><span>Premium</span></Link>
</div>
);
}