diff --git a/client/components/dashboard/QuickActionSection.tsx b/client/components/dashboard/QuickActionSection.tsx index 4d5a40f79..9d03b86a3 100644 --- a/client/components/dashboard/QuickActionSection.tsx +++ b/client/components/dashboard/QuickActionSection.tsx @@ -1,38 +1,11 @@ import { RStack } from '@packrat/ui'; import QuickActionButton from './QuickActionButton'; -import useTheme from '../../hooks/useTheme'; -import { useRouter } from 'expo-router'; import useCustomStyles from '~/hooks/useCustomStyles'; +import { useQuickActions } from '~/hooks/dashboard'; const QuickActionsSection = () => { - const router = useRouter(); const styles = useCustomStyles(loadStyles); - - const quickActionData = [ - { - action: 'createPack', - iconName: 'backpack', - text: 'Create a Pack', - }, - { - action: 'createTrip', - iconName: 'navigation', - text: 'Create a Trip', - }, - ]; - - /** - * Handles the selection of an action. - * - * @param {string} action - The selected action. - */ - const handleActionSelect = (action) => { - if (action === 'createPack') { - router.push('/pack/create'); - } else if (action === 'createTrip') { - router.push('/trip/create'); - } - }; + const { handleActionSelect, quickActionData } = useQuickActions(); return ( diff --git a/client/hooks/dashboard/index.ts b/client/hooks/dashboard/index.ts new file mode 100644 index 000000000..e2e87eb3e --- /dev/null +++ b/client/hooks/dashboard/index.ts @@ -0,0 +1 @@ +export { useQuickActions } from './useQuickActions' \ No newline at end of file diff --git a/client/hooks/dashboard/useQuickActions.ts b/client/hooks/dashboard/useQuickActions.ts new file mode 100644 index 000000000..3d40f5d50 --- /dev/null +++ b/client/hooks/dashboard/useQuickActions.ts @@ -0,0 +1,33 @@ +import { useRouter } from "expo-router"; + +const quickActionData = [ + { + action: 'createPack', + iconName: 'backpack', + text: 'Create a Pack', + }, + { + action: 'createTrip', + iconName: 'navigation', + text: 'Create a Trip', + }, +]; + +export const useQuickActions = () => { + const router = useRouter(); + + /** + * Handles the selection of an action. + * + * @param {string} action - The selected action. + */ + const handleActionSelect = (action) => { + if (action === 'createPack') { + router.push('/pack/create'); + } else if (action === 'createTrip') { + router.push('/trip/create'); + } + }; + + return { quickActionData, handleActionSelect } +} \ No newline at end of file