generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature/CE-104 upload an attachment to an existing complaint (#210)
Co-authored-by: afwilcox <[email protected]>
- Loading branch information
Showing
18 changed files
with
617 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { FC, useRef } from "react"; | ||
import { BsPlus } from "react-icons/bs"; | ||
|
||
type Props = { | ||
onFileSelect: (selectedFile: FileList) => void; | ||
}; | ||
|
||
export const AttachmentUpload: FC<Props> = ({ | ||
onFileSelect, | ||
}) => { | ||
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
if (event.target.files) { | ||
onFileSelect(event.target.files); | ||
} | ||
}; | ||
|
||
// Without this, I'm unable to re-add the same file twice. | ||
const handleFileClick = () => { | ||
// Clear the current file input value | ||
if (fileInputRef.current) { | ||
fileInputRef.current.value = ""; | ||
} | ||
}; | ||
|
||
const fileInputRef = useRef<HTMLInputElement>(null); | ||
|
||
const handleDivClick = () => { | ||
fileInputRef.current?.click(); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<input | ||
type="file" | ||
multiple | ||
onChange={handleFileChange} | ||
onClick={handleFileClick} | ||
ref={fileInputRef} | ||
style={{ display: "none" }} | ||
/> | ||
<button | ||
className="coms-carousel-upload-container" | ||
tabIndex={0} | ||
onClick={handleDivClick} | ||
> | ||
<div className="upload-icon"> | ||
<BsPlus /> | ||
</div> | ||
<div className="upload-text">Upload</div> | ||
</button> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.