update to new content tracker endpoints
This commit is contained in:
@@ -1,37 +1,21 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import ProjectComponent from '../ProjectComponent';
|
||||
|
||||
type BookDataResponse = {
|
||||
status: number,
|
||||
data: BookData
|
||||
};
|
||||
type BookData = {
|
||||
id: number,
|
||||
title: string,
|
||||
author: string,
|
||||
description: string,
|
||||
imageKey: string,
|
||||
finished: boolean,
|
||||
startedOn: Date,
|
||||
createdAt: Date,
|
||||
updatedAt: Date,
|
||||
createdById: string
|
||||
}
|
||||
import type { ContentTrackerItem } from '../../utils/types';
|
||||
|
||||
export default function RecentBook() {
|
||||
const [ data, setData ] = useState<BookData | null>(null);
|
||||
const [ data, setData ] = useState<ContentTrackerItem | null>(null);
|
||||
const [ loading, setLoading ] = useState<boolean>(true);
|
||||
const [ errorState, setErrorState ] = useState<string>("");
|
||||
|
||||
useEffect(() => {
|
||||
fetch("https://api.alexav.gg/v4/social/books", {
|
||||
fetch("https://api.alexav.gg/v4/tracker/latest/book", {
|
||||
method: 'get'
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (res.ok) {
|
||||
const json = await res.json() as BookDataResponse;
|
||||
const json = await res.json();
|
||||
setData(json.data);
|
||||
setLoading(false)
|
||||
setLoading(false);
|
||||
} else {
|
||||
setErrorState("Failed to fetch data!");
|
||||
setLoading(false);
|
||||
@@ -61,7 +45,7 @@ export default function RecentBook() {
|
||||
projectHeader={data.title}
|
||||
projectSubheader={getDateString(data.startedOn, data.finished)}
|
||||
url={"https://tracker.alexav.gg/?type=books&id=" + data.id}
|
||||
projectImage={data.imageKey}
|
||||
projectImage={data.image}
|
||||
/>
|
||||
)
|
||||
} else {
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import ProjectComponent from '../ProjectComponent';
|
||||
|
||||
type WatchDataResponse = {
|
||||
status: number,
|
||||
data: WatchData
|
||||
};
|
||||
type WatchData = {
|
||||
id: number,
|
||||
title: string,
|
||||
description: string,
|
||||
imageKey: string,
|
||||
currentEpisode: string,
|
||||
tmdbID: string,
|
||||
author?: string,
|
||||
image: string,
|
||||
episode?: string,
|
||||
tmdbId?: string,
|
||||
finished: boolean,
|
||||
startedOn: Date,
|
||||
startedOn?: Date,
|
||||
createdAt: Date,
|
||||
updatedAt: Date,
|
||||
createdById: string
|
||||
@@ -25,12 +22,12 @@ export default function RecentWatch() {
|
||||
const [ errorState, setErrorState ] = useState<string>("");
|
||||
|
||||
useEffect(() => {
|
||||
fetch("https://api.alexav.gg/v4/social/watch", {
|
||||
fetch("https://api.alexav.gg/v4/tracker/latest/tv", {
|
||||
method: 'get'
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (res.ok) {
|
||||
const json = await res.json() as WatchDataResponse;
|
||||
const json = await res.json();
|
||||
setData(json.data);
|
||||
setLoading(false)
|
||||
} else {
|
||||
@@ -48,7 +45,7 @@ export default function RecentWatch() {
|
||||
if (data?.finished) {
|
||||
return "Finished!"
|
||||
} else if (data?.startedOn) {
|
||||
return "Started on " + new Date(data.startedOn).toLocaleDateString()
|
||||
return "Last update on " + new Date(data.updatedAt).toLocaleDateString()
|
||||
} else {
|
||||
return "Just Added"
|
||||
}
|
||||
@@ -61,7 +58,7 @@ export default function RecentWatch() {
|
||||
projectHeader={data.title}
|
||||
projectSubheader={ getSubheaderText() }
|
||||
url={"https://tracker.alexav.gg/?type=tv&id=" + data.id}
|
||||
projectImage={data.imageKey}
|
||||
projectImage={data.image}
|
||||
/>
|
||||
)
|
||||
} else {
|
||||
|
||||
+21
-10
@@ -1,9 +1,4 @@
|
||||
type MusicAPIResponse = {
|
||||
data: {
|
||||
tracks: MusicData[]
|
||||
}
|
||||
}
|
||||
|
||||
// music type
|
||||
type MusicData = {
|
||||
artist: {
|
||||
mbid: string,
|
||||
@@ -18,13 +13,29 @@ type MusicData = {
|
||||
url: string,
|
||||
image: MusicImage[]
|
||||
}
|
||||
|
||||
type MusicImage = {
|
||||
size: string,
|
||||
"#text": string
|
||||
}
|
||||
|
||||
export type {
|
||||
MusicAPIResponse,
|
||||
MusicData
|
||||
// tracker type
|
||||
type ContentTrackerItem = {
|
||||
id: number,
|
||||
title: string,
|
||||
author?: string,
|
||||
description: string,
|
||||
episode?: string,
|
||||
image: string,
|
||||
type: "tv" | "book" | "game",
|
||||
tmdbId?: string,
|
||||
yearReleased: number,
|
||||
updatedAt: Date,
|
||||
genre: string,
|
||||
startedOn: Date,
|
||||
finished: boolean
|
||||
}
|
||||
|
||||
export type {
|
||||
MusicData,
|
||||
ContentTrackerItem
|
||||
}
|
||||
Reference in New Issue
Block a user