|
|
@ -1,6 +1,8 @@ |
|
|
|
import React, { useState, useMemo } from "react"; |
|
|
|
import React, { useState, useMemo } from "react"; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
|
|
|
|
|
|
|
|
//assets
|
|
|
|
//assets
|
|
|
|
|
|
|
|
import camera from "../../../../assets/icons/camera-white.svg"; |
|
|
|
|
|
|
|
|
|
|
|
const reader = new FileReader(); |
|
|
|
const reader = new FileReader(); |
|
|
|
function Upload({ name, value: initValue, onChange }) { |
|
|
|
function Upload({ name, value: initValue, onChange }) { |
|
|
@ -11,10 +13,13 @@ function Upload({ name, value: initValue, onChange }) { |
|
|
|
setSelected(null); |
|
|
|
setSelected(null); |
|
|
|
}, [initValue]); |
|
|
|
}, [initValue]); |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className="flex justify-center bg-surface rounded-full items-center overflow-hidden relative max-w-[100px] max-h-[100px] w-[100px] h-[100px]"> |
|
|
|
<div |
|
|
|
|
|
|
|
className="flex justify-center bg-green-400 rounded-full items-center overflow-hidden relative" |
|
|
|
|
|
|
|
style={{ width: 100, height: 100 }} |
|
|
|
|
|
|
|
> |
|
|
|
<div |
|
|
|
<div |
|
|
|
className={`h-full w-full rounded-full flex justify-center items-center ${ |
|
|
|
className={`h-full w-full rounded-full flex justify-center items-center ${ |
|
|
|
value ? "" : "bg-surface" |
|
|
|
value ? "" : "bg-green-400" |
|
|
|
}`}
|
|
|
|
}`}
|
|
|
|
> |
|
|
|
> |
|
|
|
<img |
|
|
|
<img |
|
|
@ -23,7 +28,7 @@ function Upload({ name, value: initValue, onChange }) { |
|
|
|
? value?.indexOf("data") > -1 |
|
|
|
? value?.indexOf("data") > -1 |
|
|
|
? value |
|
|
|
? value |
|
|
|
: "https://iranesch.com/api/v1/file/" + value |
|
|
|
: "https://iranesch.com/api/v1/file/" + value |
|
|
|
: "/icons/camera-white.svg" |
|
|
|
: camera |
|
|
|
} |
|
|
|
} |
|
|
|
alt="" |
|
|
|
alt="" |
|
|
|
className={`rounded-full ${ |
|
|
|
className={`rounded-full ${ |
|
|
@ -32,8 +37,8 @@ function Upload({ name, value: initValue, onChange }) { |
|
|
|
/> |
|
|
|
/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
{value && ( |
|
|
|
{value && ( |
|
|
|
<div className="rounded-full flex justify-center bg-surface items-center absolute right-0 bottom-0 w-7 h-7 z-20"> |
|
|
|
<div className="rounded-full flex justify-center bg-surface items-center absolute left-1/2 top-1/2 transform -translate-x-1/2 -translate-y-1/2 w-7 h-7 z-20"> |
|
|
|
<img src={"/icons/camera-white.svg"} alt="camera" className="w-2/3" /> |
|
|
|
<img src={camera} alt="camera" className="w-2/3" /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
)} |
|
|
|
)} |
|
|
|
<input |
|
|
|
<input |
|
|
@ -49,7 +54,6 @@ function Upload({ name, value: initValue, onChange }) { |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => ({ |
|
|
|
const mapStateToProps = (state) => ({}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps)(Upload); |
|
|
|
export default connect(mapStateToProps)(Upload); |
|
|
|