-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from unicornultrafoundation/v1.31
v1.31
- Loading branch information
Showing
39 changed files
with
999 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { useQuery } from "@tanstack/react-query" | ||
import { Article } from "./useNews" | ||
import { fetchNewsDetail } from "../service/news" | ||
import { formatDate } from "../util/date" | ||
import { logErrorForMonitoring } from "./useCrashlytics" | ||
|
||
export const useNewsDetail = (id: string) => { | ||
const {data, isFetching} = useQuery<Article>({ | ||
queryKey: ['news-details', id], | ||
queryFn: async () => { | ||
try { | ||
// const rs = await fetchFeaturedNews() | ||
const rs = await fetchNewsDetail(id) | ||
if (!rs.data) return {} as Article | ||
const rawNews = rs.data | ||
const dateUnixNumber = Number(rawNews.create_at) | ||
return { | ||
id: rawNews.news_id, | ||
title: rawNews.news_title, | ||
description: rawNews.meta_desc, | ||
date: formatDate(new Date(dateUnixNumber * 1000), "MMMM dd, yyyy"), | ||
category: rawNews.news_categories, | ||
thumbnail: rawNews.news_avatar, | ||
content: rawNews.news_description | ||
} | ||
} catch (error) { | ||
logErrorForMonitoring(error as any, 'fetch news detail fail') | ||
return {} as Article | ||
} | ||
}, | ||
}) | ||
|
||
return { | ||
data, | ||
isFetching | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.