Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a1014e3
fix: eslint for gift details view header return statement and return …
luisarevalo21 May 9, 2025
595c533
fix: using index for key, switch to reason
luisarevalo21 May 9, 2025
bf7d152
fix: adjust the handleFeedback in the JSDOCs so its using props
luisarevalo21 May 9, 2025
bd75e4f
fix removed props from handleFeedback
luisarevalo21 May 10, 2025
6dde88d
fix: added jsx to the react import
luisarevalo21 May 12, 2025
12d9ca8
fix: added type file for GiftDetails and passed it into the component
luisarevalo21 May 12, 2025
5ea8eba
merged develop
luisarevalo21 May 12, 2025
fc93f1a
reversed eslintignore
luisarevalo21 May 12, 2025
1f57ce0
fix: removed gift details view from eslint file
luisarevalo21 May 12, 2025
c4942d1
revered
luisarevalo21 May 13, 2025
e7a5d53
fixed added txt file
luisarevalo21 May 13, 2025
209b484
fixed: adjusted the handle amazon link, passing the string
luisarevalo21 May 13, 2025
9d11be5
fix: removed vscode folder
luisarevalo21 May 13, 2025
6f7037c
Merge branch 'develop' of https://github.com/LetsGetTechnical/elecret…
luisarevalo21 May 15, 2025
3920af7
Merge branch 'develop' into luisA/258-GiftDetailsView-ESLint
luisarevalo21 May 15, 2025
72a77e5
Merge branch 'develop' of https://github.com/LetsGetTechnical/elecret…
luisarevalo21 May 22, 2025
4385b60
fixed: merged main and added eslint to isValidUrl function;
luisarevalo21 May 22, 2025
5d6cacd
fix: re-added isValidURL outside the component function
luisarevalo21 May 28, 2025
cead520
:erge branch 'develop' of https://github.com/LetsGetTechnical/elecret…
luisarevalo21 May 28, 2025
d5bb9b4
Merge branch 'develop' into luisA/258-GiftDetailsView-ESLint
luisarevalo21 May 28, 2025
a4e62f3
Merge branch 'develop' of https://github.com/LetsGetTechnical/elecret…
luisarevalo21 Jun 26, 2025
1390a0b
resolved conflicts
luisarevalo21 Jun 27, 2025
9dc18e3
Merge branch 'develop' into luisA/258-GiftDetailsView-ESLint
shashilo Jun 27, 2025
3332e31
fix: fixed linting issue with the giftDetailsView
luisarevalo21 Jun 28, 2025
17814e4
Merge branch 'luisA/258-GiftDetailsView-ESLint' of https://github.com…
luisarevalo21 Jun 28, 2025
7498a5c
Merge branch 'develop' into luisA/258-GiftDetailsView-ESLint
shashilo Sep 11, 2025
4f1e5c2
Update components/GiftDetailsView/GiftDetailsView.tsx
shashilo Sep 11, 2025
90880ea
Merge branch 'develop' into luisA/258-GiftDetailsView-ESLint
shashilo Sep 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ components/Avatar/Avatar.tsx
components/Avatar/AvatarBody.tsx
components/Button/button.tsx
components/Calendar/calendar.tsx
components/GiftDetailsView/GiftDetailsView.tsx
components/GiftExchangeHeader/GiftExchangeHeader.tsx
components/GiftSuggestionCard/GiftSuggestionCard.tsx
components/GroupCard/GroupCard.tsx
components/ImageSelector/ImageSelector.tsx
Expand Down
36 changes: 28 additions & 8 deletions components/GiftDetailsView/GiftDetailsView.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Gridiron Survivor.
// Licensed under the MIT License.

import { Button } from '../Button/button';
import {
CardContent,
Expand All @@ -8,9 +11,14 @@ import {
} from '../Card/Card';
import { SquareArrowOutUpRight, ThumbsDown, Gift } from 'lucide-react';
import { IGiftSuggestion } from '@/app/types/giftSuggestion';
import { useState, useCallback } from 'react';
import { useState, useCallback, JSX } from 'react';

const isValidUrl = (urlString: string) => {
/**
* Helper function to validate urlStrings
* @param {string} urlString - search string to validate
* @returns {boolean} - returns if string was valid or not
*/
const isValidUrl = (urlString: string): boolean => {
try {
new URL(urlString);
return true;
Expand All @@ -19,20 +27,32 @@ const isValidUrl = (urlString: string) => {
}
};

/**
* A GiftDetailsView compoennt
* @param {object} props - The component props
* @param {IGiftSuggestion} props.gift - Gift suggestion being passed
* @param {() => void} props.handleFeedback - Callback function triggered when feedback is provided
* @returns {JSX.Element} - the rendered GiftDetailsView
*/
const GiftDetailsView = ({
gift,
handleFeedback,
}: {
gift: IGiftSuggestion;
handleFeedback: () => void;
}) => {
}): JSX.Element => {
const [imageError, setImageError] = useState(false);

const handleImageError = useCallback(() => {
setImageError(true);
}, []);

const handleAmazonLink = ({ searchTerm }: { searchTerm: string }) => {
/**
* Search Term details
* @param {string} searchTerm - search term being passed in to search amazon list
* @returns {string} - returns an encoded search string with the search term
*/
const handleAmazonLink = (searchTerm: string): string => {
const encodedSearch = encodeURIComponent(searchTerm).replace(/%20/g, '+');
return `https://www.amazon.com/s?k=${encodedSearch}`;
};
Expand Down Expand Up @@ -86,21 +106,21 @@ const GiftDetailsView = ({
</CardHeader>
<CardContent className="p-0 m-2 w-72 h-20 flex items-center bg-GiftSuggestionLightGreenBackground rounded-md">
<ul className="text-xs list-disc list-inside w-full text-giftSuggestionDarkGreen ml-2 flex flex-col gap-1">
{gift.matchReasons.map((reason, index) => (
<li key={index}>{reason}</li>
{gift.matchReasons.map((reason) => (
<li key={reason}>{reason}</li>
))}
</ul>
</CardContent>
<CardFooter className="flex flex-col">
<div className="flex justify-between w-full">
<a
href={handleAmazonLink({ searchTerm: gift.title })}
href={handleAmazonLink(gift.title)}
target="_blank"
rel="noopener noreferrer"
>
<Button
className="text-sm w-32 h-9 bg-primaryButtonYellow hover:bg-primaryButtonYellow70"
onClick={() => handleAmazonLink({ searchTerm: gift.title })}
onClick={() => handleAmazonLink(gift.title)}
>
<SquareArrowOutUpRight /> View
</Button>
Expand Down
9 changes: 9 additions & 0 deletions components/GiftDetailsView/IGiftDetailsViewProps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) Gridiron Survivor.
// Licensed under the MIT License.

import { IGiftSuggestion } from '@/app/types/giftSuggestion';

export interface IGiftDetailsViewProps {
gift: IGiftSuggestion;
handleFeedback: () => void;
}