Skip to content

OBPIH-6396 Full Outbound Import - Reusable file select field (frontend)#4646

Merged
awalkowiak merged 3 commits intodevelopfrom
OBPIH-6396
Jun 4, 2024
Merged

OBPIH-6396 Full Outbound Import - Reusable file select field (frontend)#4646
awalkowiak merged 3 commits intodevelopfrom
OBPIH-6396

Conversation

@alannadolny
Copy link
Collaborator

No description provided.

Copy link
Collaborator

@awalkowiak awalkowiak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I think it looks good to me, I am just a bit worried about the previous styling (for example looks like dropzone on the import location might lost its styling). If everything looks and works as before then I'm fine with it.

Copy link
Collaborator

@kchelstowski kchelstowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My question would be if you checked the compatibility of the FileSelect you've implemented with both: react-hook-form and zod and if so, if there are any obstacles we need to know before trying to use one in the upcoming tickets?


const validateFileType = (file) => {
if (!allowedExtensions.length || allowedExtensions.includes(getFileExtension(file))) {
return null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for clarity of validation methods we used to have, this should eventually return true if the validation passes, which I think it does in this case if I understand it correctly:
"If we don't have any allowed extensions specified or the file extension is in the allowed ones, the validation should pass (currently returning null)"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The null is required by the react-dropzone. Basically, this validation blocks you from uploading files with the wrong extensions.

onDrop,
noClick: true,
noKeyboard: true,
validator: validateFileType,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but I guess this hook from the library expects to return a falsy value if the validation passes, hence my previous comment doesn't make sense, since we are not able to adjust that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the validation for our libraries, I answered it in the comment above. I tested it with our libraries and it is working fine. In case someone has some problems with adjusting it, it can also be done by the workaround by passing the setValue function.

Comment on lines +60 to +72
{data.path}
{' '}
(
{data.size}
{' '}
bytes)
{file?.errors?.length ? (
<ul>
{file.errors.map((e) => (
<li key={e.code}>{e.message}</li>
))}
</ul>
) : null}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would maybe do something like:

Suggested change
{data.path}
{' '}
(
{data.size}
{' '}
bytes)
{file?.errors?.length ? (
<ul>
{file.errors.map((e) => (
<li key={e.code}>{e.message}</li>
))}
</ul>
) : null}
<div>
<span className="mx-1" >{data.path}<span>
<span className="mx-1" >({data.size})<span>
</div>
{!!file?.errors?.length ? (
<ul>
{file.errors.map((e) => (
<li key={e.code}>{e.message}</li>
))}
</ul>
) }

But current solution is fine

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drodzewicz I think you skipped the fallback (:), or you meant to do it via &&. Honestly I'd avoid double negation, since it is usually confusing.
I would prefer Alan's version.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, Idc

@awalkowiak awalkowiak merged commit 6e2065d into develop Jun 4, 2024
@awalkowiak awalkowiak deleted the OBPIH-6396 branch June 4, 2024 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants