Skip to content

Commit

Permalink
Merge pull request #82 from Nosto/tagging-removal
Browse files Browse the repository at this point in the history
Remove tagging and align API types
  • Loading branch information
timowestnosto authored Jun 19, 2024
2 parents 00e092b + 7a3c29d commit 6f27ad9
Show file tree
Hide file tree
Showing 13 changed files with 808 additions and 178 deletions.
9 changes: 1 addition & 8 deletions src/components/Nosto404.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,5 @@ export default function Nosto404(props: { placements?: string[] }) {
},
[recommendationComponent, pageTypeUpdated]
)

return (
<>
<div className="nosto_page_type" style={{ display: "none" }}>
notfound
</div>
</>
)
return null
}
12 changes: 1 addition & 11 deletions src/components/NostoCategory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,5 @@ export default function NostoCategory(props: { category: string; placements?: st
},
[category, recommendationComponent, pageTypeUpdated]
)

return (
<>
<div className="nosto_page_type" style={{ display: "none" }}>
category
</div>
<div className="nosto_category" style={{ display: "none" }}>
{category}
</div>
</>
)
return null
}
10 changes: 1 addition & 9 deletions src/components/NostoCheckout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { useNostoApi } from "../utils/hooks"
*
* @group Components
*/

export default function NostoCheckout(props: { placements?: string[] }) {
const { recommendationComponent, useRenderCampaigns } = useNostoContext()

Expand All @@ -36,12 +35,5 @@ export default function NostoCheckout(props: { placements?: string[] }) {
},
[recommendationComponent, pageTypeUpdated]
)

return (
<>
<div className="nosto_page_type" style={{ display: "none" }}>
cart
</div>
</>
)
return null
}
9 changes: 1 addition & 8 deletions src/components/NostoHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,5 @@ export default function NostoHome(props: { placements?: string[] }) {
},
[recommendationComponent, pageTypeUpdated]
)

return (
<>
<div className="nosto_page_type" style={{ display: "none" }}>
front
</div>
</>
)
return null
}
16 changes: 3 additions & 13 deletions src/components/NostoOrder.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Purchase } from "../types"
import { Order } from "../types"
import { useNostoContext } from "./context"
import { snakeize } from "../utils/snakeize"
import { useNostoApi } from "../utils/hooks"
Expand All @@ -23,7 +23,7 @@ import { useNostoApi } from "../utils/hooks"
* @group Components
*/
export default function NostoOrder(props: {
order: { purchase: Purchase }
order: Order,
placements?: string[]
}) {
const { order, placements } = props
Expand All @@ -41,15 +41,5 @@ export default function NostoOrder(props: {
},
[recommendationComponent, pageTypeUpdated]
)

return (
<>
<div className="nosto_page_type" style={{ display: "none" }}>
order
</div>
<div className="nosto_order" style={{ display: "none" }}>
{order.purchase.number}
</div>
</>
)
return null
}
9 changes: 1 addition & 8 deletions src/components/NostoOther.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,5 @@ export default function NostoOther(props: { placements?: string[] }) {
},
[recommendationComponent, pageTypeUpdated]
)

return (
<>
<div className="nosto_page_type" style={{ display: "none" }}>
other
</div>
</>
)
return null
}
3 changes: 1 addition & 2 deletions src/components/NostoProduct.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@ export default function NostoProduct(props: {
useNostoApi(
async (api) => {
const data = await api.defaultSession()
.viewProduct(tagging?.productId ?? product)
.viewProduct(tagging ?? product)
.setPlacements(placements || api.placements.getPlacements())
.load()
renderCampaigns(data, api)
},
[product, recommendationComponent, pageTypeUpdated],
{ deep: true }
)

return null
}
12 changes: 1 addition & 11 deletions src/components/NostoSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,5 @@ export default function NostoSearch(props: { query: string; placements?: string[
},
[query, recommendationComponent, pageTypeUpdated]
)

return (
<>
<div className="nosto_page_type" style={{ display: "none" }}>
search
</div>
<div className="nosto_search" style={{ display: "none" }}>
{query}
</div>
</>
)
return null
}
4 changes: 2 additions & 2 deletions src/components/NostoSession.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { useDeepCompareEffect } from "../utils/hooks"
*
* @group Essential Functions
*/
export default function NostoSession(props: { cart: Cart; customer: Customer }) {
const { cart, customer } = props
export default function NostoSession(props?: { cart?: Cart; customer?: Customer }) {
const { cart, customer } = props ?? {}
const { clientScriptLoaded } = useNostoContext()

useDeepCompareEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/context.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createContext, useContext } from "react"
import { NostoClient, Recommendation } from "../types"
import { NostoClient, Recommendation, RenderMode } from "../types"

type AnyFunction = (...args: unknown[]) => unknown

Expand All @@ -11,7 +11,7 @@ export interface NostoContextType {
clientScriptLoaded: boolean
currentVariation?: string
renderFunction?: AnyFunction
responseMode: string
responseMode: RenderMode
recommendationComponent?: React.ReactElement<{
nostoRecommendation: Recommendation
}>
Expand Down
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export type { Buyer, Cart, Customer, Item, Product, Purchase, Recommendation, SKU } from "./types"

export type { Cart, Customer, Product, Order, Recommendation } from "./types"
export * from "./components"
Loading

0 comments on commit 6f27ad9

Please sign in to comment.