feat(FE-62): add button for document path in MovementForm with link functionality

This commit is contained in:
rstubryan
2025-10-20 15:23:18 +07:00
parent f27e34128e
commit c3338d3e05
2 changed files with 27 additions and 10 deletions
+6 -2
View File
@@ -1,7 +1,5 @@
import react from 'react'; import react from 'react';
import Link from 'next/link'; import Link from 'next/link';
import { cn } from '@/lib/helper'; import { cn } from '@/lib/helper';
import { Color } from '@/types/theme'; import { Color } from '@/types/theme';
@@ -10,6 +8,8 @@ interface ButtonProps extends react.ComponentProps<'button'> {
color?: Color; color?: Color;
href?: string; href?: string;
isLoading?: boolean; isLoading?: boolean;
target?: string;
rel?: string;
} }
const Button = ({ const Button = ({
@@ -22,6 +22,8 @@ const Button = ({
className, className,
disabled, disabled,
onClick, onClick,
target,
rel,
...props ...props
}: ButtonProps) => { }: ButtonProps) => {
const btnBaseClassName = cn( const btnBaseClassName = cn(
@@ -68,6 +70,8 @@ const Button = ({
{href && ( {href && (
<Link <Link
href={disabled ? '#' : href} href={disabled ? '#' : href}
target={target}
rel={rel}
aria-disabled={disabled} aria-disabled={disabled}
className={cn( className={cn(
btnBaseClassName, btnBaseClassName,
@@ -1163,14 +1163,27 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
</td> </td>
<td> <td>
{type === 'detail' ? ( {type === 'detail' ? (
<TextInput <Button
readOnly color='primary'
value={delivery.document_path || '-'} className='w-full min-w-52 flex items-center justify-center gap-2'
className={{ disabled={!delivery.document_path}
wrapper: 'w-full min-w-52 md:w-72 lg:w-80', href={delivery.document_path ?? undefined}
}} target='_blank'
name={`deliveries.${idx}.document_path`} rel='noopener noreferrer'
/> >
{delivery.document_path ? (
<>
<Icon
icon='material-symbols:file-open-outline'
width={20}
height={20}
/>
Lihat Dokumen
</>
) : (
'-'
)}
</Button>
) : ( ) : (
<FileInput <FileInput
name={`deliveries.${idx}.document`} name={`deliveries.${idx}.document`}