add functionality and refactor the code

This commit is contained in:
2024-08-31 08:19:41 +00:00
parent 32d9bc96b5
commit be78e17fb9
7 changed files with 207 additions and 76 deletions

View File

@@ -2,11 +2,12 @@ import React from "react";
interface Props {
closeRemapFunction: () => void;
renameCallback: (file: any, newName: string) => void;
file: any;
}
const Rename = (props: Props) => {
const { closeRemapFunction, file } = props;
const { closeRemapFunction, file, renameCallback } = props;
const [newName, setNewName] = React.useState(file.attributes.name);
const handleKeyDown = (event: React.KeyboardEvent) => {
@@ -19,9 +20,9 @@ const Rename = (props: Props) => {
};
const handleRename = (event: React.MouseEvent) => {
// console.log("rename");
console.log("Renaming file:", file?.attributes.name, "to", newName);
console.log(file);
// use from parent function named putRenameFile
// renameFunction(file, newName);
renameCallback(file, newName);
};
const ref = React.useRef<HTMLDivElement>(null);