Skip to content

Instantly share code, notes, and snippets.

@minostro
Created November 22, 2023 04:02
Show Gist options
  • Save minostro/44ad69f9fb321b843c2a868a4524bf80 to your computer and use it in GitHub Desktop.
Save minostro/44ad69f9fb321b843c2a868a4524bf80 to your computer and use it in GitHub Desktop.
diff --git a/libs/taxes/hub/ui-components/src/lib/Result/ResultElement.stories.tsx b/libs/taxes/hub/ui-components/src/lib/Result/ResultElement.stories.tsx
new file mode 100644
index 000000000..bfb85f74d
--- /dev/null
+++ b/libs/taxes/hub/ui-components/src/lib/Result/ResultElement.stories.tsx
@@ -0,0 +1,38 @@
+import { Meta, StoryFn } from '@storybook/react'
+
+import { Result, ResultType } from "./ResultElement";
+import { Provider as DesignSystemProvider } from '@cash-design-system/react'
+
+export default {
+ title: 'Taxes/Applet/ResultElement',
+ component: Result,
+ argTypes: {
+ value: {
+ defaultValue: '{}',
+ control: {
+ type: 'text',
+ },
+ },
+ type: {
+ defaultValue: 'FormBlocker',
+ control: {
+ type: 'select',
+ },
+ options: ['FormBlocker', 'StatusResult'],
+ },
+ }
+} as Meta<typeof Result>
+
+const Template: StoryFn<typeof Result> = args => {
+ return (
+ <DesignSystemProvider darkMode={true}>
+ <Result value={args.value} type={args.type} />
+ </DesignSystemProvider>
+ )
+}
+
+export const Default = Template.bind({})
+Default.args = {
+ value: '{}',
+ type: ResultType.FormBlocker
+}
diff --git a/libs/taxes/hub/ui-components/src/lib/Result/ResultElement.tsx b/libs/taxes/hub/ui-components/src/lib/Result/ResultElement.tsx
new file mode 100644
index 000000000..65ce9469e
--- /dev/null
+++ b/libs/taxes/hub/ui-components/src/lib/Result/ResultElement.tsx
@@ -0,0 +1,23 @@
+import {FormBlocker} from "@cash-web/shared-blocker-feature-main";
+
+//Using the enum as string to make the switch statement work.
+export enum ResultType {
+ FormBlocker = "FormBlocker",
+ StatusResult = "StatusResult"
+}
+
+export const Result = ({value, type} : {value: string, type: ResultType}) => {
+ let resolvedValue
+ //TODO(minostroza): this is a hack to get around the fact that the value is a string
+ switch (type) {
+ case ResultType.FormBlocker:
+ resolvedValue = JSON.parse(value)
+ break;
+ case ResultType.StatusResult:
+ resolvedValue = JSON.parse(value)
+ break;
+ }
+ return (
+ <FormBlocker id="generated-id" blocker={resolvedValue} />
+ )
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment