Skip to content

Commit

Permalink
added check to restrict creation of files with same name inside same …
Browse files Browse the repository at this point in the history
…folder
  • Loading branch information
Nick-h4ck3r committed Nov 3, 2023
1 parent 6a4c28a commit e0d6934
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,17 @@ const CollectionMenu = ({

const existingFolders = useExplorerStore.getState().explorer.folders;
const parentFolderId = folderId || collectionId;
// console.log(parentFolderId, "parentfolderid")
const isDuplicateName = existingFolders.some(
(folder) =>
// console.log(`folder name ${folder.name} and folder parent id ${folder.__ref.collectionId}`),

(folder) =>
folder.name === val && folder.__ref.collectionId === parentFolderId
);
);

if (isDuplicateName) {
return {
isValid: false,
message: 'A folder with the same name already exists in this location.',
};
}
if (isDuplicateName) {
return {
isValid: false,
message: 'A folder with the same name already exists in this location.',
};
}
return {
isValid,
message:
Expand Down

0 comments on commit e0d6934

Please sign in to comment.