Skip to content

Commit

Permalink
DataLoop
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkirtzel committed Feb 24, 2025
1 parent b5270fe commit 922fe37
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions website/docs/destinations/event_mapping.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
DataMap,
DataSet,
DataComplete,
DataLoop,
} from '@site/src/components/templates/mappings/eventConfig';
import Link from '@docusaurus/Link';

Expand Down Expand Up @@ -124,6 +125,8 @@ to a `WalkerOS.Property`.
Loops over the first parameter and maps the second to the current value. It is
used for creating an array of dynamic length.

<DataLoop />

### condition

Is a function to check if the mapping should be used. It returns a boolean, if
Expand Down
20 changes: 16 additions & 4 deletions website/src/components/templates/mappings/eventConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Mapping } from '@elbwalker/types';
import { getEvent } from '@elbwalker/utils';
import { DestinationPush } from '../destination';

Expand All @@ -9,23 +10,25 @@ export const destination = {
},
};

const string = 'data.total';
const string: Mapping.Data = 'data.total';

const key = {
const key: Mapping.Data = {
key: 'data.id',
};

const map = {
const map: Mapping.Data = {
map: {
pageGroup: 'globals.pagegroup',
shoppingStage: 'context.shopping.0',
},
};

const set = {
const set: Mapping.Data = {
set: ['trigger', 'entity', 'action'],
};

const loop: Mapping.Data = { loop: ['nested', 'data.name'] };

export const DataString: React.FC = () => {
return (
<DestinationPush event={{ data: event.data }} mapping={{ data: string }} />
Expand Down Expand Up @@ -60,6 +63,15 @@ export const DataSet: React.FC = () => {
);
};

export const DataLoop: React.FC = () => {
return (
<DestinationPush
event={{ nested: event.nested }}
mapping={{ data: loop }}
/>
);
};

export const DataComplete: React.FC = () => {
return (
<DestinationPush
Expand Down

0 comments on commit 922fe37

Please sign in to comment.