Merge branch 'dev/hotfix/restu' into 'development'

[HOTFIX/FE] Fixing Penjualan Tabs (Misplacement Issue)

See merge request mbugroup/lti-web-client!81
This commit is contained in:
Adnan Zahir
2025-12-10 15:33:54 +07:00
4 changed files with 30 additions and 20 deletions
+12 -12
View File
@@ -4,7 +4,6 @@ import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr'; import useSWR from 'swr';
import ClosingDetail from '@/components/pages/closing/ClosingDetail'; import ClosingDetail from '@/components/pages/closing/ClosingDetail';
import SalesReportTable from '@/components/pages/closing/sale/SalesReportTable';
import { ClosingApi } from '@/services/api/closing'; import { ClosingApi } from '@/services/api/closing';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper'; import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
@@ -20,9 +19,9 @@ const ClosingDetailPage = () => {
(id: number) => ClosingApi.getGeneralInfo(id) (id: number) => ClosingApi.getGeneralInfo(id)
); );
const { data: salesReport, isLoading: isLoadingSalesReport } = useSWR( const { data: salesData, isLoading: isLoadingSales } = useSWR(
closingId, closingId ? `sales-${closingId}` : null,
(id: number) => ClosingApi.getPenjualan(id) () => ClosingApi.getPenjualan(Number(closingId))
); );
if (!closingId) { if (!closingId) {
@@ -40,17 +39,18 @@ const ClosingDetailPage = () => {
return; return;
} }
const isLoading = isLoadingClosing || isLoadingSales;
return ( return (
<div className='w-full p-4 flex flex-row justify-center'> <div className='w-full p-4 flex flex-row justify-center'>
{isLoadingClosing && ( {isLoading && <span className='loading loading-spinner loading-xl' />}
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingClosing && isResponseSuccess(closing) && ( {!isLoading && isResponseSuccess(closing) && (
<ClosingDetail id={Number(closingId)} initialValue={closing.data} /> <ClosingDetail
)} id={Number(closingId)}
{!isLoadingSalesReport && isResponseSuccess(salesReport) && ( initialValue={closing.data}
<SalesReportTable type='detail' initialValues={salesReport.data} /> salesData={isResponseSuccess(salesData) ? salesData.data : undefined}
/>
)} )}
</div> </div>
); );
+12 -3
View File
@@ -7,15 +7,24 @@ import Button from '@/components/Button';
import Tabs from '@/components/Tabs'; import Tabs from '@/components/Tabs';
import ClosingGeneralInformationTable from '@/components/pages/closing/ClosingGeneralInformationTable'; import ClosingGeneralInformationTable from '@/components/pages/closing/ClosingGeneralInformationTable';
import { ClosingGeneralInformation } from '@/types/api/closing'; import {
ClosingGeneralInformation,
BaseClosingSales,
} from '@/types/api/closing';
import ClosingSapronakTabContent from './ClosingSapronakTabContent'; import ClosingSapronakTabContent from './ClosingSapronakTabContent';
import SalesReportTable from './sale/SalesReportTable';
interface ClosingDetailProps { interface ClosingDetailProps {
id: number; id: number;
initialValue?: ClosingGeneralInformation; initialValue?: ClosingGeneralInformation;
salesData?: BaseClosingSales;
} }
const ClosingDetail: React.FC<ClosingDetailProps> = ({ id, initialValue }) => { const ClosingDetail: React.FC<ClosingDetailProps> = ({
id,
initialValue,
salesData,
}) => {
const [activeTab, setActiveTab] = useState<string>('sapronak'); const [activeTab, setActiveTab] = useState<string>('sapronak');
const closingDetailTabs = useMemo(() => { const closingDetailTabs = useMemo(() => {
@@ -33,7 +42,7 @@ const ClosingDetail: React.FC<ClosingDetailProps> = ({ id, initialValue }) => {
{ {
id: 'penjualan', id: 'penjualan',
label: 'Penjualan', label: 'Penjualan',
content: 'Penjualan', content: <SalesReportTable initialValues={salesData} />,
}, },
{ {
id: 'overhead', id: 'overhead',
@@ -263,7 +263,7 @@ const SalesReportTable = ({
tableWrapperClassName: 'overflow-x-auto', tableWrapperClassName: 'overflow-x-auto',
tableClassName: 'w-full table-auto text-sm', tableClassName: 'w-full table-auto text-sm',
headerColumnClassName: headerColumnClassName:
'px-4 py-3 text-xs font-semibold text-gray-500 last:flex last:flex-row last:justify-end whitespace-nowrap border-l border-l-gray-200 border-r border-r-gray-200 border-t border-t-gray-200 border-gray-200 border-b-0', 'px-4 py-3 text-xs font-semibold text-gray-500 whitespace-nowrap border-l border-l-gray-200 border-r border-r-gray-200 border-t border-t-gray-200 border-gray-200 border-b-0',
bodyRowClassName: bodyRowClassName:
'hover:bg-gray-50 transition-colors border-b border-gray-200 first:border-t first:border-t-gray-200 border-l border-l-gray-200 border-r border-r-gray-200', 'hover:bg-gray-50 transition-colors border-b border-gray-200 first:border-t first:border-t-gray-200 border-l border-l-gray-200 border-r border-r-gray-200',
bodyColumnClassName: bodyColumnClassName:
+5 -4
View File
@@ -20,10 +20,11 @@ export class ClosingApiService extends BaseApiService<Closing, null, null> {
id: number id: number
): Promise<BaseApiResponse<ClosingSales> | undefined> { ): Promise<BaseApiResponse<ClosingSales> | undefined> {
try { try {
const getPenjualanPath = `${id}/penjualan`; const getPenjualanPath = `${this.basePath}/${id}/penjualan`;
return await this.customRequest<BaseApiResponse<ClosingSales>>( const getPenjualanRes =
getPenjualanPath await httpClient<BaseApiResponse<ClosingSales>>(getPenjualanPath);
);
return getPenjualanRes;
} catch (error) { } catch (error) {
if (axios.isAxiosError<BaseApiResponse<ClosingSales>>(error)) { if (axios.isAxiosError<BaseApiResponse<ClosingSales>>(error)) {
return error.response?.data; return error.response?.data;