From 3ab9f0423e97af63da4bf6a13ffd786955bd5b3b Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Thu, 26 Oct 2023 21:55:55 +0200
Subject: refactor(hooks,providers): rewrite useAckee hook and AckeeProvider

---
 .../organisms/toolbar/settings.stories.tsx         | 29 ++++++----------------
 1 file changed, 7 insertions(+), 22 deletions(-)

(limited to 'src/components/organisms/toolbar/settings.stories.tsx')

diff --git a/src/components/organisms/toolbar/settings.stories.tsx b/src/components/organisms/toolbar/settings.stories.tsx
index bea0d9e..66b4e0f 100644
--- a/src/components/organisms/toolbar/settings.stories.tsx
+++ b/src/components/organisms/toolbar/settings.stories.tsx
@@ -1,5 +1,5 @@
-import { ComponentMeta, ComponentStory } from '@storybook/react';
-import { useState } from 'react';
+import type { ComponentMeta, ComponentStory } from '@storybook/react';
+import { useCallback, useState } from 'react';
 import { Settings } from './settings';
 
 /**
@@ -9,20 +9,9 @@ export default {
   title: 'Organisms/Toolbar/Settings',
   component: Settings,
   args: {
-    ackeeStorageKey: 'ackee-tracking',
     motionStorageKey: 'reduced-motion',
   },
   argTypes: {
-    ackeeStorageKey: {
-      control: {
-        type: 'text',
-      },
-      description: 'Set Ackee settings local storage key.',
-      type: {
-        name: 'string',
-        required: true,
-      },
-    },
     className: {
       control: {
         type: 'text',
@@ -92,15 +81,11 @@ const Template: ComponentStory<typeof Settings> = ({
 }) => {
   const [isOpen, setIsOpen] = useState<boolean>(isActive);
 
-  return (
-    <Settings
-      isActive={isOpen}
-      setIsActive={() => {
-        setIsOpen(!isOpen);
-      }}
-      {...args}
-    />
-  );
+  const toggle = useCallback(() => {
+    setIsOpen((prevState) => !prevState);
+  }, []);
+
+  return <Settings isActive={isOpen} setIsActive={toggle} {...args} />;
 };
 
 /**
-- 
cgit v1.2.3

