refactor(FE): Refactor tab store to use a unified ReportTabStore

This commit is contained in:
rstubryan
2026-02-12 16:16:40 +07:00
parent 6aae18df54
commit dbb523c710
13 changed files with 76 additions and 182 deletions
@@ -4,11 +4,11 @@ import { useState } from 'react';
import Tabs from '@/components/Tabs';
import DailyMarketingReportContent from '@/components/pages/report/marketing/tab/DailyMarketingTab';
import HppPerKandangTab from '@/components/pages/report/marketing/tab/HppPerKandangTab';
import { useMarketingTabStore } from '@/stores/report/marketing-tab/marketing-tab.store';
import { useReportTabStore } from '@/stores/report/report-tab.store';
const MarketingReportContent = () => {
const [activeTabId, setActiveTabId] = useState<string>('1');
const tabActions = useMarketingTabStore((state) => state.tabActions);
const tabActions = useReportTabStore((state) => state.tabActions);
const tabs = [
{
@@ -37,7 +37,7 @@ import {
import SelectInput from '@/components/input/SelectInput';
import Modal, { useModal } from '@/components/Modal';
import { cn } from '@/lib/helper';
import { useMarketingTabStore } from '@/stores/report/marketing-tab/marketing-tab.store';
import { useReportTabStore } from '@/stores/report/report-tab.store';
import DailyMarketingReportSkeleton from '@/components/pages/report/marketing/skeleton/DailyMarketingSkeleton';
import { useEffect as useEffectHook } from 'react';
import { httpClient } from '@/services/http/client';
@@ -390,10 +390,8 @@ const DailyMarketingTab = ({ tabId }: DailyMarketingTabProps) => {
}, [dailyMarketingsExport, summaryTotal]);
// ===== REGISTER TAB ACTIONS TO STORE =====
const setTabActions = useMarketingTabStore((state) => state.setTabActions);
const clearTabActions = useMarketingTabStore(
(state) => state.clearTabActions
);
const setTabActions = useReportTabStore((state) => state.setTabActions);
const clearTabActions = useReportTabStore((state) => state.clearTabActions);
useEffectHook(() => {
setTabActions(
@@ -33,7 +33,7 @@ import SelectInputCheckbox from '@/components/input/SelectInputCheckbox';
import SelectInputRadio from '@/components/input/SelectInputRadio';
import Modal, { useModal } from '@/components/Modal';
import { cn } from '@/lib/helper';
import { useMarketingTabStore } from '@/stores/report/marketing-tab/marketing-tab.store';
import { useReportTabStore } from '@/stores/report/report-tab.store';
import HppPerKandangSkeleton from '@/components/pages/report/marketing/skeleton/HppPerKandangSkeleton';
import { useEffect as useEffectHook } from 'react';
@@ -487,10 +487,8 @@ const HppPerKandangTab = ({ tabId }: HppPerKandangTabProps) => {
]);
// ===== REGISTER TAB ACTIONS TO STORE =====
const setTabActions = useMarketingTabStore((state) => state.setTabActions);
const clearTabActions = useMarketingTabStore(
(state) => state.clearTabActions
);
const setTabActions = useReportTabStore((state) => state.setTabActions);
const clearTabActions = useReportTabStore((state) => state.clearTabActions);
useEffectHook(() => {
setTabActions(