Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ffxiv blog #440

Merged
merged 2 commits into from
Jun 13, 2024
Merged

add ffxiv blog #440

merged 2 commits into from
Jun 13, 2024

Conversation

cohenaj194
Copy link
Contributor

@cohenaj194 cohenaj194 commented Jun 13, 2024

closes: #434

Summary by CodeRabbit

  • New Features
    • Introduced a new API integration to fetch and display blog data related to items.
    • Added a description field for items in the user interface.

Copy link
Contributor

coderabbitai bot commented Jun 13, 2024

Walkthrough

The changes introduce a new function to fetch blog data related to an item and incorporate this data into both the loader function and UI. This enhancement enriches the existing item detail page by displaying item descriptions retrieved from a blog API.

Changes

Files Change Summary
app/routes/queries.item-data.$itemId.tsx Added an API call to fetch blog data, incorporated blog response in the loader function, and displayed item description in the UI.
app/requests/GetBlog.ts Introduced functionality for making a POST request to fetch a blog item from an API, defined interfaces for the blog response, and exported the GetBlog function.

Sequence Diagram(s)

sequenceDiagram
    Participant Client
    Participant ItemPage
    Participant Loader
    Participant GetBlog
    Participant BlogAPI

    Client->>ItemPage: Request Item Page
    ItemPage->>Loader: Call Loader
    Loader->>GetBlog: GetBlog({ itemId })
    GetBlog->>BlogAPI: POST /api/getBlog
    BlogAPI-->>GetBlog: BlogResponse
    GetBlog-->>Loader: BlogResponse
    Loader-->>ItemPage: BlogResponse
    ItemPage-->>Client: Render Item Description
Loading

Assessment against linked issues

Objective Addressed Explanation
Add a new blog page API (#434)
Display blog data in the UI (#434)
Include item description in the JSON response (#434)

Poem

In fields where data roams so free,
A blog now shares its tale with thee.
With item lore both rich and bright,
Our code now brings this text to light.
For bards and coders intertwined,
This change reflects a thoughtful mind. 😊


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

cloudflare-workers-and-pages bot commented Jun 13, 2024

Deploying saddlebag-with-pockets with  Cloudflare Pages  Cloudflare Pages

Latest commit: bbeb14b
Status: ✅  Deploy successful!
Preview URL: https://b6017f04.saddlebag-with-pockets.pages.dev
Branch Preview URL: https://ffxiv-items-blog.saddlebag-with-pockets.pages.dev

View logs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Outside diff range and nitpick comments (3)
app/routes/queries.item-data.$itemId.tsx (3)

Line range hint 63-63: Replace isNaN with Number.isNaN for safer type checking.

- if (isNaN(parsedItemId)) return { exception: 'Invalid item' }
+ if (Number.isNaN(parsedItemId)) return { exception: 'Invalid item' }

Line range hint 27-28: Replace the use of {} in type definitions with more specific types or unknown if the exact type is not determinable.

- type ItemPageData =
-   | {
-       history?: HistoryResponse | {}
-       listing?: ListingResponseType | {}
-       itemName: string
-     }
-   | { exception: string }
+ type ItemPageData =
+   | {
+       history?: HistoryResponse | unknown
+       listing?: ListingResponseType | unknown
+       itemName: string
+     }
+   | { exception: string }

Line range hint 108-108: Omit the unnecessary else clause to simplify control flow.

- } else return { exception: 'Error finding data' }
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bbc832b and d17f882.

Files selected for processing (1)
  • app/routes/queries.item-data.$itemId.tsx (4 hunks)
Additional context used
Learnings (1)
Common learnings
User: cohenaj194
PR: ff14-advanced-market-search/saddlebag-with-pockets#0
File: :0-0
Timestamp: 2024-06-09T21:34:49.875Z
Learning: User: cohenaj194 prefers detailed, actionable responses that directly address the code issues with specific solutions and examples.
Biome
app/routes/queries.item-data.$itemId.tsx

[error] 108-108: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.


[error] 27-27: Don't use '{}' as a type. (lint/complexity/noBannedTypes)

Prefer explicitly define the object shape. '{}' means "any non-nullable value".


[error] 28-28: Don't use '{}' as a type. (lint/complexity/noBannedTypes)

Prefer explicitly define the object shape. '{}' means "any non-nullable value".


[error] 63-63: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead. (lint/suspicious/noGlobalIsNan)

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.


[error] 195-195: Avoid passing content using the dangerouslySetInnerHTML prop. (lint/security/noDangerouslySetInnerHtml)

Setting content using code can expose users to cross-site scripting (XSS) attacks

Additional comments not posted (2)
app/routes/queries.item-data.$itemId.tsx (2)

15-16: Imports for BlogResponseType and GetBlog have been correctly added as part of the new feature implementation.


Line range hint 85-102: The addition of the blogResponse handling in the loader function is appropriate for fetching blog data. However, ensure proper error handling and response validation.

<Section>
<ContentContainer>
<>
<div dangerouslySetInnerHTML={{ __html: data.itemDescription }} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider sanitizing or ensuring the safety of data.itemDescription before using dangerouslySetInnerHTML to prevent XSS attacks.

- <div dangerouslySetInnerHTML={{ __html: data.itemDescription }} />
+ <div>{data.itemDescription}</div>

Committable suggestion was skipped due to low confidence.

Tools
Biome

[error] 195-195: Avoid passing content using the dangerouslySetInnerHTML prop. (lint/security/noDangerouslySetInnerHtml)

Setting content using code can expose users to cross-site scripting (XSS) attacks

@cohenaj194 cohenaj194 merged commit cd439e9 into master Jun 13, 2024
4 checks passed
@cohenaj194 cohenaj194 deleted the ffxiv-items-blog branch June 13, 2024 23:02
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Outside diff range and nitpick comments (1)
app/requests/GetBlog.ts (1)

1-1: Ensure consistent import paths across the project.

The import path '~/requests/client/config' should follow the project's conventions. If other files use relative paths or a different base, consider aligning this for consistency.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d17f882 and bbeb14b.

Files selected for processing (1)
  • app/requests/GetBlog.ts (1 hunks)
Additional context used
Learnings (1)
Common learnings
User: cohenaj194
PR: ff14-advanced-market-search/saddlebag-with-pockets#0
File: :0-0
Timestamp: 2024-06-09T21:34:49.875Z
Learning: User: cohenaj194 prefers detailed, actionable responses that directly address the code issues with specific solutions and examples.
Additional comments not posted (2)
app/requests/GetBlog.ts (2)

3-10: Well-defined interfaces for the blog response and props.

The interfaces BlogResponse and GetBlogProps are clearly defined and align with the requirements specified in the PR.


21-28: Review the API endpoint and ensure security headers are included.

Ensure the API endpoint ${address}/api/ffxiv/blog is correct and consistent with other endpoints in the project. Also, verify that appropriate security headers, such as CORS and authentication tokens, are included if required by the project's security policy.

item_id: itemId
})

console.log('Request body:', requestBody)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing or replacing console logs before deployment.

Production code should not contain console logs as they can lead to unintentional data leakage and are not useful for end-users. Consider replacing it with a more robust logging mechanism if needed for debugging.

Comment on lines +12 to +29
const GetBlog: ({ itemId }: GetBlogProps) => Promise<Response> = 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
})
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check consistency in property naming and validate error handling.

-    item_id: itemId
+    itemId: itemId

The property name item_id in the request body at line 16 should match the naming convention used elsewhere in the project. If camelCase is standard, use itemId instead of item_id.

Also, consider adding error handling for the fetch operation to manage network errors or non-200 responses gracefully. This could improve the robustness of the API interaction.

Committable suggestion was skipped due to low confidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FFXIV item blog
1 participant