mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-21 19:30:16 +00:00
chore: fix some misc syntax bugs
This commit is contained in:
parent
11643afe4b
commit
42362ba14b
@ -1,13 +1,15 @@
|
|||||||
import { Playlist } from "../types/playlist";
|
import { Playlist } from "../types/playlist";
|
||||||
import { Playlists } from "../types/playlists";
|
import { Playlists } from "../types/playlists";
|
||||||
import { TA_BASE_URL } from "./constants";
|
import { getTAUrl } from "./constants";
|
||||||
|
|
||||||
|
const TA_BASE_URL = getTAUrl();
|
||||||
|
|
||||||
export const getPlaylists = async (token: string): Promise<Playlists> => {
|
export const getPlaylists = async (token: string): Promise<Playlists> => {
|
||||||
if (!token) {
|
if (!token) {
|
||||||
throw new Error(`No token provided when fetching a playlists`);
|
throw new Error(`No token provided when fetching a playlists`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetch(`${TA_BASE_URL}/api/playlist/`, {
|
const response = await fetch(`${TA_BASE_URL.server}/api/playlist/`, {
|
||||||
headers: {
|
headers: {
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@ -33,14 +35,17 @@ export const getPlaylist = async (
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetch(`${TA_BASE_URL}/api/playlist/${playlistId}`, {
|
const response = await fetch(
|
||||||
headers: {
|
`${TA_BASE_URL.server}/api/playlist/${playlistId}`,
|
||||||
Accept: "application/json",
|
{
|
||||||
"Content-Type": "application/json",
|
headers: {
|
||||||
Authorization: `Token ${token}`,
|
Accept: "application/json",
|
||||||
mode: "no-cors",
|
"Content-Type": "application/json",
|
||||||
},
|
Authorization: `Token ${token}`,
|
||||||
});
|
mode: "no-cors",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Error getting playlists information: ${response.statusText}`
|
`Error getting playlists information: ${response.statusText}`
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
* @param number A number or string number
|
* @param number A number or string number
|
||||||
* @returns A number string with an appropriate letter appended
|
* @returns A number string with an appropriate letter appended
|
||||||
*/
|
*/
|
||||||
export function formatNumbers(number: string): string {
|
export function formatNumbers(number: string | number): string | number {
|
||||||
var numberUnformatted = parseFloat(number);
|
var numberUnformatted = parseFloat(number as string);
|
||||||
if (numberUnformatted > 999999999) {
|
if (numberUnformatted > 999999999) {
|
||||||
var numberFormatted =
|
var numberFormatted =
|
||||||
(numberUnformatted / 1000000000).toFixed(1).toString() + "B";
|
(numberUnformatted / 1000000000).toFixed(1).toString() + "B";
|
||||||
|
@ -171,7 +171,9 @@ const Channel: NextPage = () => {
|
|||||||
</a>
|
</a>
|
||||||
</h3>
|
</h3>
|
||||||
{/* {% if channel.source.channel_subs >= 1000000 %} */}
|
{/* {% if channel.source.channel_subs >= 1000000 %} */}
|
||||||
<p>Subscribers: {formatNumbers(channel?.channel_subs)} </p>
|
<p>
|
||||||
|
Subscribers: {formatNumbers(channel?.channel_subs)}{" "}
|
||||||
|
</p>
|
||||||
{/* {% else %} */}
|
{/* {% else %} */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -185,10 +187,20 @@ const Channel: NextPage = () => {
|
|||||||
className="unsubscribe"
|
className="unsubscribe"
|
||||||
type="button"
|
type="button"
|
||||||
id="{{ channel.source.channel_id }}"
|
id="{{ channel.source.channel_id }}"
|
||||||
onClick={() => console.log("unsubscribe(this.id) -> toggleSubscribe()")}
|
onClick={() =>
|
||||||
title={`${channel?.channel_subscribed ? "Unsubscribe from" : "Subscribe to"} ${channel?.channel_name}`}
|
console.log(
|
||||||
|
"unsubscribe(this.id) -> toggleSubscribe()"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
title={`${
|
||||||
|
channel?.channel_subscribed
|
||||||
|
? "Unsubscribe from"
|
||||||
|
: "Subscribe to"
|
||||||
|
} ${channel?.channel_name}`}
|
||||||
>
|
>
|
||||||
{channel?.channel_subscribed ? "Unsubscribe" : "Subscribe"}
|
{channel?.channel_subscribed
|
||||||
|
? "Unsubscribe"
|
||||||
|
: "Subscribe"}
|
||||||
</button>
|
</button>
|
||||||
{/* {% else %} */}
|
{/* {% else %} */}
|
||||||
{/* <button
|
{/* <button
|
||||||
|
@ -5,7 +5,7 @@ import { useState } from "react";
|
|||||||
import { dehydrate, QueryClient, useQuery } from "react-query";
|
import { dehydrate, QueryClient, useQuery } from "react-query";
|
||||||
import { CustomHead } from "../components/CustomHead";
|
import { CustomHead } from "../components/CustomHead";
|
||||||
import { Layout } from "../components/Layout";
|
import { Layout } from "../components/Layout";
|
||||||
import { TA_BASE_URL } from "../lib/constants";
|
import { getTAUrl } from "../lib/constants";
|
||||||
import { getPlaylists } from "../lib/getPlaylists";
|
import { getPlaylists } from "../lib/getPlaylists";
|
||||||
import IconAdd from "../images/icon-add.svg";
|
import IconAdd from "../images/icon-add.svg";
|
||||||
import IconListView from "../images/icon-listview.svg";
|
import IconListView from "../images/icon-listview.svg";
|
||||||
@ -13,6 +13,8 @@ import IconGridView from "../images/icon-gridview.svg";
|
|||||||
|
|
||||||
type ViewStyle = "grid" | "list";
|
type ViewStyle = "grid" | "list";
|
||||||
|
|
||||||
|
const TA_BASE_URL = getTAUrl();
|
||||||
|
|
||||||
export const getServerSideProps: GetServerSideProps = async (context) => {
|
export const getServerSideProps: GetServerSideProps = async (context) => {
|
||||||
const queryClient = new QueryClient();
|
const queryClient = new QueryClient();
|
||||||
const session = await getSession(context);
|
const session = await getSession(context);
|
||||||
@ -140,7 +142,7 @@ const Playlist = () => {
|
|||||||
<div className="playlist-thumbnail">
|
<div className="playlist-thumbnail">
|
||||||
<a href="{% url 'playlist_id' playlist.source.playlist_id %}">
|
<a href="{% url 'playlist_id' playlist.source.playlist_id %}">
|
||||||
<img
|
<img
|
||||||
src={`${TA_BASE_URL}/${playlist.playlist_thumbnail}`}
|
src={`${TA_BASE_URL.client}/${playlist.playlist_thumbnail}`}
|
||||||
alt={`${playlist.playlist_id}-thumbnail`}
|
alt={`${playlist.playlist_id}-thumbnail`}
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user