mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 15:25:46 +00:00
feat(FE-316): Add tooltip and remove control to file upload
This commit is contained in:
@@ -43,6 +43,7 @@ import UniformityResultForm from '@/components/pages/uniformity/form/UniformityR
|
|||||||
import { generateUniformityTemplate } from '@/components/pages/uniformity/export/UniformityTemplate';
|
import { generateUniformityTemplate } from '@/components/pages/uniformity/export/UniformityTemplate';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
import { cn, formatNumber } from '@/lib/helper';
|
import { cn, formatNumber } from '@/lib/helper';
|
||||||
|
import Tooltip from '@/components/Tooltip';
|
||||||
|
|
||||||
interface UniformityFormProps {
|
interface UniformityFormProps {
|
||||||
formType?: 'add' | 'edit';
|
formType?: 'add' | 'edit';
|
||||||
@@ -364,7 +365,10 @@ const UniformityForm = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const handleRemoveFile = useCallback(() => {
|
const handleRemoveFile = useCallback(() => {
|
||||||
formik.setFieldValue('files', undefined);
|
formik.setFieldValue('file', undefined);
|
||||||
|
if (fileInputRef.current) {
|
||||||
|
fileInputRef.current.value = '';
|
||||||
|
}
|
||||||
}, [formik]);
|
}, [formik]);
|
||||||
|
|
||||||
const handleDownloadTemplate = useCallback(() => {
|
const handleDownloadTemplate = useCallback(() => {
|
||||||
@@ -521,15 +525,45 @@ const UniformityForm = ({
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label
|
<div className='flex items-center justify-between'>
|
||||||
htmlFor='file-upload-input'
|
<label
|
||||||
className={cn(
|
htmlFor='file-upload-input'
|
||||||
"w-full text-sm font-normal leading-5 after:content-['*'] after:ml-0.5 after:text-red-500",
|
className={cn(
|
||||||
formik.touched.file && formik.errors.file && 'text-red-500'
|
"w-full text-sm font-normal leading-5 after:content-['*'] after:ml-0.5 after:text-red-500",
|
||||||
)}
|
formik.touched.file && formik.errors.file && 'text-red-500'
|
||||||
>
|
)}
|
||||||
Upload File
|
>
|
||||||
</label>
|
Upload File
|
||||||
|
</label>
|
||||||
|
{formik.values.file && !isNextStep ? (
|
||||||
|
<button
|
||||||
|
onClick={handleRemoveFile}
|
||||||
|
className='cursor-pointer'
|
||||||
|
type='button'
|
||||||
|
>
|
||||||
|
<Icon
|
||||||
|
icon='heroicons-solid:trash'
|
||||||
|
width={20}
|
||||||
|
height={20}
|
||||||
|
className='text-gray-400 hover:text-gray-600'
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
) : !formik.values.file && !isNextStep ? (
|
||||||
|
<button className='cursor-pointer' type='button'>
|
||||||
|
<Tooltip
|
||||||
|
position='left'
|
||||||
|
content='Pastikan file yang diunggah sesuai dengan template yang disediakan, template akan menyesuaikan dengan jumlah populasi pada kandang yang dipilih.'
|
||||||
|
>
|
||||||
|
<Icon
|
||||||
|
icon='heroicons:information-circle'
|
||||||
|
width={20}
|
||||||
|
height={20}
|
||||||
|
className='text-gray-400 hover:text-gray-600'
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
</button>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
|
||||||
<section
|
<section
|
||||||
className={cn(
|
className={cn(
|
||||||
|
|||||||
Reference in New Issue
Block a user