fix broken date on book stuff
This commit is contained in:
@@ -43,9 +43,15 @@ export default function RecentBook() {
|
|||||||
})
|
})
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const parseDate = (date: Date) => {
|
const getDateString = (startedOn: Date, finished: boolean) => {
|
||||||
const jsDate = new Date(date);
|
if (startedOn && !finished) {
|
||||||
return `${jsDate.getFullYear()}/${jsDate.getMonth() + 1}/${jsDate.getDate()}`;
|
const startedOnDate = new Date(startedOn);
|
||||||
|
return "Started on " + startedOnDate.toLocaleDateString();
|
||||||
|
} else if (finished) {
|
||||||
|
return "Finished!"
|
||||||
|
} else {
|
||||||
|
return "Just Added"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data && !loading) {
|
if (data && !loading) {
|
||||||
@@ -53,7 +59,7 @@ export default function RecentBook() {
|
|||||||
<ProjectComponent
|
<ProjectComponent
|
||||||
header={"What I'm reading"}
|
header={"What I'm reading"}
|
||||||
projectHeader={data.title}
|
projectHeader={data.title}
|
||||||
projectSubheader={ data.finished ? "Finished!" : "Started on " + parseDate(data.startedOn) }
|
projectSubheader={getDateString(data.startedOn, data.finished)}
|
||||||
url={"https://tracker.alexav.gg/?type=books&id=" + data.id}
|
url={"https://tracker.alexav.gg/?type=books&id=" + data.id}
|
||||||
projectImage={data.imageKey}
|
projectImage={data.imageKey}
|
||||||
projectImageSize={"30"}
|
projectImageSize={"30"}
|
||||||
|
|||||||
@@ -22,12 +22,10 @@ export default function RecentPhoto() {
|
|||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
console.log("ok!")
|
|
||||||
const json = await res.json()
|
const json = await res.json()
|
||||||
setData(json.data[0]);
|
setData(json.data[0]);
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
} else {
|
} else {
|
||||||
console.log("not ok :(")
|
|
||||||
setErrorState("Failed to fetch data!");
|
setErrorState("Failed to fetch data!");
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user