Skip to content

Commit

Permalink
Update dependencies, fix filters, refactoring (#26)
Browse files Browse the repository at this point in the history
* Node v18, update minor dependencies

* Codemod pt1

* Removeu nrecognized type

* ...

* Fix imports

* Fix filtering features, improve UI

* Improve filters, image stuff

* Prepare for Remix v2

* use @tsconfig/remix

* Add missing type

---------

Co-authored-by: Santeri Elo <[email protected]>
  • Loading branch information
iffa and Santeri Elo authored Aug 1, 2023
1 parent f6083a3 commit 18ae650
Show file tree
Hide file tree
Showing 23 changed files with 15,235 additions and 1,812 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ jobs:
id: nvmrc

- name: Setup node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: "${{ steps.nvmrc.outputs.version }}"
cache: "npm"
node-version-file: ".nvmrc"

- name: Install dependencies
run: npm ci
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
v18.16.1
13 changes: 9 additions & 4 deletions app/components/NavBar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useTranslation } from "react-i18next";
import { Link } from "remix";
import { Link } from "@remix-run/react";
import { Trans, useTranslation } from "react-i18next";

export const NavBar = (): JSX.Element => {
const { t } = useTranslation("common");
Expand All @@ -9,8 +9,13 @@ export const NavBar = (): JSX.Element => {
<div className="container mx-auto p-4 flex flex-row justify-between items-center align-middle">
<Link to="/" className="text-xl text-gray-900 font-semibold">
{t("title")}
<span className="text-gray-700 font-normal text-sm">
{t("version")}
<span className="text-gray-700 font-normal text-base">
<Trans
i18nKey="common:version"
components={{
span: <span className="font-semibold text-pink-500" />,
}}
/>
</span>
</Link>
</div>
Expand Down
88 changes: 46 additions & 42 deletions app/components/product/ProductDetailsCard.tsx
Original file line number Diff line number Diff line change
@@ -1,56 +1,59 @@
import { Trans, useTranslation } from "react-i18next";
import { getFormattedNumber, getFormattedPrice } from "~/utils/number-utils";
import { getStoresAmountForProduct } from "~/utils/product-utils";
import { Product } from "../../lib/model/product.model";
import {
getFormattedNumber,
getFormattedPrice,
} from "../../utils/number-utils";
import { getStoresAmountForProduct } from "../../utils/product-utils";
import ProductPlatformPill from "./ProductPlatformPill";

function ProductDetailsCard({ product }: { product: Product }): JSX.Element {
export function ProductDetailsCard({
product,
}: {
product: Product;
}): JSX.Element {
const { t } = useTranslation();
const price =
product.bestOffer?.bestVoucher?.priceWithVoucher ||
product.bestOffer?.price;
const currency = product.bestOffer?.currency;

return (
<div className="w-full bg-white rounded shadow">
<div className="p-4">
<h3
className="text-xl leading-6 font-medium text-gray-900"
data-cy="title"
>
{product.name}
</h3>
<p className="mt-1 max-w-2xl text-sm text-gray-500">
<Trans
i18nKey="product:developedBy"
values={{ developer: product.developer }}
components={{ span: <span className="font-semibold" /> }}
/>
</p>
<p className="mt-1 max-w-2xl text-sm text-gray-500">
<Trans
i18nKey="product:publishedBy"
values={{ publisher: product.publisher }}
components={{ span: <span className="font-semibold" /> }}
/>
</p>

<div className="flex flex-row space-x-2 mt-4 overflow-x-auto">
{Object.entries(product.availablePlatforms).map(([key, value]) => {
return (
<ProductPlatformPill
key={key}
platform={value}
isActive={value.gameId === product.id}
/>
);
})}
<div className="bg-white rounded shadow w-full overflow-hidden">
<div className="flex flex-row">
{/** TODO: Use more optimized component instead of native <img> */}
<img src={product.coverImageUrl || "/img/placeholder_cover.svg"}></img>
<div className="p-4">
<h3
className="text-xl leading-6 font-medium text-gray-900"
data-cy="title"
>
{product.name}
</h3>
<p className="mt-1 max-w-2xl text-sm text-gray-500">
<Trans
i18nKey="product:developedBy"
values={{ developer: product.developer }}
components={{ span: <span className="font-semibold" /> }}
/>
</p>
<p className="mt-1 max-w-2xl text-sm text-gray-500">
<Trans
i18nKey="product:publishedBy"
values={{ publisher: product.publisher }}
components={{ span: <span className="font-semibold" /> }}
/>
</p>
<div className="flex flex-row space-x-2 mt-4 overflow-x-auto">
{Object.entries(product.availablePlatforms).map(([key, value]) => {
return (
<ProductPlatformPill
key={key}
platform={value}
isActive={value.gameId === product.id}
/>
);
})}
</div>
</div>
</div>

<div className="border-t border-gray-200">
<dl>
<div className="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
Expand Down Expand Up @@ -82,6 +85,9 @@ function ProductDetailsCard({ product }: { product: Product }): JSX.Element {
/>
)}
</a>
<p className="mt-2 text-gray-400">
<Trans i18nKey="product:bestOfferNote" />
</p>
</dd>
</div>
<div className="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
Expand Down Expand Up @@ -123,5 +129,3 @@ function ProductDetailsCard({ product }: { product: Product }): JSX.Element {
</div>
);
}

export default ProductDetailsCard;
2 changes: 1 addition & 1 deletion app/components/product/ProductOfferTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function ProductOfferTable({ product }: { product: Product }): JSX.Element {
</th>
<th
scope="col"
className="hidden md:visible px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
className="md:visible px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider"
>
{t("product:store")}
</th>
Expand Down
29 changes: 27 additions & 2 deletions app/components/product/ProductOfferTableFilters.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
import { Form, useSearchParams } from "@remix-run/react";
import { useTranslation } from "react-i18next";
import { Form, useSearchParams } from "remix";
import { Store } from "~/lib/model/store.model";
import { Edition } from "../../lib/model/edition.model";
import { Region } from "../../lib/model/region.model";
import ProductFilterCheckbox from "./ProductFilterCheckbox";

function ProductOfferTableFilters({
launchers,
editions,
stores,
}: {
launchers: Region[];
editions: Edition[];
stores: Store[];
}): JSX.Element {
const { t } = useTranslation();

const [searchParams] = useSearchParams();
const hasSelectedEditions = searchParams.has("edition");
const hasSelectedLaunchers = searchParams.has("launcher");
const hasSelectedStores = searchParams.has("store");
const selectedEditions = searchParams.getAll("edition");
const selectedLaunchers = searchParams.getAll("launcher");
const selectedStores = searchParams.getAll("store");

return (
<Form reloadDocument className="px-4 mb-8">
Expand All @@ -30,7 +35,7 @@ function ProductOfferTableFilters({
{launchers.map((launcher) => (
<ProductFilterCheckbox
key={launcher.id}
title={launcher.name}
title={launcher.id}
name="launcher"
value={launcher.id}
checked={
Expand Down Expand Up @@ -61,6 +66,26 @@ function ProductOfferTableFilters({
))}
</div>
</div>

<div className="flex flex-col">
<h4 className="text-lg text-gray-900 font-semibold mb-2">
{t("product:stores")}
</h4>
<div className="grid grid-flow-row-dense grid-cols-1 md:grid-cols-3 gap-x-4 gap-y-0.5">
{stores.map((store) => (
<ProductFilterCheckbox
key={store.id}
title={store.name}
name="store"
value={store.id.toString()}
checked={
!hasSelectedStores ||
!!selectedStores.find((x) => x === store.id.toString())
}
></ProductFilterCheckbox>
))}
</div>
</div>
</div>
<button
type="submit"
Expand Down
8 changes: 3 additions & 5 deletions app/components/product/ProductOfferTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,18 @@ function ProductOfferTableRow({ offer }: { offer: Offer }): JSX.Element {
<img
className="h-10 w-10"
src={getLauncherIcon(region.id)}
alt={region.name}
alt={region.id}
width={40}
height={40}
></img>
</div>
<div className="ml-4">
<div className="text-sm font-medium text-gray-900">
{region.name}
</div>
<div className="text-sm font-medium text-gray-900">{region.id}</div>
<div className="text-sm text-gray-500">{edition.name}</div>
</div>
</div>
</td>
<td className="hidden md:visible px-4 py-4 whitespace-nowrap text-sm text-gray-900">
<td className="md:visible px-4 py-4 whitespace-nowrap text-right text-sm text-gray-900">
<div>{store.name}</div>
</td>
<td className="px-4 py-4 whitespace-nowrap text-right">
Expand Down
2 changes: 1 addition & 1 deletion app/components/product/ProductPlatformPill.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link } from "remix";
import { Link } from "@remix-run/react";
import { AvailablePlatform } from "../../lib/model/product.model";

function ProductPlatformPill({
Expand Down
2 changes: 1 addition & 1 deletion app/components/search/SearchResult.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link } from "remix";
import { Link } from "@remix-run/react";
import { Product } from "../../lib/model/product.model";
import { getFormattedPrice } from "../../utils/number-utils";

Expand Down
2 changes: 1 addition & 1 deletion app/entry.client.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import i18next from "i18next";
import { hydrate } from "react-dom";
import { initReactI18next } from "react-i18next";
import { RemixBrowser } from "remix";
import { RemixBrowser } from "@remix-run/react";
import i18nOptions from "./i18n-options";

if (!i18next.isInitialized) {
Expand Down
4 changes: 2 additions & 2 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { renderToString } from "react-dom/server";
import { RemixServer } from "remix";
import type { EntryContext } from "remix";
import { type EntryContext } from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
import i18next from "i18next";
import { initReactI18next } from "react-i18next";
import i18nOptions from "./i18n-options";
Expand Down
Loading

1 comment on commit 18ae650

@vercel
Copy link

@vercel vercel bot commented on 18ae650 Aug 1, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

akm-remix – ./

akm-remix.vercel.app
akm-remix-git-main-iffa.vercel.app
akm.iffa.dev
akm-remix-iffa.vercel.app

Please sign in to comment.