76 lines
2.1 KiB
TypeScript
76 lines
2.1 KiB
TypeScript
// import { ISlider } from '@/types/IArticle';
|
|
// import { Icon } from '@/ui/Icon';
|
|
// import { reorderFields } from '@/utils/reorderFields';
|
|
// import { Reorder } from 'framer-motion';
|
|
// import { SyntheticEvent } from 'react';
|
|
// import {
|
|
// Control,
|
|
// useFieldArray,
|
|
// UseFieldArrayRemove,
|
|
// UseFormSetValue,
|
|
// } from 'react-hook-form';
|
|
// import { IArticleFormInput } from '../modals/ArticleFormModal';
|
|
// import { ArticleSliderImageInput } from './ArticleSliderImageInput';
|
|
|
|
// interface IArticleSliderInputProps {
|
|
// setValue: UseFormSetValue<IArticleFormInput>;
|
|
// item: ISlider & Record<'id', string>;
|
|
// index: number;
|
|
// control: Control<IArticleFormInput, any>;
|
|
// remove: UseFieldArrayRemove;
|
|
// }
|
|
|
|
// export function ArticleSliderInput({
|
|
// index,
|
|
// item,
|
|
// setValue,
|
|
// control,
|
|
// remove: removeSlider,
|
|
// }: IArticleSliderInputProps) {
|
|
// const { swap, append, remove, fields } = useFieldArray({
|
|
// control,
|
|
// name: `blocks.${index}.images`,
|
|
// });
|
|
|
|
// function handleAddSlide(e: SyntheticEvent) {
|
|
// e.preventDefault();
|
|
// append({ img: '' });
|
|
// }
|
|
|
|
// function handleRemoveSlider(e: SyntheticEvent) {
|
|
// e.preventDefault();
|
|
// removeSlider(index);
|
|
// }
|
|
|
|
// return (
|
|
// <Reorder.Item
|
|
// value={item}
|
|
// as="div"
|
|
// className="border border-[#3D425C] rounded-3xl p-4 col-span-full space-y-4"
|
|
// >
|
|
// <div className="flex gap-x-4 justify-center">
|
|
// <button onClick={handleAddSlide}>
|
|
// <Icon name="add" color="white" />
|
|
// </button>
|
|
// <button onClick={handleRemoveSlider}>
|
|
// <Icon name="trash" color="white" />
|
|
// </button>
|
|
// </div>
|
|
// <Reorder.Group
|
|
// as="div"
|
|
// axis="x"
|
|
// values={fields}
|
|
// onReorder={reorderFields(fields, swap)}
|
|
// className="flex gap-4 flex-wrap"
|
|
// >
|
|
// {fields.map((item, imgIndex) => (
|
|
// <ArticleSliderImageInput
|
|
// key={item.id}
|
|
// {...{ imgIndex, item, setValue, remove, index }}
|
|
// />
|
|
// ))}
|
|
// </Reorder.Group>
|
|
// </Reorder.Item>
|
|
// );
|
|
// }
|