From 52f2cccc11200b76e8d60080e9be7c2154fa009a Mon Sep 17 00:00:00 2001 From: Joel Varty Date: Fri, 18 Jun 2021 13:08:59 -0400 Subject: [PATCH] api and hero --- components/agility-modules/Hero.tsx | 4 +- components/ui/Hero/Hero.tsx | 11 +++-- pages/api/search-products.ts | 21 ++++++---- public/custom-fields.js | 62 +++++++++++++++++++---------- 4 files changed, 62 insertions(+), 36 deletions(-) diff --git a/components/agility-modules/Hero.tsx b/components/agility-modules/Hero.tsx index 6202ec24a..c4b33c9a3 100644 --- a/components/agility-modules/Hero.tsx +++ b/components/agility-modules/Hero.tsx @@ -16,8 +16,8 @@ const HeroModule:Module = ({ module: {fields }}) => { ) } diff --git a/components/ui/Hero/Hero.tsx b/components/ui/Hero/Hero.tsx index 58d13e5de..7e27f8c14 100644 --- a/components/ui/Hero/Hero.tsx +++ b/components/ui/Hero/Hero.tsx @@ -6,10 +6,13 @@ import Link from 'next/link' interface HeroProps { className?: string headline: string - description: string + description: string, + ctaUrl:string, + ctaText: string + } -const Hero: FC = ({ headline, description }) => { +const Hero: FC = ({ headline, description, ctaUrl, ctaText }) => { return (
@@ -17,9 +20,9 @@ const Hero: FC = ({ headline, description }) => {

{headline}

{description}

- + - Read it here + {ctaText} diff --git a/pages/api/search-products.ts b/pages/api/search-products.ts index 529e1b5f7..771dabd26 100644 --- a/pages/api/search-products.ts +++ b/pages/api/search-products.ts @@ -2,6 +2,7 @@ import { NextApiRequest, NextApiResponse } from "next" import commerce from '@lib/api/commerce' +import { truncate } from "fs/promises" export default async (req: NextApiRequest, res: NextApiResponse) => { @@ -45,14 +46,18 @@ export default async (req: NextApiRequest, res: NextApiResponse) => { }) .map(p => { - return { - name: p.name, - imageUrl: p.images[0].url, - price: p.price, - id: p.id, - description: p.description - } - }) + return { + name: p.name, + imageUrl: p.images[0].url, + price: p.price, + id: p.id, + description: p.description, + slug: p.path || p.slug + } + }).sort((a, b) => { + if (a.name > b.name) return 1 + return -1 + }) res.statusCode = 200 res.json(ret) diff --git a/public/custom-fields.js b/public/custom-fields.js index e3cf2b647..184a454af 100644 --- a/public/custom-fields.js +++ b/public/custom-fields.js @@ -220,8 +220,12 @@ var ChooseProductCustomField = function () { var htmlContent = `