({
uploading,
user,
progress,
onChange,
}: Props)
| 15 | } |
| 16 | |
| 17 | export default function AvatarField({ |
| 18 | uploading, |
| 19 | user, |
| 20 | progress, |
| 21 | onChange, |
| 22 | }: Props) { |
| 23 | let ref = useRef<HTMLInputElement>(null); |
| 24 | const openFileDialog = () => { |
| 25 | if (ref.current) { |
| 26 | ref.current.value = ''; |
| 27 | ref.current?.click(); |
| 28 | } |
| 29 | }; |
| 30 | return ( |
| 31 | <Field> |
| 32 | <div className={styles.row}> |
| 33 | <Avatar src={user.profileImageUrl} text={user.displayName} size="xl" /> |
| 34 | <div> |
| 35 | <Button onClick={openFileDialog} disabled={uploading} color="gray"> |
| 36 | <FiUploadCloud />{' '} |
| 37 | {!uploading ? 'Change avatar' : `Uploading... ${progress}%`} |
| 38 | </Button> |
| 39 | <div className={styles.text}>JPG, GIF or PNG. 2MB max.</div> |
| 40 | </div> |
| 41 | </div> |
| 42 | <input |
| 43 | className={styles.input} |
| 44 | disabled={uploading} |
| 45 | type="file" |
| 46 | id="avatar" |
| 47 | accept=".jpg,.gif,.png" |
| 48 | name="avatar" |
| 49 | ref={ref} |
| 50 | onChange={onChange} |
| 51 | /> |
| 52 | </Field> |
| 53 | ); |
| 54 | } |
nothing calls this directly
no outgoing calls
no test coverage detected