Skip to content

Commit 45b3e73

Browse files
make changes UI in file upload
1 parent 5ce50db commit 45b3e73

File tree

2 files changed

+45
-53
lines changed

2 files changed

+45
-53
lines changed

apps/OpenSign/src/components/fields/DropboxChoose.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ export default function DropboxChooser({ children, onSuccess, onCancel }) {
5050
return (
5151
<div onClick={handleChoose}>
5252
{children || (
53-
<button className="px-2 py-2 rounded border-[1px] text-blue-400 border-gray-300 w-full">
54-
<i className="fa-brands fa-dropbox"></i> Choose from Dropbox
53+
<button className="px-2 py-[2px] text-2xl rounded border-[1px] text-blue-400 border-gray-300 w-full">
54+
<i className="fa-brands fa-dropbox"></i>
5555
</button>
5656
)}
5757
</div>

apps/OpenSign/src/components/fields/FileUpload.js

Lines changed: 43 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ const FileUpload = (props) => {
88
const [parseAppId] = useState(localStorage.getItem("parseAppId"));
99
const [_fileupload, setFileUpload] = useState("");
1010
const [fileload, setfileload] = useState(false);
11-
12-
const [localValue, setLocalValue] = useState("");
1311
const [Message] = useState(false);
1412
const [percentage, setpercentage] = useState(0);
1513

@@ -25,7 +23,6 @@ const FileUpload = (props) => {
2523
const onChange = (e) => {
2624
try {
2725
let files = e.target.files;
28-
setLocalValue(e.target.files);
2926
if (typeof files[0] !== "undefined") {
3027
if (props.schema.filetypes && props.schema.filetypes.length > 0) {
3128
var fileName = files[0].name;
@@ -257,58 +254,53 @@ const FileUpload = (props) => {
257254
</div>
258255

259256
<>
260-
{localValue ? (
261-
<input
262-
type="file"
263-
id="hashfile"
264-
style={{
265-
border: "1px solid #ccc",
266-
color: "gray",
267-
backgroundColor: "white",
268-
padding: "5px 10px",
269-
borderRadius: "4px",
270-
fontSize: "13px",
271-
width: "100%",
272-
fontWeight: "bold"
273-
}}
274-
accept="application/pdf,application/vnd.ms-excel"
275-
onChange={onChange}
276-
/>
277-
) : props.formData ? (
278-
<div
279-
style={{
280-
border: "1px solid #ccc",
281-
color: "gray",
282-
backgroundColor: "white",
283-
padding: "5px 10px",
284-
borderRadius: "4px",
285-
fontSize: "13px",
286-
width: "100%",
287-
fontWeight: "bold"
288-
}}
289-
>
290-
file selected : {props.formData.split("/")[3]}
257+
{props.formData ? (
258+
<div className="flex gap-2 justify-center items-center">
259+
<div className="flex justify-between items-center px-2 py-[6px] w-full font-bold rounded border-[1px] border-[#ccc] text-gray-500 bg-white text-[13px]">
260+
<div className="break-all">
261+
file selected : {props.formData.split("/")[3]}
262+
</div>
263+
<div
264+
onClick={() => {
265+
console.log("clicked");
266+
setFileUpload([]);
267+
props.onChange(undefined);
268+
}}
269+
className="cursor-pointer px-[10px] text-base font-bold bg-white"
270+
>
271+
X
272+
</div>
273+
</div>
274+
<DropboxChooser
275+
onSuccess={dropboxSuccess}
276+
onCancel={dropboxCancel}
277+
/>
291278
</div>
292279
) : (
293-
<input
294-
type="file"
295-
id="hashfile"
296-
style={{
297-
border: "1px solid #ccc",
298-
color: "gray",
299-
backgroundColor: "white",
300-
padding: "5px 10px",
301-
borderRadius: "4px",
302-
fontSize: "13px",
303-
width: "100%",
304-
fontWeight: "bold"
305-
}}
306-
accept="application/pdf,application/vnd.ms-excel"
307-
onChange={onChange}
308-
/>
280+
<div className="flex gap-2 justify-center items-center">
281+
<input
282+
type="file"
283+
id="hashfile"
284+
style={{
285+
border: "1px solid #ccc",
286+
color: "gray",
287+
backgroundColor: "white",
288+
padding: "5px 10px",
289+
borderRadius: "4px",
290+
fontSize: "13px",
291+
width: "100%",
292+
fontWeight: "bold"
293+
}}
294+
accept="application/pdf,application/vnd.ms-excel"
295+
onChange={onChange}
296+
/>
297+
<DropboxChooser
298+
onSuccess={dropboxSuccess}
299+
onCancel={dropboxCancel}
300+
/>
301+
</div>
309302
)}
310303
</>
311-
<DropboxChooser onSuccess={dropboxSuccess} onCancel={dropboxCancel} />
312304
</React.Fragment>
313305
);
314306
};

0 commit comments

Comments
 (0)