mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 15:25:46 +00:00
refactor(FE): Refactor Uniformity header and add filter badge
This commit is contained in:
@@ -101,7 +101,7 @@ const UniformityChart = ({
|
|||||||
const shouldShowEmptyState = !isFiltered;
|
const shouldShowEmptyState = !isFiltered;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className='w-full grid grid-cols-1 xl:grid-cols-2 2xl:grid-cols-4 gap-4'>
|
<section className='w-full grid grid-cols-1 xl:grid-cols-2 2xl:grid-cols-4 gap-3'>
|
||||||
<Card
|
<Card
|
||||||
title='Performance Overview ⓘ'
|
title='Performance Overview ⓘ'
|
||||||
variant='bordered'
|
variant='bordered'
|
||||||
|
|||||||
@@ -900,58 +900,149 @@ const UniformityTable = () => {
|
|||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// ===== CALCULATE FILTER COUNT =====
|
||||||
|
const filterCount = useMemo(() => {
|
||||||
|
let count = 0;
|
||||||
|
|
||||||
|
if (filterStartDate && filterEndDate) {
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filterLocation) {
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filterProjectFlock) {
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filterKandang) {
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}, [
|
||||||
|
filterStartDate,
|
||||||
|
filterEndDate,
|
||||||
|
filterLocation,
|
||||||
|
filterProjectFlock,
|
||||||
|
filterKandang,
|
||||||
|
]);
|
||||||
|
|
||||||
|
const isFilterActive = filterCount > 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<section className='[&_button]:w-full [&_button]:sm:w-fit [&_button]:last:mt-2 [&_button]:last:sm:mt-0 sm:flex sm:justify-between grid grid-cols-1 sm:gap-0 gap-2'>
|
<div className='@container w-full'>
|
||||||
<div className='w-full sm:w-fit flex flex-col sm:flex-row self-start gap-2'>
|
<div className='w-full p-3 flex flex-row justify-between gap-3 flex-wrap border-b border-base-content/10'>
|
||||||
<RequirePermission permissions='lti.production.uniformity.create'>
|
<div className='w-fit flex flex-row gap-3 flex-wrap'>
|
||||||
<Button color='primary' href='/production/uniformity/add'>
|
<RequirePermission permissions='lti.production.uniformity.create'>
|
||||||
<Icon icon='ic:round-plus' width={18} height={18} />
|
<Button
|
||||||
Add Uniformity
|
href='/production/uniformity/add'
|
||||||
</Button>
|
color='primary'
|
||||||
</RequirePermission>
|
className='px-3 py-2.5 w-fit text-sm text-base-100 rounded-lg shadow-sm'
|
||||||
</div>
|
>
|
||||||
|
<Icon icon='heroicons:plus' width={20} height={20} />
|
||||||
<div className='sm:flex gap-2'>
|
Add Uniformity
|
||||||
<Button variant='outline' onClick={filterModal.openModal}>
|
|
||||||
<Icon icon='heroicons:funnel' width={18} height={18} />
|
|
||||||
Filter
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Dropdown
|
|
||||||
trigger={
|
|
||||||
<Button variant='outline' isLoading={isAnyExportLoading}>
|
|
||||||
<Icon
|
|
||||||
icon='heroicons:cloud-arrow-down'
|
|
||||||
width={18}
|
|
||||||
height={18}
|
|
||||||
/>
|
|
||||||
Export
|
|
||||||
</Button>
|
</Button>
|
||||||
}
|
</RequirePermission>
|
||||||
align='end'
|
</div>
|
||||||
>
|
|
||||||
<Menu>
|
<div className='flex flex-1 flex-row justify-start sm:justify-end items-center gap-3 flex-wrap'>
|
||||||
<MenuItem title='Excel' onClick={handleExportExcel} />
|
<Button
|
||||||
<MenuItem title='PDF' onClick={handleExportPDF} />
|
variant='outline'
|
||||||
</Menu>
|
color='none'
|
||||||
</Dropdown>
|
onClick={filterModal.openModal}
|
||||||
|
className={cn(
|
||||||
|
'px-3 py-2.5 gap-1.5 text-sm text-base-content/50 border border-base-content/10 rounded-xl shadow-button-soft transition-all',
|
||||||
|
{
|
||||||
|
'border-primary-gradient text-primary': isFilterActive,
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Icon icon='heroicons:funnel' width={20} height={20} />
|
||||||
|
Filter
|
||||||
|
{isFilterActive && (
|
||||||
|
<Badge
|
||||||
|
className={{
|
||||||
|
badge:
|
||||||
|
'p-1.5 bg-[#FF3535] text-xs text-base-100 border border-base-300 rounded-lg',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{filterCount}
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Dropdown
|
||||||
|
align='end'
|
||||||
|
direction='bottom'
|
||||||
|
className={{
|
||||||
|
content:
|
||||||
|
'mt-1 rounded-xl border border-base-content/5 shadow-sm overflow-hidden',
|
||||||
|
}}
|
||||||
|
trigger={
|
||||||
|
<Button
|
||||||
|
variant='outline'
|
||||||
|
color='none'
|
||||||
|
className='px-3 py-2.5 text-sm text-base-content/50 border border-base-content/10 rounded-xl shadow-button-soft'
|
||||||
|
>
|
||||||
|
<div className='flex flex-row items-center gap-1.5'>
|
||||||
|
<Icon
|
||||||
|
icon='heroicons:cloud-arrow-down'
|
||||||
|
width={20}
|
||||||
|
height={20}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<span>Export</span>
|
||||||
|
|
||||||
|
<div className='w-px self-stretch bg-base-content/10' />
|
||||||
|
|
||||||
|
<Icon
|
||||||
|
icon='heroicons:chevron-down'
|
||||||
|
width={14}
|
||||||
|
height={14}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
variant='ghost'
|
||||||
|
color='none'
|
||||||
|
onClick={handleExportExcel}
|
||||||
|
isLoading={isExcelExportLoading}
|
||||||
|
className='w-full p-3 justify-start text-sm text-base-content/50 font-semibold text-nowrap'
|
||||||
|
>
|
||||||
|
<Icon icon='heroicons:table-cells' width={20} height={20} />
|
||||||
|
Export to Excel
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant='ghost'
|
||||||
|
color='none'
|
||||||
|
onClick={handleExportPDF}
|
||||||
|
isLoading={isPdfExportLoading}
|
||||||
|
className='w-full p-3 justify-start text-sm text-base-content/50 font-semibold text-nowrap hover:bg-base-content/5'
|
||||||
|
>
|
||||||
|
<Icon icon='heroicons:document-text' width={20} height={20} />
|
||||||
|
Export to PDF
|
||||||
|
</Button>
|
||||||
|
</Dropdown>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
|
||||||
|
|
||||||
<div className='my-4 divider'></div>
|
<section className='p-3'>
|
||||||
|
<UniformityChartWrapper
|
||||||
<section>
|
uniformitySwrKey={uniformitySwrKey}
|
||||||
<UniformityChartWrapper
|
isFiltered={isSubmitted}
|
||||||
uniformitySwrKey={uniformitySwrKey}
|
/>
|
||||||
isFiltered={isSubmitted}
|
</section>
|
||||||
/>
|
</div>
|
||||||
</section>
|
|
||||||
|
|
||||||
<Card
|
<Card
|
||||||
variant='bordered'
|
variant='bordered'
|
||||||
className={{
|
className={{
|
||||||
wrapper: 'my-4 w-full relative',
|
wrapper: 'w-full',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Table<Uniformity>
|
<Table<Uniformity>
|
||||||
|
|||||||
Reference in New Issue
Block a user