From c6530d3ded7a201a2ddcf143e0c41bf0f0db1e67 Mon Sep 17 00:00:00 2001 From: tedraykov Date: Tue, 9 Jul 2024 11:40:14 +0300 Subject: [PATCH] handle missing shipping costs and black styling issue --- app/account/(orderId)/orders/[id]/page.tsx | 3 +- components/engine-sizes/index.tsx | 2 +- components/home-page/manufacturers.tsx | 2 +- components/orders/actions.tsx | 68 +++++-------------- components/orders/core-return-modal.tsx | 7 +- .../orders/order-confirmation-modal.tsx | 8 +-- components/orders/order-confirmation-pdf.tsx | 6 +- components/orders/order-summary.tsx | 6 +- components/page/mini-icon-block.tsx | 8 ++- components/page/rich-text-display.tsx | 2 +- components/page/text-block.tsx | 2 +- components/plp/default-content.tsx | 2 +- components/plp/dynamic-content.tsx | 2 +- components/plp/tabs.tsx | 2 +- components/transmission-codes/index.tsx | 2 +- components/ui/heading.tsx | 2 +- lib/shopify/index.ts | 11 +-- lib/shopify/types.ts | 2 +- lib/styles.ts | 9 --- 19 files changed, 53 insertions(+), 93 deletions(-) diff --git a/app/account/(orderId)/orders/[id]/page.tsx b/app/account/(orderId)/orders/[id]/page.tsx index 59241fcae..1d960c65b 100644 --- a/app/account/(orderId)/orders/[id]/page.tsx +++ b/app/account/(orderId)/orders/[id]/page.tsx @@ -15,7 +15,6 @@ import Image from 'next/image'; import Link from 'next/link'; import ActivateWarranty from 'components/orders/activate-warranty'; import OrderStatuses from 'components/orders/order-statuses'; -import Divider from 'components/divider'; import { CoreReturn } from 'components/orders/core-return'; function Unfulfilled({ order }: { order: Order }) { @@ -178,7 +177,7 @@ function OrderDetails({ order }: { order: Order }) {
- {order.shippingMethod!.name} + {order.shippingMethod ? order.shippingMethod.name : 'N/A'}
diff --git a/components/engine-sizes/index.tsx b/components/engine-sizes/index.tsx index ba833c1b9..e66b3e541 100644 --- a/components/engine-sizes/index.tsx +++ b/components/engine-sizes/index.tsx @@ -38,7 +38,7 @@ const EngineSizes = async ({ collection }: { collection: Collection }) => { return (
-

+

Browse Engines By Engine Sizes

diff --git a/components/home-page/manufacturers.tsx b/components/home-page/manufacturers.tsx index 23b93f4ab..b42ce5b79 100644 --- a/components/home-page/manufacturers.tsx +++ b/components/home-page/manufacturers.tsx @@ -17,7 +17,7 @@ const Manufacturers = async ({ return (
-

{`Browse ${title[variant]} By Manufacturer`}

+

{`Browse ${title[variant]} By Manufacturer`}

); diff --git a/components/orders/actions.tsx b/components/orders/actions.tsx index a7773bcf1..289649ea0 100644 --- a/components/orders/actions.tsx +++ b/components/orders/actions.tsx @@ -165,59 +165,23 @@ export const confirmOrder = async ({ order, content, formData }: ConfirmOrderOpt } }; -export async function returnCore() { - // const rawFormData = [ - // getMetafieldValue( - // 'coreReturnZip', - // { - // key: '', - // value: formData.get('name') as string | null, - // type: 'file_reference' - // }, - // order - // ), - // getMetafieldValue( - // 'warrantyActivationInstallation', - // { - // key: 'warranty_activation_installation', - // value: installationFileId, - // type: 'file_reference' - // }, - // order - // ), - // getMetafieldValue( - // 'warrantyActivationSelfInstall', - // { - // key: 'warranty_activation_self_install', - // value: formData.get('warranty_activation_self_install') === 'on' ? 'true' : 'false', - // type: 'boolean' - // }, - // order - // ), - // getMetafieldValue( - // 'warrantyActivationMileage', - // { - // key: 'warranty_activation_mileage', - // value: formData.get('warranty_activation_mileage') as string | null, - // type: 'number_integer' - // }, - // order - // ), - // getMetafieldValue( - // 'warrantyActivationVIN', - // { - // key: 'warranty_activation_vin', - // value: formData.get('warranty_activation_vin') as string | null, - // type: 'single_line_text_field' - // }, - // order - // ) - // ]; +export async function returnCore(order: Order, formData: FormData) { + const rawFormData = [ + getMetafieldValue( + 'coreReturnZip', + { + key: '', + value: formData.get('name') as string | null, + type: 'file_reference' + }, + order + ) + ]; try { - // await updateOrderMetafields({ - // orderId: order.id, - // metafields: rawFormData - // }); + await updateOrderMetafields({ + orderId: order.id, + metafields: rawFormData + }); revalidateTag(TAGS.orderMetafields); } catch (error) { diff --git a/components/orders/core-return-modal.tsx b/components/orders/core-return-modal.tsx index c65aa1176..81a496b35 100644 --- a/components/orders/core-return-modal.tsx +++ b/components/orders/core-return-modal.tsx @@ -3,7 +3,7 @@ import { Order } from 'lib/shopify/types'; import { Button, Heading, Input } from 'components/ui'; import StatesCombobox from 'components/states-combobox'; import { useTransition } from 'react'; -// import { returnCore } from './actions'; +import { returnCore } from './actions'; export function CoreReturnModal({ isOpen, @@ -18,8 +18,7 @@ export function CoreReturnModal({ async function submitCoreReturn(formData: FormData) { startTransition(async () => { - // returnCore(order, formData); - console.log(formData); + returnCore(order, formData); }); } @@ -27,7 +26,7 @@ export function CoreReturnModal({
diff --git a/components/orders/order-confirmation-modal.tsx b/components/orders/order-confirmation-modal.tsx index b94d9d48b..8afcf219e 100644 --- a/components/orders/order-confirmation-modal.tsx +++ b/components/orders/order-confirmation-modal.tsx @@ -121,11 +121,11 @@ function OrderConfirmationDetails({
Shipping - {order.shippingMethod.price.amount !== '0.0' ? ( + {order.shippingMethod && order.shippingMethod.price.amount !== '0.0' ? ( ) : ( Free @@ -228,7 +228,7 @@ export default function OrderConfirmationModal({
diff --git a/components/orders/order-confirmation-pdf.tsx b/components/orders/order-confirmation-pdf.tsx index bc834a259..901cd31e4 100644 --- a/components/orders/order-confirmation-pdf.tsx +++ b/components/orders/order-confirmation-pdf.tsx @@ -216,8 +216,10 @@ export default function OrderConfirmationPdf({ Shipping
Shipping - {order.shippingMethod?.price.amount !== '0.0' ? ( + {order.shippingMethod && order.shippingMethod.price.amount !== '0.0' ? ( ) : ( Free diff --git a/components/page/mini-icon-block.tsx b/components/page/mini-icon-block.tsx index 6e1cdfaab..878b90ff1 100644 --- a/components/page/mini-icon-block.tsx +++ b/components/page/mini-icon-block.tsx @@ -23,12 +23,14 @@ const MiniIconBlock = async ({ block }: { block: Metaobject }) => { {content.title && content.content && (
{content.title && ( -
{content.title}
+
{content.title}
+ )} + {content.content && ( +

{content.content}

)} - {content.content &&

{content.content}

}
)} - {content.title &&
{content.title}
} + {content.title &&
{content.title}
}
))}
diff --git a/components/page/rich-text-display.tsx b/components/page/rich-text-display.tsx index 4ec53cdcc..3b79b197a 100644 --- a/components/page/rich-text-display.tsx +++ b/components/page/rich-text-display.tsx @@ -82,7 +82,7 @@ const RichTextBlock = ({ block, className }: { block: Content; className?: strin } return ( -

+

{block.children.map((child, index) => ( ))} diff --git a/components/page/text-block.tsx b/components/page/text-block.tsx index 4d511214b..b66508ff8 100644 --- a/components/page/text-block.tsx +++ b/components/page/text-block.tsx @@ -8,7 +8,7 @@ const TextBlock = ({ block }: { block: Metaobject }) => {

{block.title && ( -

{block.title}

+

{block.title}

)} diff --git a/components/plp/default-content.tsx b/components/plp/default-content.tsx index da1032295..e1da6933a 100644 --- a/components/plp/default-content.tsx +++ b/components/plp/default-content.tsx @@ -17,7 +17,7 @@ const DefaultContent = async () => { return (
-

{title}

+

{title}

}> diff --git a/components/plp/dynamic-content.tsx b/components/plp/dynamic-content.tsx index 92cf80b66..60b7088f7 100644 --- a/components/plp/dynamic-content.tsx +++ b/components/plp/dynamic-content.tsx @@ -9,7 +9,7 @@ const DynamicContent = ({ content }: { content: Metaobject }) => { return (
-

+

{content.title}

}> diff --git a/components/plp/tabs.tsx b/components/plp/tabs.tsx index 59585f715..f641a94a5 100644 --- a/components/plp/tabs.tsx +++ b/components/plp/tabs.tsx @@ -13,7 +13,7 @@ const Tabs = ({ fields }: { fields: { [key: string]: string } }) => { {keys.map((key) => ( {startCase(key)} diff --git a/components/transmission-codes/index.tsx b/components/transmission-codes/index.tsx index 9f0014d7f..74ec4deee 100644 --- a/components/transmission-codes/index.tsx +++ b/components/transmission-codes/index.tsx @@ -40,7 +40,7 @@ const TransmissionCode = async ({ collection }: { collection: Collection }) => { return (
-

+

Browse By Transmission Code

diff --git a/components/ui/heading.tsx b/components/ui/heading.tsx index a3fbde268..aebc21cda 100644 --- a/components/ui/heading.tsx +++ b/components/ui/heading.tsx @@ -26,6 +26,6 @@ export interface HeadingProps extends VariantProps { } export default function Heading({ children, className, size, as }: HeadingProps) { - const Component = as || 'h2'; + const Component = as || 'span'; return {children}; } diff --git a/lib/shopify/index.ts b/lib/shopify/index.ts index 000146dd7..c3f049e8f 100644 --- a/lib/shopify/index.ts +++ b/lib/shopify/index.ts @@ -643,10 +643,6 @@ function reshapeOrder(shopifyOrder: ShopifyOrder): Order { totalTax: reshapeMoney(shopifyOrder.totalTax), totalPrice: reshapeMoney(shopifyOrder.totalPrice), createdAt: shopifyOrder.createdAt, - shippingMethod: { - name: shopifyOrder.shippingLine?.title, - price: reshapeMoney(shopifyOrder.shippingLine.originalPrice)! - }, warrantyActivationDeadline: shopifyOrder.warrantyActivationDeadline, warrantyStatus: shopifyOrder.warrantyStatus, warrantyActivationInstallation: shopifyOrder.warrantyActivationInstallation, @@ -667,6 +663,13 @@ function reshapeOrder(shopifyOrder: ShopifyOrder): Order { coreReturnDescription: shopifyOrder.coreReturnDescription }; + if (shopifyOrder.shippingLine) { + order.shippingMethod = { + name: shopifyOrder.shippingLine.title, + price: reshapeMoney(shopifyOrder.shippingLine.originalPrice) + }; + } + if (shopifyOrder.customer) { order.customer = reshapeCustomer(shopifyOrder.customer); } diff --git a/lib/shopify/types.ts b/lib/shopify/types.ts index b8b9c7a83..c259cd462 100644 --- a/lib/shopify/types.ts +++ b/lib/shopify/types.ts @@ -163,7 +163,7 @@ export type Order = { totalShipping: Money; totalTax: Money; totalPrice: Money; - shippingMethod: { + shippingMethod?: { name: string; price: Money; }; diff --git a/lib/styles.ts b/lib/styles.ts index 09ec76ab1..d24035282 100644 --- a/lib/styles.ts +++ b/lib/styles.ts @@ -18,9 +18,6 @@ export const carPartPlanetColor = { 200: '#666C89', 500: '#2D3A7B', 600: '#111C55' - }, - black: { - 700: '#1A1A25' } }; @@ -44,9 +41,6 @@ export const remanTransmissionColor = { 200: '#666C89', 500: '#2D3A7B', 600: '#111C55' - }, - black: { - 700: '#1A1A25' } }; @@ -70,8 +64,5 @@ export const transmissionLocatorColor = { 200: '#666C89', 500: '#2D3A7B', 600: '#111C55' - }, - black: { - 700: '#1A1A25' } };