mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-21 13:55:45 +00:00
refactor(FE): Refactor tab actions store to use a unified implementation
This commit is contained in:
@@ -18,7 +18,7 @@ import HppExpeditionClosingTab from '@/components/pages/closing/tab/HppExpeditio
|
||||
import ClosingKandangList from '@/components/pages/closing/ClosingKandangList';
|
||||
import { ProjectFlock } from '@/types/api/production/project-flock';
|
||||
import { ProjectFlockKandang } from '@/types/api/production/project-flock-kandang';
|
||||
import { useClosingTabStore } from '@/stores/closing/closing-tab.store';
|
||||
import { useTabActionsStore } from '@/stores/tab-actions/tab-actions.store';
|
||||
interface ClosingDetailProps {
|
||||
id: number;
|
||||
initialValue?: ClosingGeneralInformation;
|
||||
@@ -33,7 +33,7 @@ const ClosingDetail: React.FC<ClosingDetailProps> = ({
|
||||
kandangData,
|
||||
}) => {
|
||||
const [activeTabId, setActiveTabId] = useState<string>('sapronak');
|
||||
const tabActions = useClosingTabStore((state) => state.tabActions);
|
||||
const tabActions = useTabActionsStore((state) => state.tabActions);
|
||||
|
||||
const closingDetailTabs = useMemo(() => {
|
||||
const validTabs = [
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
import { useState } from 'react';
|
||||
import Tabs from '@/components/Tabs';
|
||||
|
||||
import { useReportTabStore } from '@/stores/report/report-tab.store';
|
||||
import { useTabActionsStore } from '@/stores/tab-actions/tab-actions.store';
|
||||
import ReportExpenseTab from './tab/ReportExpenseTab';
|
||||
|
||||
const ReportExpenseTabs = () => {
|
||||
const [activeTabId, setActiveTabId] = useState<string>('1');
|
||||
const tabActions = useReportTabStore((state) => state.tabActions);
|
||||
const tabActions = useTabActionsStore((state) => state.tabActions);
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ import { cn, formatCurrency, formatDate } from '@/lib/helper';
|
||||
import { ReportExpense } from '@/types/api/report/report-expense';
|
||||
import { ReportExpenseApi } from '@/services/api/report';
|
||||
import { isResponseSuccess } from '@/lib/api-helper';
|
||||
import { useReportTabStore } from '@/stores/report/report-tab.store';
|
||||
import { useTabActionsStore } from '@/stores/tab-actions/tab-actions.store';
|
||||
import Modal, { useModal } from '@/components/Modal';
|
||||
import Pagination from '@/components/Pagination';
|
||||
import ReportExpenseSkeleton from '@/components/pages/report/expense/skeleton/ReportExpenseSkeleton';
|
||||
@@ -305,8 +305,8 @@ const ReportExpenseTab = ({ tabId }: ReportExpenseTabProps) => {
|
||||
]);
|
||||
|
||||
// ===== REGISTER TAB ACTIONS TO STORE =====
|
||||
const setTabActions = useReportTabStore((state) => state.setTabActions);
|
||||
const clearTabActions = useReportTabStore((state) => state.clearTabActions);
|
||||
const setTabActions = useTabActionsStore((state) => state.setTabActions);
|
||||
const clearTabActions = useTabActionsStore((state) => state.clearTabActions);
|
||||
|
||||
useEffect(() => {
|
||||
setTabActions(
|
||||
|
||||
@@ -4,11 +4,11 @@ import { useState } from 'react';
|
||||
import Tabs from '@/components/Tabs';
|
||||
import CustomerPaymentTab from '@/components/pages/report/finance/tab/CustomerPaymentTab';
|
||||
import DebtSupplierTab from '@/components/pages/report/finance/tab/DebtSupplierTab';
|
||||
import { useReportTabStore } from '@/stores/report/report-tab.store';
|
||||
import { useTabActionsStore } from '@/stores/tab-actions/tab-actions.store';
|
||||
|
||||
const FinanceTabs = () => {
|
||||
const [activeTabId, setActiveTabId] = useState<string>('1');
|
||||
const tabActions = useReportTabStore((state) => state.tabActions);
|
||||
const tabActions = useTabActionsStore((state) => state.tabActions);
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ import {
|
||||
} from '@/components/pages/report/finance/filter/CustomerPaymentFilter';
|
||||
import { generateCustomerPaymentExcel } from '@/components/pages/report/finance/export/CustomerPaymentExportXLSX';
|
||||
import { generateCustomerPaymentPDF } from '@/components/pages/report/finance/export/CustomerPaymentExportPDF';
|
||||
import { useReportTabStore } from '@/stores/report/report-tab.store';
|
||||
import { useTabActionsStore } from '@/stores/tab-actions/tab-actions.store';
|
||||
import CustomerSupplierSkeleton from '@/components/pages/report/finance/skeleton/CustomerSupplierSkeleton';
|
||||
import { OptionType } from '@/components/table/TableRowSizeSelector';
|
||||
import { Color } from '@/types/theme';
|
||||
@@ -373,8 +373,8 @@ const CustomerPaymentTab = ({ tabId }: CustomerPaymentTabProps) => {
|
||||
}, [customerPaymentExport, filterParams, customerOptions]);
|
||||
|
||||
// ===== REGISTER TAB ACTIONS TO STORE =====
|
||||
const setTabActions = useReportTabStore((state) => state.setTabActions);
|
||||
const clearTabActions = useReportTabStore((state) => state.clearTabActions);
|
||||
const setTabActions = useTabActionsStore((state) => state.setTabActions);
|
||||
const clearTabActions = useTabActionsStore((state) => state.clearTabActions);
|
||||
|
||||
useEffect(() => {
|
||||
setTabActions(
|
||||
|
||||
@@ -31,7 +31,7 @@ import { Color } from '@/types/theme';
|
||||
import { Supplier } from '@/types/api/master-data/supplier';
|
||||
import SelectInputCheckbox from '@/components/input/SelectInputCheckbox';
|
||||
import SelectInputRadio from '@/components/input/SelectInputRadio';
|
||||
import { useReportTabStore } from '@/stores/report/report-tab.store';
|
||||
import { useTabActionsStore } from '@/stores/tab-actions/tab-actions.store';
|
||||
import StatusBadge from '@/components/helper/StatusBadge';
|
||||
import DebtSupplierSkeleton from '@/components/pages/report/finance/skeleton/DebtSupplierSkeleton';
|
||||
|
||||
@@ -265,8 +265,8 @@ const DebtSupplierTab = ({ tabId }: DebtSupplierTabProps) => {
|
||||
}, [debtSupplierExport]);
|
||||
|
||||
// ===== REGISTER TAB ACTIONS TO STORE =====
|
||||
const setTabActions = useReportTabStore((state) => state.setTabActions);
|
||||
const clearTabActions = useReportTabStore((state) => state.clearTabActions);
|
||||
const setTabActions = useTabActionsStore((state) => state.setTabActions);
|
||||
const clearTabActions = useTabActionsStore((state) => state.clearTabActions);
|
||||
|
||||
useEffect(() => {
|
||||
setTabActions(
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
import { useState } from 'react';
|
||||
import Tabs from '@/components/Tabs';
|
||||
import PurchasesPerSupplierTab from '@/components/pages/report/logistic-stock/tab/PurchasesPerSupplierTab';
|
||||
import { useReportTabStore } from '@/stores/report/report-tab.store';
|
||||
import { useTabActionsStore } from '@/stores/tab-actions/tab-actions.store';
|
||||
|
||||
const LogisticStockTabs = () => {
|
||||
const [activeTabId, setActiveTabId] = useState<string>('1');
|
||||
const tabActions = useReportTabStore((state) => state.tabActions);
|
||||
const tabActions = useTabActionsStore((state) => state.tabActions);
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ import {
|
||||
} from '@/components/pages/report/logistic-stock/filter/PurchasesPerSupplierFilter';
|
||||
import SelectInputCheckbox from '@/components/input/SelectInputCheckbox';
|
||||
import SelectInputRadio from '@/components/input/SelectInputRadio';
|
||||
import { useReportTabStore } from '@/stores/report/report-tab.store';
|
||||
import { useTabActionsStore } from '@/stores/tab-actions/tab-actions.store';
|
||||
import PurchasePerSupplierSkeleton from '@/components/pages/report/logistic-stock/skeleton/PurchasePerSupplierSkeleton';
|
||||
|
||||
interface PurchasesPerSupplierTabProps {
|
||||
@@ -479,8 +479,8 @@ const PurchasesPerSupplierTab = ({ tabId }: PurchasesPerSupplierTabProps) => {
|
||||
]);
|
||||
|
||||
// ===== REGISTER TAB ACTIONS TO STORE =====
|
||||
const setTabActions = useReportTabStore((state) => state.setTabActions);
|
||||
const clearTabActions = useReportTabStore((state) => state.clearTabActions);
|
||||
const setTabActions = useTabActionsStore((state) => state.setTabActions);
|
||||
const clearTabActions = useTabActionsStore((state) => state.clearTabActions);
|
||||
|
||||
useEffect(() => {
|
||||
setTabActions(
|
||||
|
||||
@@ -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 { useReportTabStore } from '@/stores/report/report-tab.store';
|
||||
import { useTabActionsStore } from '@/stores/tab-actions/tab-actions.store';
|
||||
|
||||
const MarketingReportContent = () => {
|
||||
const [activeTabId, setActiveTabId] = useState<string>('1');
|
||||
const tabActions = useReportTabStore((state) => state.tabActions);
|
||||
const tabActions = useTabActionsStore((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 { useReportTabStore } from '@/stores/report/report-tab.store';
|
||||
import { useTabActionsStore } from '@/stores/tab-actions/tab-actions.store';
|
||||
import DailyMarketingReportSkeleton from '@/components/pages/report/marketing/skeleton/DailyMarketingSkeleton';
|
||||
import { useEffect as useEffectHook } from 'react';
|
||||
import { httpClient } from '@/services/http/client';
|
||||
@@ -390,8 +390,8 @@ const DailyMarketingTab = ({ tabId }: DailyMarketingTabProps) => {
|
||||
}, [dailyMarketingsExport, summaryTotal]);
|
||||
|
||||
// ===== REGISTER TAB ACTIONS TO STORE =====
|
||||
const setTabActions = useReportTabStore((state) => state.setTabActions);
|
||||
const clearTabActions = useReportTabStore((state) => state.clearTabActions);
|
||||
const setTabActions = useTabActionsStore((state) => state.setTabActions);
|
||||
const clearTabActions = useTabActionsStore((state) => state.clearTabActions);
|
||||
|
||||
useEffectHook(() => {
|
||||
setTabActions(
|
||||
|
||||
@@ -31,7 +31,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 { useReportTabStore } from '@/stores/report/report-tab.store';
|
||||
import { useTabActionsStore } from '@/stores/tab-actions/tab-actions.store';
|
||||
import HppPerKandangSkeleton from '@/components/pages/report/marketing/skeleton/HppPerKandangSkeleton';
|
||||
import { useEffect as useEffectHook } from 'react';
|
||||
|
||||
@@ -479,8 +479,8 @@ const HppPerKandangTab = ({ tabId }: HppPerKandangTabProps) => {
|
||||
]);
|
||||
|
||||
// ===== REGISTER TAB ACTIONS TO STORE =====
|
||||
const setTabActions = useReportTabStore((state) => state.setTabActions);
|
||||
const clearTabActions = useReportTabStore((state) => state.clearTabActions);
|
||||
const setTabActions = useTabActionsStore((state) => state.setTabActions);
|
||||
const clearTabActions = useTabActionsStore((state) => state.clearTabActions);
|
||||
|
||||
useEffectHook(() => {
|
||||
setTabActions(
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
import { useState } from 'react';
|
||||
import Tabs from '@/components/Tabs';
|
||||
import ProductionResultTab from '@/components/pages/report/production-result/tab/ProductionResultProjectFlockKandangTab';
|
||||
import { useReportTabStore } from '@/stores/report/report-tab.store';
|
||||
|
||||
import { useTabActionsStore } from '@/stores/tab-actions/tab-actions.store';
|
||||
const ProductionResultTabs = () => {
|
||||
const [activeTabId, setActiveTabId] = useState<string>('1');
|
||||
const tabActions = useReportTabStore((state) => state.tabActions);
|
||||
const tabActions = useTabActionsStore((state) => state.tabActions);
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
|
||||
+3
-3
@@ -34,7 +34,7 @@ import { ColumnDef } from '@tanstack/react-table';
|
||||
import { ProductionResult } from '@/types/api/report/production-result';
|
||||
import ProductionResultReportPDF from '../export/ProductionResultExportPDF';
|
||||
import { pdf } from '@react-pdf/renderer';
|
||||
import { useReportTabStore } from '@/stores/report/report-tab.store';
|
||||
import { useTabActionsStore } from '@/stores/tab-actions/tab-actions.store';
|
||||
import Modal, { useModal } from '@/components/Modal';
|
||||
import { cn, formatNumber } from '@/lib/helper';
|
||||
import Pagination from '@/components/Pagination';
|
||||
@@ -532,8 +532,8 @@ const ProductionResultContent = ({ tabId }: ProductionResultTabProps) => {
|
||||
}, [filterParams]);
|
||||
|
||||
// ===== REGISTER TAB ACTIONS TO STORE =====
|
||||
const setTabActions = useReportTabStore((state) => state.setTabActions);
|
||||
const clearTabActions = useReportTabStore((state) => state.clearTabActions);
|
||||
const setTabActions = useTabActionsStore((state) => state.setTabActions);
|
||||
const clearTabActions = useTabActionsStore((state) => state.clearTabActions);
|
||||
|
||||
useEffect(() => {
|
||||
setTabActions(
|
||||
|
||||
Reference in New Issue
Block a user