mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 05:22:02 +00:00
70 lines
1.5 KiB
TypeScript
70 lines
1.5 KiB
TypeScript
'use client';
|
|
|
|
import { ChangeEventHandler, useId, useState } from 'react';
|
|
|
|
import ConfirmationModal, {
|
|
ConfirmationModalProps,
|
|
} from '@/components/modal/ConfirmationModal';
|
|
import TextArea from '@/components/input/TextArea';
|
|
|
|
import { Color } from '@/types/theme';
|
|
|
|
interface ConfirmationModalWithNotesProps
|
|
extends Omit<ConfirmationModalProps, 'children' | 'primaryButton'> {
|
|
rows?: number;
|
|
placeholder?: string;
|
|
|
|
primaryButton?: {
|
|
text?: string;
|
|
color?: Color;
|
|
isLoading?: boolean;
|
|
onClick?: (notes: string) => void;
|
|
};
|
|
}
|
|
|
|
const ConfirmationModalWithNotes: React.FC<ConfirmationModalWithNotesProps> = ({
|
|
ref,
|
|
type = 'info',
|
|
text,
|
|
closeOnBackdrop,
|
|
primaryButton,
|
|
secondaryButton,
|
|
className,
|
|
rows = 3,
|
|
placeholder = 'Catatan...',
|
|
}) => {
|
|
const randomId = useId();
|
|
const [notes, setNotes] = useState('');
|
|
|
|
const notesChangeHandler: ChangeEventHandler<HTMLTextAreaElement> = (e) => {
|
|
setNotes(e.target.value);
|
|
};
|
|
|
|
return (
|
|
<ConfirmationModal
|
|
ref={ref}
|
|
type={type}
|
|
text={text}
|
|
closeOnBackdrop={closeOnBackdrop}
|
|
primaryButton={{
|
|
...primaryButton,
|
|
onClick: () => {
|
|
primaryButton?.onClick?.(notes);
|
|
},
|
|
}}
|
|
secondaryButton={secondaryButton}
|
|
className={className}
|
|
>
|
|
<TextArea
|
|
name={randomId}
|
|
placeholder={placeholder}
|
|
value={notes}
|
|
onChange={notesChangeHandler}
|
|
rows={rows}
|
|
/>
|
|
</ConfirmationModal>
|
|
);
|
|
};
|
|
|
|
export default ConfirmationModalWithNotes;
|