mirror of
https://git.um-react.app/um/um-react.git
synced 2025-11-28 03:23:02 +00:00
feat: allow user to remove entry from the page
This commit is contained in:
@@ -13,8 +13,9 @@ import {
|
||||
Wrap,
|
||||
WrapItem,
|
||||
} from '@chakra-ui/react';
|
||||
import { DecryptedAudioFile, ProcessState } from './fileListingSlice';
|
||||
import { DecryptedAudioFile, ProcessState, deleteFile } from './fileListingSlice';
|
||||
import { useRef } from 'react';
|
||||
import { useAppDispatch } from '~/hooks';
|
||||
|
||||
interface FileRowProps {
|
||||
id: string;
|
||||
@@ -22,6 +23,7 @@ interface FileRowProps {
|
||||
}
|
||||
|
||||
export function FileRow({ id, file }: FileRowProps) {
|
||||
const dispatch = useAppDispatch();
|
||||
const isDecrypted = file.state === ProcessState.COMPLETE;
|
||||
|
||||
const nameWithoutExt = file.fileName.replace(/\.[a-z\d]{3,6}$/, '');
|
||||
@@ -41,6 +43,10 @@ export function FileRow({ id, file }: FileRowProps) {
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteRow = () => {
|
||||
dispatch(deleteFile({ id }));
|
||||
};
|
||||
|
||||
return (
|
||||
<Card w="full">
|
||||
<CardBody>
|
||||
@@ -107,7 +113,7 @@ export function FileRow({ id, file }: FileRowProps) {
|
||||
)}
|
||||
</WrapItem>
|
||||
<WrapItem>
|
||||
<Button type="button" onClick={() => alert('todo')}>
|
||||
<Button type="button" onClick={handleDeleteRow}>
|
||||
删除
|
||||
</Button>
|
||||
</WrapItem>
|
||||
|
||||
Reference in New Issue
Block a user