-
+
+ console.log('icon click')} />
+
}
+
+export function ImageUpload ({ children, className, onSelect, onSuccess }) {
+ const ref = useRef()
+ const toaster = useToast()
+
+ return (
+ <>
+ {
+ if (e.target.files.length === 0) {
+ return
+ }
+ const file = e.target.files[0]
+ if (UPLOAD_TYPES_ALLOW.indexOf(file.type) === -1) {
+ toaster.danger(`image must be ${UPLOAD_TYPES_ALLOW.map(t => t.replace('image/', '')).join(', ')}`)
+ return
+ }
+ onSelect?.(file)
+ // TODO find out if this is needed and if so, why (copied from components/upload.js)
+ e.target.value = null
+ }}
+ />
+ ref.current?.click()} style={{ cursor: 'pointer' }}>
+ {children}
+
+ >
+ )
+}