diff --git a/apps/potlock/widget/Profile/BannerHeader.jsx b/apps/potlock/widget/Profile/BannerHeader.jsx index 539b2f5..a6268aa 100644 --- a/apps/potlock/widget/Profile/BannerHeader.jsx +++ b/apps/potlock/widget/Profile/BannerHeader.jsx @@ -10,6 +10,14 @@ const editable = props.bgImageOnChange && props.profileImageOnChange; const profile = props.profile ?? Social.getr(`${accountId}/profile`); +const uploadFileUpdateState = (body, callback) => { + asyncFetch("https://ipfs.near.social/add", { + method: "POST", + headers: { Accept: "application/json" }, + body, + }).then(callback); +}; + // Loading Skeleton const loadingSkeleton = styled.keyframes` 0% { @@ -77,12 +85,15 @@ if (profile === null) { const name = profile.name || "No-name profile"; const image = profile.image; -const backgroundImage = props.backgroundImage || profile.backgroundImage; -const profileImage = props.profileImage || image; const imageStyle = props.imageStyle ?? {}; const backgroundStyle = props.backgroundStyle ?? {}; const containerStyle = props.containerStyle ?? {}; +State.init({ + profileImage: props.profileImage || profile.image, + backgroundImage: props.backgroundImage || profile.backgroundImage, +}); + const statuses = { Approved: { icon: ( @@ -394,8 +405,28 @@ const CameraSvg = ({ height }) => ( ); -return ( - +const Avatar = ({ imageStyle, profileImage }) => { + return ( + + + + + ); +}; + +const BackgroundImage = ({ backgroundImage, backgroundStyle }) => { + return ( - {editable && ( + + ); +}; + +return ( + + {editable ? ( + { + if (files) { + uploadFileUpdateState(files[0], (res) => { + const ipfs_cid = res.body.cid; + State.update({ backgroundImage: { ipfs_cid } }); + props.bgImageOnChange({ ipfs_cid }); + }); + } + }} + > + + + ) : ( + + )} + + {editable ? ( - )} - - - - - { + if (files) { + uploadFileUpdateState(files[0], (res) => { + const ipfs_cid = res.body.cid; + State.update({ profileImage: { ipfs_cid } }); + console.log("ipfs_cid: ", ipfs_cid); + props.profileImageOnChange({ ipfs_cid }); + }); + } }} - /> - - {editable && ( - - )} - + > + + + ) : ( + + )} {ShowFollowers && ( {tab === "profile" && nadaBotVerified ? ( diff --git a/apps/potlock/widget/Project/CreateForm.jsx b/apps/potlock/widget/Project/CreateForm.jsx index 0fcbea9..22f791a 100644 --- a/apps/potlock/widget/Project/CreateForm.jsx +++ b/apps/potlock/widget/Project/CreateForm.jsx @@ -954,18 +954,6 @@ if (props.edit && !userHasPermissions) { return

Unauthorized

; } -const uploadFileUpdateState = (body, callback) => { - asyncFetch("https://ipfs.near.social/add", { - method: "POST", - headers: { Accept: "application/json" }, - body, - }).then(callback); -}; - -// console.log("state in create form: ", state); - -console.log(state.fundingSources); - return ( {!state.socialDataFetched || !registrations ? ( @@ -1038,21 +1026,11 @@ return ( // allowEdit: true, backgroundImage: state.backgroundImage, profileImage: state.profileImage, - bgImageOnChange: (files) => { - if (files) { - uploadFileUpdateState(files[0], (res) => { - const ipfs_cid = res.body.cid; - State.update({ backgroundImage: { ipfs_cid } }); - }); - } + bgImageOnChange: (img) => { + State.update({ backgroundImage: img }); }, - profileImageOnChange: (files) => { - if (files) { - uploadFileUpdateState(files[0], (res) => { - const ipfs_cid = res.body.cid; - State.update({ profileImage: { ipfs_cid } }); - }); - } + profileImageOnChange: (img) => { + State.update({ profileImage: img }); }, children: (