Skip to content

Commit

Permalink
Update examples/stateful-sidebar-with-dialog/src/locations/Dialog.jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
david-shibley-contentful authored Sep 9, 2024
1 parent 61467b1 commit ab1625e
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions examples/stateful-sidebar-with-dialog/src/locations/Dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { reducer } from '../model/reducerAndInitialSidebarState';

const Dialog = () => {
const sdk = useSDK();
const { serializedSidebarState } = (sdk.parameters.invocation || {});
const { serializedSidebarState } = sdk.parameters.invocation || {};
const [state, dispatch] = useReducer(reducer, {});
/*
To use the cma, inject it as follows.
Expand All @@ -20,20 +20,28 @@ const Dialog = () => {
});
}, []);

return <>
<Paragraph>Hello Dialog Component (AppId: {sdk.ids.app})</Paragraph>
<Paragraph>{`Time is ${state.timestamp}`}</Paragraph>
<Button onClick={() => {
dispatch({
type: 'SET_TIME',
payload: new Date().toString(),
});
}}>SET TIME</Button>
<Button
onClick={() => {
sdk.close(JSON.stringify(state));
}}>CLOSE</Button>
</>;
return (
<>
<Paragraph>Hello Dialog Component (AppId: {sdk.ids.app})</Paragraph>
<Paragraph>{`Time is ${state.timestamp}`}</Paragraph>
<Button
onClick={() => {
dispatch({
type: 'SET_TIME',
payload: new Date().toString(),
});
}}>
SET TIME
</Button>
<Button
onClick={() => {
sdk.close(JSON.stringify(state));
}}>
CLOSE
</Button>
</>
);
};

export default Dialog;

0 comments on commit ab1625e

Please sign in to comment.