Skip to content

Commit

Permalink
Merge branch 'main' of github.com:amplience/amplience-bigcommerce-cat…
Browse files Browse the repository at this point in the history
…alyst
  • Loading branch information
Benj0s committed May 16, 2024
2 parents 049f38c + 32bf1fb commit 15c99ac
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { PropsWithChildren } from 'react';

import { CompareProductsProvider } from '~/app/contexts/compare-products-context';

import { RealtimeVisualizationProvider } from './contexts/compare-products-context/amplience/realtime-visualization-context';
import { RealtimeVisualizationProvider } from './contexts/amplience/realtime-visualization-context';

export function Providers({ children }: PropsWithChildren) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@

import { useCallback, useState } from 'react';

import { AmplienceContentItem } from '~/amplience-client';
import {
useInitialRealtimeContent,
useRealtimeVisualization,
} from '~/app/contexts/compare-products-context/amplience/realtime-visualization-context';
} from '~/app/contexts/amplience/realtime-visualization-context';

import AmplienceContent from '../wrapper/amplience-content';

export interface RealtimeVisualizationProps {
content?: AmplienceContentItem;
content?: Record<string, unknown>;
}

export default function RealtimeVisualization({ content }: RealtimeVisualizationProps) {
const [contentItem, setContentItem] = useState<AmplienceContentItem | undefined>(content);
const [contentItem, setContentItem] = useState<Record<string, unknown> | undefined>(content);

const updateRealtimeContent = useCallback((realtimeContent: AmplienceContentItem) => {
const updateRealtimeContent = useCallback((realtimeContent: Record<string, unknown>) => {
setContentItem(realtimeContent);
}, []);

Expand Down
11 changes: 6 additions & 5 deletions components/amplience/wrapper/amplience-content.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AmplienceContentItem } from '~/amplience-client';
import { ContentItem } from 'dc-delivery-sdk-js';

import CuratedProductGrid from '../curated-product-grid/curated-product-grid';
import DynamicProductGrid from '../dynamic-product-grid/dynamic-product-grid';
Expand All @@ -22,7 +22,7 @@ const COMPONENT_MAPPING: ComponentMapType = {
'https://demostore.amplience.com/content/product-grid': DynamicProductGrid,
};

const MappingNotFound = (content: AmplienceContentItem) => {
const MappingNotFound = (content: ContentItem) => {
return (
<pre>
<code className="block break-words text-xs md:text-sm">
Expand All @@ -33,13 +33,14 @@ const MappingNotFound = (content: AmplienceContentItem) => {
};

export interface AmplienceContentProps {
content?: AmplienceContentItem;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
content?: Record<string, any>;
}

// Wrapper component maps Amplience components based on content schema
const AmplienceContent = ({ content }: AmplienceContentProps) => {
// eslint-disable-next-line no-underscore-dangle
const contentSchema = content?._meta?.schema || '';
// eslint-disable-next-line no-underscore-dangle, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
const contentSchema: string = content?._meta?.schema || '';

const Component = COMPONENT_MAPPING[contentSchema] ?? MappingNotFound;

Expand Down

0 comments on commit 15c99ac

Please sign in to comment.