mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 21:41:57 +00:00
Merge branch 'fix/marketing-report' into 'development'
[FIX/FE] Daily Marketing Report See merge request mbugroup/lti-web-client!171
This commit is contained in:
@@ -197,7 +197,7 @@ const ClosingProductionDataTabContent = ({
|
||||
value={formatNumber(performance.mor_diff)}
|
||||
unitClassName='hidden'
|
||||
/>
|
||||
<DataRow
|
||||
{/* <DataRow
|
||||
label='AWG Std'
|
||||
value={formatNumber(performance.awg_std)}
|
||||
unit='Gr/Hari'
|
||||
@@ -206,7 +206,7 @@ const ClosingProductionDataTabContent = ({
|
||||
label='AWG Act'
|
||||
value={formatNumber(performance.awg_act)}
|
||||
unit='Gr/Hari'
|
||||
/>
|
||||
/> */}
|
||||
<DataRow
|
||||
label='Feed Intake Std'
|
||||
value={formatNumber(performance.feed_intake_std)}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { ChangeEventHandler, useState } from 'react';
|
||||
import { ChangeEventHandler, useEffect, useState } from 'react';
|
||||
import { pdf } from '@react-pdf/renderer';
|
||||
import toast from 'react-hot-toast';
|
||||
|
||||
@@ -28,7 +28,10 @@ import {
|
||||
import { Warehouse } from '@/types/api/master-data/warehouse';
|
||||
import { Customer } from '@/types/api/master-data/customer';
|
||||
import { MarketingReportApi } from '@/services/api/report/marketing-report';
|
||||
import { MARKETING_TYPE_OPTIONS } from '@/config/constant';
|
||||
import {
|
||||
MARKETING_DATE_FILTER_TYPE_OPTIONS,
|
||||
MARKETING_TYPE_OPTIONS,
|
||||
} from '@/config/constant';
|
||||
import { httpClient } from '@/services/http/client';
|
||||
import { BaseApiResponse } from '@/types/api/api-general';
|
||||
import {
|
||||
@@ -150,6 +153,15 @@ const DailyMarketingReportContent = () => {
|
||||
updateFilter('end_date', e.target.value ? e.target.value : '');
|
||||
};
|
||||
|
||||
const [selectedMarketingDateFilterType, setSelectedMarketingDateFilterType] =
|
||||
useState<OptionType | null>(null);
|
||||
const marketingDateFilterTypeChangeHandler = (
|
||||
val: OptionType | OptionType[] | null
|
||||
) => {
|
||||
setSelectedMarketingDateFilterType(val as OptionType);
|
||||
updateFilter('filter_by', val ? ((val as OptionType).value as string) : '');
|
||||
};
|
||||
|
||||
const [selectedMarketingType, setSelectedMarketingType] =
|
||||
useState<OptionType | null>(null);
|
||||
const marketingTypeChangeHandler = (
|
||||
@@ -252,6 +264,23 @@ const DailyMarketingReportContent = () => {
|
||||
resetFilter();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
tableFilterState.filter_by === 'realization_date' ||
|
||||
tableFilterState.filter_by === 'so_date'
|
||||
) {
|
||||
setSelectedMarketingDateFilterType({
|
||||
label:
|
||||
tableFilterState.filter_by === 'realization_date'
|
||||
? 'Tanggal Realisasi'
|
||||
: 'Tanggal SO',
|
||||
value: tableFilterState.filter_by,
|
||||
});
|
||||
} else {
|
||||
setSelectedMarketingDateFilterType(null);
|
||||
}
|
||||
}, [tableFilterState.filter_by]);
|
||||
|
||||
return (
|
||||
<div className='w-full border border-gray-200 p-4'>
|
||||
<div>
|
||||
@@ -341,6 +370,18 @@ const DailyMarketingReportContent = () => {
|
||||
</div>
|
||||
|
||||
<div className='grid grid-cols-12 gap-4'>
|
||||
<SelectInput
|
||||
label='Filter Tanggal'
|
||||
placeholder='Pilih Filter Tanggal'
|
||||
options={MARKETING_DATE_FILTER_TYPE_OPTIONS}
|
||||
value={selectedMarketingDateFilterType}
|
||||
onChange={marketingDateFilterTypeChangeHandler}
|
||||
isClearable
|
||||
className={{
|
||||
wrapper: 'col-span-12 sm:col-span-6 lg:col-span-4',
|
||||
}}
|
||||
/>
|
||||
|
||||
<SelectInput
|
||||
label='Tipe Marketing'
|
||||
placeholder='Pilih Tipe Marketing'
|
||||
|
||||
@@ -71,19 +71,22 @@ const DailyMarketingsTable = ({
|
||||
cell: (props) => `${props.row.original.aging_days} hari`,
|
||||
},
|
||||
{
|
||||
accessorKey: 'warehouse.name',
|
||||
accessorKey: 'warehouse',
|
||||
header: 'Gudang',
|
||||
cell: ({ row }) => row.original.warehouse.name,
|
||||
},
|
||||
{
|
||||
accessorKey: 'customer.name',
|
||||
accessorKey: 'customer',
|
||||
header: 'Pelanggan',
|
||||
cell: ({ row }) => row.original.customer.name,
|
||||
},
|
||||
{
|
||||
accessorKey: 'do_number',
|
||||
header: 'No. DO',
|
||||
enableSorting: false,
|
||||
},
|
||||
{
|
||||
accessorKey: 'sales',
|
||||
accessorKey: 'sales_person',
|
||||
header: 'Sales/Marketing',
|
||||
cell: (props) => props.row.original.sales.name,
|
||||
},
|
||||
@@ -97,10 +100,12 @@ const DailyMarketingsTable = ({
|
||||
{
|
||||
accessorKey: 'marketing_type',
|
||||
header: 'Marketing Type',
|
||||
enableSorting: false,
|
||||
},
|
||||
{
|
||||
accessorKey: 'product.name',
|
||||
accessorKey: 'product',
|
||||
header: 'Produk',
|
||||
cell: ({ row }) => row.original.product.name,
|
||||
},
|
||||
{
|
||||
accessorKey: 'qty',
|
||||
@@ -115,12 +120,12 @@ const DailyMarketingsTable = ({
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: 'average_weight_kg',
|
||||
accessorKey: 'average_weight',
|
||||
header: 'Bobot Rata-Rata (Kg)',
|
||||
cell: (props) => formatNumber(props.row.original.average_weight_kg),
|
||||
},
|
||||
{
|
||||
accessorKey: 'total_weight_kg',
|
||||
accessorKey: 'total_weight',
|
||||
header: 'Bobot Total (Kg)',
|
||||
cell: (props) => formatNumber(props.row.original.total_weight_kg),
|
||||
footer: () => {
|
||||
@@ -132,12 +137,12 @@ const DailyMarketingsTable = ({
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: 'sales_price_per_kg',
|
||||
accessorKey: 'sales_price',
|
||||
header: 'Harga Jual (Rp)',
|
||||
cell: (props) => formatCurrency(props.row.original.sales_price_per_kg),
|
||||
},
|
||||
{
|
||||
accessorKey: 'hpp_price_per_kg',
|
||||
accessorKey: 'hpp_price',
|
||||
header: 'HPP (Rp)',
|
||||
cell: (props) => formatCurrency(props.row.original.hpp_price_per_kg),
|
||||
footer: () => {
|
||||
@@ -163,6 +168,8 @@ const DailyMarketingsTable = ({
|
||||
];
|
||||
|
||||
useEffect(() => {
|
||||
console.log({ sorting });
|
||||
|
||||
if (sorting.length === 1) {
|
||||
onFilterByChange(sorting[0].id);
|
||||
onSortByChange(sorting[0].desc ? 'desc' : 'asc');
|
||||
|
||||
@@ -457,3 +457,14 @@ export const MARKETING_TYPE_OPTIONS = [
|
||||
value: 'trading',
|
||||
},
|
||||
];
|
||||
|
||||
export const MARKETING_DATE_FILTER_TYPE_OPTIONS = [
|
||||
{
|
||||
label: 'Tanggal Realisasi',
|
||||
value: 'realization_date',
|
||||
},
|
||||
{
|
||||
label: 'Tanggal SO',
|
||||
value: 'so_date',
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user