Rename function and variable

This commit is contained in:
Leonardo Murça 2022-11-22 15:03:31 -03:00
parent 124ec2d80b
commit 4a9bddd767
2 changed files with 7 additions and 7 deletions

View file

@ -3,18 +3,18 @@
import Dropzone from "./Dropzone.svelte"; import Dropzone from "./Dropzone.svelte";
import FileList from "./FileList.svelte"; import FileList from "./FileList.svelte";
import { filterFileRequirements } from "../utils/filterFileRequirements"; import { filterFiles } from "../utils/filterFiles";
let acceptedFiles; let acceptedFiles;
let rejectedFiles; let rejectedFiles;
let isAcceptedFilesRendered = false; let areAcceptedFilesRendered = false;
const fileRequirements = { const fileRequirements = {
supportedFormats: [".pes"], supportedFormats: [".pes"],
maxSize: 700000, maxSize: 700000,
}; };
const onSubmit = () => { const onSubmit = () => {
isAcceptedFilesRendered = true; areAcceptedFilesRendered = true;
}; };
const onDrop = (evt) => { const onDrop = (evt) => {
@ -23,13 +23,13 @@
const onChange = (evt) => { const onChange = (evt) => {
acceptedFiles = null; acceptedFiles = null;
isAcceptedFilesRendered = false; areAcceptedFilesRendered = false;
const changedFiles = evt.dataTransfer const changedFiles = evt.dataTransfer
? evt.dataTransfer.files ? evt.dataTransfer.files
: evt.target.files; : evt.target.files;
const results = filterFileRequirements(changedFiles, fileRequirements); const results = filterFiles(changedFiles, fileRequirements);
acceptedFiles = results.accepted; acceptedFiles = results.accepted;
rejectedFiles = results.rejected; rejectedFiles = results.rejected;
}; };
@ -69,7 +69,7 @@
<input type="submit" value="Render files" /> <input type="submit" value="Render files" />
</form> </form>
{#if isAcceptedFilesRendered} {#if areAcceptedFilesRendered}
<CardList files={acceptedFiles} /> <CardList files={acceptedFiles} />
{:else} {:else}
<FileList title="Rejected Files" files={rejectedFiles} isError /> <FileList title="Rejected Files" files={rejectedFiles} isError />

View file

@ -5,7 +5,7 @@ const areRequirementsFulfilled = (requirements, file) =>
requirements.maxSize >= file.size && requirements.maxSize >= file.size &&
requirements.supportedFormats.includes(formattedFilenameExt(file.name)); requirements.supportedFormats.includes(formattedFilenameExt(file.name));
export function filterFileRequirements(files, requirements) { export function filterFiles(files, requirements) {
let accepted = []; let accepted = [];
let rejected = []; let rejected = [];
Array.from(files).forEach((file) => { Array.from(files).forEach((file) => {