Skip to content

Commit

Permalink
fix missed import paths
Browse files Browse the repository at this point in the history
  • Loading branch information
feledori committed Oct 18, 2024
1 parent 321094f commit e9b369d
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 37 deletions.
6 changes: 3 additions & 3 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { fonts } from 'app/fonts'
import cn from 'clsx'
import { StyleVariables } from 'libs/style-variables'
import { colors, themes } from 'styles/config.mjs'
import 'styles/global.css'
import { StyleVariables } from '~/libs/style-variables'
import { colors, themes } from '~/styles/config.mjs'
import '~/styles/global.css'

/** @type { import('@storybook/react').Preview } */
const preview = {
Expand Down
2 changes: 1 addition & 1 deletion components/animated-gradient/animated-gradient.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Canvas } from 'libs/webgl/components/canvas'
import { Canvas } from '~/libs/webgl/components/canvas'
import { AnimatedGradient } from '.'

// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
Expand Down
22 changes: 11 additions & 11 deletions libs/shopify/cart/actions.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
'use server'

import { revalidateTag } from 'next/cache'
import { cookies } from 'next/headers'
import {
addToCart,
createCart,
getCart,
removeFromCart,
updateCart,
} from 'libs/shopify'
import { TAGS } from 'libs/shopify/constants'
import { revalidateTag } from 'next/cache'
import { cookies } from 'next/headers'
} from '~/libs/shopify'
import { TAGS } from '~/libs/shopify/constants'

export async function removeItem(prevState, merchandiseId) {
let cartId = cookies().get('cartId')?.value
const cartId = cookies().get('cartId')?.value

if (!cartId) {
return 'Missing cart ID'
Expand All @@ -26,10 +26,10 @@ export async function removeItem(prevState, merchandiseId) {
}

const lineItem = cart.lines.find(
(line) => line.merchandise.id === merchandiseId,
(line) => line.merchandise.id === merchandiseId
)

if (lineItem && lineItem.id) {
if (lineItem?.id) {
await removeFromCart(cartId, [lineItem.id])
revalidateTag(TAGS.cart)
} else {
Expand Down Expand Up @@ -68,9 +68,9 @@ export async function addItem(prevState, { variantId, quantity = 1 }) {

export async function updateItemQuantity(
prevState,
payload = { merchandiseId: '', quantity: '' },
payload = { merchandiseId: '', quantity: '' }
) {
let cartId = cookies().get('cartId')?.value
const cartId = cookies().get('cartId')?.value

if (!cartId) {
return 'Missing cart ID'
Expand All @@ -86,7 +86,7 @@ export async function updateItemQuantity(
const { merchandiseId, quantity } = payload

const lineItem = cart.lines.find(
(line) => line.merchandise.id === merchandiseId,
(line) => line.merchandise.id === merchandiseId
)

await updateCart(cartId, [
Expand All @@ -103,7 +103,7 @@ export async function updateItemQuantity(
}

export async function fetchCart() {
let cartId = cookies().get('cartId')?.value
const cartId = cookies().get('cartId')?.value

let cart

Expand Down
2 changes: 1 addition & 1 deletion libs/shopify/cart/add-to-cart/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'

import cn from 'clsx'
import { addItem } from 'libs/shopify/cart/actions'
import { addItem } from '~/libs/shopify/cart/actions'
import { useCartContext } from '../cart-context'
import { useCartModal } from '../modal'
import s from './add-to-cart.module.css'
Expand Down
4 changes: 2 additions & 2 deletions libs/shopify/cart/modal/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use client'

import cn from 'clsx'
import { Image } from 'components/image'
import { Link } from 'components/link'
import { createContext, useContext, useState } from 'react'
import { Image } from '~/components/image'
import { Link } from '~/components/link'
import { removeItem, updateItemQuantity } from '../actions'
import { useCartContext } from '../cart-context'
import s from './modal.module.css'
Expand Down
22 changes: 9 additions & 13 deletions libs/shopify/cart/optimistic-utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isEmptyArray } from 'libs/utils'
import { isEmptyArray } from '~/libs/utils'

export function cartReconciler(state, action) {
const currentCart = state || createEmptyCart()
Expand Down Expand Up @@ -26,12 +26,8 @@ function createEmptyCart() {
}

const reconcilingActions = {
UPDATE_ITEM: function (state, action) {
return updateItem(state, action)
},
ADD_ITEM: function (state, action) {
return addItem(state, action)
},
UPDATE_ITEM: (state, action) => updateItem(state, action),
ADD_ITEM: (state, action) => addItem(state, action),
}

function updateItem(state, action) {
Expand All @@ -40,7 +36,7 @@ function updateItem(state, action) {
.map((item) =>
item.merchandise.id === merchandiseId
? updateCartItem(item, updateType)
: item,
: item
)
.filter(Boolean)

Expand All @@ -62,18 +58,18 @@ function updateItem(state, action) {
function addItem(state, action) {
const { variant, product, quantity } = action.payload
const existingItem = state.lines.find(
(item) => item.merchandise.id === variant.id,
(item) => item.merchandise.id === variant.id
)
const updatedItem = createOrUpdateCartItem(
existingItem,
variant,
product,
quantity,
quantity
)

const updatedLines = existingItem
? state.lines.map((item) =>
item.merchandise.id === variant.id ? updatedItem : item,
item.merchandise.id === variant.id ? updatedItem : item
)
: [...state.lines, updatedItem]

Expand All @@ -97,7 +93,7 @@ function updateCartItem(item, updateType) {
const singleItemAmount = Number(item.cost.totalAmount.amount) / item.quantity
const newTotalAmount = calculateItemCost(
newQuantity,
singleItemAmount.toString(),
singleItemAmount.toString()
)

return {
Expand Down Expand Up @@ -150,7 +146,7 @@ function updateCartTotals(lines) {
const totalQuantity = lines.reduce((sum, item) => sum + item.quantity, 0)
const totalAmount = lines.reduce(
(sum, item) => sum + Number(item.cost.totalAmount.amount),
0,
0
)
const currencyCode = lines[0]?.cost.totalAmount.currencyCode ?? 'USD'

Expand Down
2 changes: 1 addition & 1 deletion libs/shopify/customer/actions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use server'

import { shopifyFetch } from 'libs/shopify'
import { cookies } from 'next/headers'
import { shopifyFetch } from '~/libs/shopify'
import {
customerAccessTokenCreateMutation,
customerAccessTokenDeleteMutation,
Expand Down
10 changes: 5 additions & 5 deletions libs/shopify/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { revalidateTag } from 'next/cache'
import { headers } from 'next/headers'
import { NextResponse } from 'next/server'
import {
HIDDEN_PRODUCT_TAG,
SHOPIFY_GRAPHQL_API_ENDPOINT,
TAGS,
} from 'libs/shopify/constants'
import { revalidateTag } from 'next/cache'
import { headers } from 'next/headers'
import { NextResponse } from 'next/server'
} from '~/libs/shopify/constants'
import {
addToCartMutation,
createCartMutation,
Expand Down Expand Up @@ -277,7 +277,7 @@ export async function getCollections() {
// Filter out the `hidden` collections.
// Collections that start with `hidden-*` need to be hidden on the search page.
...reshapeCollections(shopifyCollections).filter(
(collection) => !collection.handle.startsWith('hidden'),
(collection) => !collection.handle.startsWith('hidden')
),
]

Expand Down

0 comments on commit e9b369d

Please sign in to comment.