From d6100324ed50aa650f27e86c0092458a07a3211a Mon Sep 17 00:00:00 2001 From: Guilherme da Silva Benevides Date: Thu, 7 Nov 2024 10:20:54 -0300 Subject: [PATCH] feat: update version - Update version of deno 1 to 2 - Update dependencies - Fix issue while using item itemToAnalyticsItem of deco vtex app --- .github/workflows/deco-deploy.yaml | 1 - components/footer/CopyrightRow.tsx | 96 ++++++++++++++-------------- deno.json | 28 +++++--- fresh.gen.ts | 2 +- sdk/cart/vtex/utils/cartFrom.ts | 4 +- sdk/cart/vtex/utils/useCartCustom.ts | 29 +++++++++ sections/Component.tsx | 4 +- static/tailwind.css | 3 - 8 files changed, 101 insertions(+), 66 deletions(-) create mode 100644 sdk/cart/vtex/utils/useCartCustom.ts diff --git a/.github/workflows/deco-deploy.yaml b/.github/workflows/deco-deploy.yaml index f9a360a..68c4490 100644 --- a/.github/workflows/deco-deploy.yaml +++ b/.github/workflows/deco-deploy.yaml @@ -1,4 +1,3 @@ - name: Deploy on: push: diff --git a/components/footer/CopyrightRow.tsx b/components/footer/CopyrightRow.tsx index 2664201..4bf635f 100644 --- a/components/footer/CopyrightRow.tsx +++ b/components/footer/CopyrightRow.tsx @@ -2,55 +2,55 @@ import Image from "apps/website/components/Image.tsx"; import { CardFlag, TecnologiesLogo } from "site/components/footer/types.ts"; interface Props { - copyright: string; - cardFlags: CardFlag[]; - tecnologiesLogo: TecnologiesLogo; + copyright: string; + cardFlags: CardFlag[]; + tecnologiesLogo: TecnologiesLogo; } export default function CopyrightRow(props: Props) { - const copyText = props.copyright.replace( - "{{year}}", - new Date().getFullYear().toString(), - ); - return ( -
-
-

- {copyText} -

- -
    - {props.cardFlags.map((flag) => ( -
  • - {`Logo -
  • - ))} -
-
+ const copyText = props.copyright.replace( + "{{year}}", + new Date().getFullYear().toString(), + ); + return ( +
+
+

+ {copyText} +

+ - ); +
    + {props.cardFlags.map((flag) => ( +
  • + {`Logo +
  • + ))} +
+
+
+ ); } diff --git a/deno.json b/deno.json index 945326f..830f06c 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "imports": { - "$fresh/": "https://deno.land/x/fresh@1.6.8/", + "$fresh/": "https://deno.land/x/fresh@1.7.3/", "preact": "npm:preact@10.23.1", "preact-render-to-string": "npm:preact-render-to-string@6.4.2", "@cliffy/prompt": "jsr:@cliffy/prompt@^1.0.0-rc.5", @@ -29,15 +29,15 @@ "@zaubrik/djwt": "jsr:@zaubrik/djwt@^3.0.2", "fast-json-patch": "npm:fast-json-patch@^3.1.1", "https://esm.sh/*preact-render-to-string@6.3.1": "npm:preact-render-to-string@6.4.2", - "@deco/deco": "jsr:@deco/deco@1.102.3", + "@deco/deco": "jsr:@deco/deco@1.107.0", "simple-git": "npm:simple-git@^3.25.0", "std/": "https://deno.land/std@0.190.0/", - "deco/": "https://cdn.jsdelivr.net/gh/deco-cx/deco@1.102.3/", - "apps/": "https://cdn.jsdelivr.net/gh/deco-cx/apps@0.59.16/", + "deco/": "https://cdn.jsdelivr.net/gh/deco-cx/deco@1.107.0/", + "apps/": "https://cdn.jsdelivr.net/gh/deco-cx/apps@0.63.0/", "@preact/signals": "https://esm.sh/*@preact/signals@1.2.2", "@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.5.1", "daisyui": "npm:daisyui@4.6.0", - "@deco/dev": "jsr:@deco/dev@1.102.0", + "@deco/dev": "jsr:@deco/dev@1.107.0", "site/": "./" }, "tasks": { @@ -55,10 +55,12 @@ "build": "deno run -A dev.ts build", "preview": "deno run -A main.ts", "generate-icons": "deno run -A --unstable static/generate-icons.ts", - "dev": "deno run -A --env --unstable --unstable-hmr dev.ts", + "dev": "deno run -A --env --unstable-kv --unstable-hmr dev.ts", "reload": "deno cache -r https://deco.cx/run" }, - "githooks": { "pre-commit": "check" }, + "githooks": { + "pre-commit": "check" + }, "exclude": [ "node_modules", "static/", @@ -68,9 +70,17 @@ ".deco" ], "lint": { - "rules": { "exclude": ["no-window"], "tags": ["fresh", "recommended"] } + "rules": { + "exclude": [ + "no-window" + ], + "tags": [ + "fresh", + "recommended" + ] + } }, - "nodeModulesDir": true, + "nodeModulesDir": "auto", "compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "preact", diff --git a/fresh.gen.ts b/fresh.gen.ts index e49e188..19d1568 100644 --- a/fresh.gen.ts +++ b/fresh.gen.ts @@ -5,7 +5,7 @@ import * as $_app from "./routes/_app.tsx"; import * as $MinicartFooter from "./islands/MinicartFooter.tsx"; import * as $Notify from "./islands/Notify.tsx"; -import { type Manifest } from "$fresh/server.ts"; +import type { Manifest } from "$fresh/server.ts"; const manifest = { routes: { diff --git a/sdk/cart/vtex/utils/cartFrom.ts b/sdk/cart/vtex/utils/cartFrom.ts index 4d3d372..6627332 100644 --- a/sdk/cart/vtex/utils/cartFrom.ts +++ b/sdk/cart/vtex/utils/cartFrom.ts @@ -1,4 +1,4 @@ -import { itemToAnalyticsItem } from "apps/vtex/hooks/useCart.ts"; +import { itemToAnalyticsItem } from "site/sdk/cart/vtex/utils/useCartCustom.ts"; import { Minicart } from "../../../../components/minicart/Minicart.tsx"; import { Cart } from "../types.ts"; import { SkuInformationData } from "./loadSizes.ts"; @@ -28,7 +28,7 @@ export const cartFrom = ( const detailUrl = new URL(item.detailUrl, url).href; const skuInfo = skuInformation[item.id]; return { - ...itemToAnalyticsItem({ ...item, detailUrl, coupon }, index), + ...itemToAnalyticsItem({ ...item, detailUrl, coupon }, index, url), image: item.imageUrl, ...skuInfo, listPrice: item.listPrice / 100, diff --git a/sdk/cart/vtex/utils/useCartCustom.ts b/sdk/cart/vtex/utils/useCartCustom.ts new file mode 100644 index 0000000..6919163 --- /dev/null +++ b/sdk/cart/vtex/utils/useCartCustom.ts @@ -0,0 +1,29 @@ +import { mapCategoriesToAnalyticsCategories } from "apps/commerce/utils/productToAnalyticsItem.ts"; +import { OrderForm, OrderFormItem } from "apps/vtex/utils/types.ts"; + +const mapItemCategoriesToAnalyticsCategories = ( + item: OrderFormItem, +): Record<`item_category${number | ""}`, string> => { + return mapCategoriesToAnalyticsCategories( + Object.values(item.productCategories), + ); +}; +export const itemToAnalyticsItem = ( + item: OrderForm["items"][number] & { coupon?: string }, + index: number, + url: string, +) => ({ + affiliation: item.seller, + item_id: item.id, + item_group_id: item.productId, + quantity: item.quantity, + coupon: item.coupon ?? "", + price: item.sellingPrice / 100, + index, + discount: Number(((item.listPrice - item.sellingPrice) / 100).toFixed(2)), + item_name: item.name ?? item.skuName ?? "", + item_variant: item.skuName, + item_brand: item.additionalInfo.brandName ?? "", + item_url: new URL(item.detailUrl, url).href, + ...(mapItemCategoriesToAnalyticsCategories(item)), +}); diff --git a/sections/Component.tsx b/sections/Component.tsx index 6cda691..3bc407e 100644 --- a/sections/Component.tsx +++ b/sections/Component.tsx @@ -1,9 +1,9 @@ // deno-lint-ignore-file no-explicit-any +import { type SectionProps } from "@deco/deco"; +import { useSection } from "@deco/deco/hooks"; import { Component, type ComponentType } from "preact"; import { toFileUrl } from "std/path/mod.ts"; import type { AppContext } from "../apps/site.ts"; -import { useSection } from "@deco/deco/hooks"; -import { type SectionProps } from "@deco/deco"; interface Props { component: string; props?: Record; diff --git a/static/tailwind.css b/static/tailwind.css index 13ed1be..ed7acb4 100644 --- a/static/tailwind.css +++ b/static/tailwind.css @@ -5256,9 +5256,6 @@ details.collapse summary::-webkit-details-marker { .uppercase { text-transform: uppercase; } -.lowercase { - text-transform: lowercase; -} .capitalize { text-transform: capitalize; }