Skip to content

Commit

Permalink
Merge pull request #1044 from hackclub/shop_temp_details
Browse files Browse the repository at this point in the history
Added shop details
  • Loading branch information
maxwofford authored Jan 12, 2025
2 parents 2e01ab3 + ba13684 commit 630d667
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/app/harbor/shipyard/ships.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export default function Ships({
</Button>

<Modal isOpen={shipModal} close={() => setShipModal(false)}>
<div className="p-4 max-h-96 overflow-y-auto">
<div className="p-4 max-h-[70vh] overflow-y-auto">
<h2 className="text-3xl font-bold text-center">
Confirm Shipping
</h2>
Expand Down
88 changes: 85 additions & 3 deletions src/app/harbor/shop/shop-item-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import {
CardTitle,
} from '@/components/ui/card'
import { Button } from '@/components/ui/button'
import { useMemo } from 'react'
import { useMemo, useState } from 'react'
import { cantAffordWords, purchaseWords, sample } from '../../../../lib/flavor'
import Icon from '@hackclub/icons'
import { transcript } from '../../../../lib/transcript'
import Modal from '@/components/ui/modal'
import Image from 'next/image'
const ActionArea = ({ item, filterIndex, affordable }) => {
const buyWord = useMemo(() => sample(purchaseWords), [item.id])
const getYourRacksUp = useMemo(() => sample(cantAffordWords), [item.id])
Expand Down Expand Up @@ -47,6 +49,8 @@ export const ShopItemComponent = ({
setFavouriteItems,
favouriteItems,
}) => {
let [detailsModal, setDetailsModal] = useState(false)

const cardHoverProps = {
whileHover: {
scale: 1.05,
Expand Down Expand Up @@ -89,9 +93,85 @@ export const ShopItemComponent = ({
})
}

const linkIndex = Number(filterIndex) - 1

return (
<motion.div {...cardHoverProps}>
<motion.div {...cardHoverProps} className="cursor-pointer">
<Modal isOpen={detailsModal} close={() => setDetailsModal(false)}>
<div className="flex flex-col max-h-[60vh] overflow-y-auto px-2 mb-5">
<h2 className="text-3xl">{item.name}</h2>
<h3
className="text-xl"
dangerouslySetInnerHTML={{ __html: item.subtitle }}
></h3>
<img
src={item.imageUrl}
alt={item.name}
className="max-w-sm mx-auto my-3"
/>

{item.description && (
<p
className="my-5"
dangerouslySetInnerHTML={{ __html: item.description }}
></p>
)}

<Image
src="/hr.svg"
className="w-2/3 mx-auto my-3"
alt=""
width={461}
height={11}
/>

{item.limited_qty && (
<i className="mt-3 text-amber-100">
This item is limited, buy it while you can!
</i>
)}

{item.fulfillment_description && (
<p
className="my-2 text-lg"
dangerouslySetInnerHTML={{ __html: item.fulfillment_description }}
></p>
)}

{item.links && linkIndex >= 0 && item.links[linkIndex] && (
<p>
We will most likely order it from{' '}
<a
className="underline"
target="_blank"
href={item.links[Number(filterIndex) - 1]}
>
this link
</a>
</p>
)}

{item.customs_likely && linkIndex !== 0 && (
<p className="font-bold italic text-xl">
Customs may apply outside of US!
</p>
)}
</div>

<Button
className="float-right mr-10"
onClick={() => setDetailsModal(false)}
>
Close
</Button>
</Modal>

<Card
onClick={(e) => {
if (e.target.tagName !== 'BUTTON' && e.target.tagName !== 'FORM') {
setDetailsModal(true)
}
}}
id={id}
className="h-full flex flex-col overflow-hidden shadow-lg transition-shadow duration-300 hover:shadow-xl"
>
Expand Down Expand Up @@ -133,7 +213,9 @@ export const ShopItemComponent = ({
<img
src={item.imageUrl}
alt={item.name}
onClick={() => {
onClick={(e) => {
e.stopPropagation()
setDetailsModal(false)
let interaction = transcript('item.base', {
name: item.name,
price: localPrice,
Expand Down
17 changes: 17 additions & 0 deletions src/app/harbor/shop/shop-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export interface ShopItem {
outOfStock: boolean
minimumHoursEstimated: number
maximumHoursEstimated: number
description: string | null
customs_likely: boolean | null
fulfillment_description: string | null
links: string[] | null[]
limited_qty: boolean | null
}

export async function getShop(): Promise<ShopItem[]> {
Expand Down Expand Up @@ -82,6 +87,18 @@ export async function getShop(): Promise<ShopItem[]> {
maximumHoursEstimated: Number(
record.get('maximum_hours_estimated'),
),
description: record.get('description') as string | null,
customs_likely: Boolean(record.get('customs_likely')) as boolean,
fulfillment_description: record.get('fulfillment_description') as
| string
| null,
links: [
record.get('third_party_link_us') as string,
record.get('third_party_link_eu') as string,
record.get('third_party_link_in') as string,
record.get('third_party_link_ca') as string,
],
limited_qty: Boolean(record.get('limited_qty')) as boolean,
})
})

Expand Down

0 comments on commit 630d667

Please sign in to comment.