From d17f8828dfa41dc72eb09c83cb6ebeac856a7968 Mon Sep 17 00:00:00 2001 From: cohenaj194 Date: Thu, 13 Jun 2024 18:55:16 -0400 Subject: [PATCH 1/2] add ffxiv blog --- app/routes/queries.item-data.$itemId.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/routes/queries.item-data.$itemId.tsx b/app/routes/queries.item-data.$itemId.tsx index fe0c1676..57874980 100644 --- a/app/routes/queries.item-data.$itemId.tsx +++ b/app/routes/queries.item-data.$itemId.tsx @@ -12,6 +12,8 @@ import type { HistoryResponse } from '~/requests/GetHistory' import GetHistory from '~/requests/GetHistory' import type { ListingResponseType } from '~/requests/GetListing' import GetListing from '~/requests/GetListing' +import type { BlogResponseType } from '~/requests/GetBlog' +import GetBlog from '~/requests/GetBlog' import { getUserSessionData } from '~/sessions' import { getItemNameById } from '~/utils/items' import HistoryResults from '~/components/FFXIVResults/item-history/Results' @@ -80,6 +82,7 @@ export const loader: LoaderFunction = async ({ params, request }) => { try { const historyResponse = await GetHistory(input) const listingResponse = await GetListing(input) + const blogResponse = await GetBlog({ itemId: parsedItemId }) if (!historyResponse.ok) { return { exception: historyResponse.statusText } @@ -89,9 +92,14 @@ export const loader: LoaderFunction = async ({ params, request }) => { return { exception: listingResponse.statusText } } + if (!blogResponse.ok) { + return { exception: blogResponse.statusText } + } + return json({ history: await historyResponse.json(), listing: await listingResponse.json(), + itemDescription: (await blogResponse.json()).itemDescription, itemName }) } catch (error) { @@ -181,6 +189,13 @@ const ItemPage = () => { +
+ + <> +
+ + +
) From bbeb14bac03701926fafa2e3a8bcce846b96e26e Mon Sep 17 00:00:00 2001 From: cohenaj194 Date: Thu, 13 Jun 2024 18:57:16 -0400 Subject: [PATCH 2/2] add new request page --- app/requests/GetBlog.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 app/requests/GetBlog.ts diff --git a/app/requests/GetBlog.ts b/app/requests/GetBlog.ts new file mode 100644 index 00000000..b0ded614 --- /dev/null +++ b/app/requests/GetBlog.ts @@ -0,0 +1,31 @@ +import { address, UserAgent } from '~/requests/client/config' + +export interface BlogResponse { + itemID: number + itemDescription: string +} + +export interface GetBlogProps { + itemId: number +} + +const GetBlog: ({ itemId }: GetBlogProps) => Promise = async ({ + itemId +}) => { + const requestBody = JSON.stringify({ + item_id: itemId + }) + + console.log('Request body:', requestBody) + + return fetch(`${address}/api/ffxiv/blog`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'User-Agent': UserAgent + }, + body: requestBody + }) +} + +export default GetBlog