| 1 | account's node_id: 1 |
| 2 | |
| 3 | node_id: 1, value: {"widget":{"ProfileEditor":"const accountId = context.accountId; |
| 4 | |
| 5 | if (!accountId) { |
| 6 | return "Please sign in with NEAR wallet to edit your profile"; |
| 7 | } |
| 8 | |
| 9 | let profile = Social.getr(`${accountId}/profile`); |
| 10 | |
| 11 | if (profile === null) { |
| 12 | return "Loading"; |
| 13 | } |
| 14 | |
| 15 | initState({ |
| 16 | profile: profile ?? {}, |
| 17 | img: { cid: profile.image.ipfs_cid }, |
| 18 | }); |
| 19 | |
| 20 | profile = { |
| 21 | name: state.profile.name, |
| 22 | image: {}, |
| 23 | }; |
| 24 | |
| 25 | if (state.img.cid) { |
| 26 | profile.image.ipfs_cid = state.img.cid; |
| 27 | } else if (state.profile.image.url) { |
| 28 | profile.image.url = state.profile.image.url; |
| 29 | } |
| 30 | |
| 31 | return ( |
| 32 | <div className="container"> |
| 33 | <div className="row mb-3"> |
| 34 | <div> |
| 35 | <h4>Edit profile of @{accountId}</h4> |
| 36 | </div> |
| 37 | <div className="mb-2"> |
| 38 | Name: |
| 39 | <input type="text" value={state.profile.name} /> |
| 40 | </div> |
| 41 | <div className="mb-2"> |
| 42 | Picture: |
| 43 | <br /> |
| 44 | <IpfsImageUpload image={state.img} /> |
| 45 | </div> |
| 46 | {!state.img.cid && state.profile.image.url && ( |
| 47 | <div className="mb-2"> |
| 48 | Image URL: |
| 49 | <input type="text" value={state.profile.image.url} /> |
| 50 | </div> |
| 51 | )} |
| 52 | <div>Preview</div> |
| 53 | <div> |
| 54 | <Widget src="mob.near/widget/Profile" props={{ accountId, profile }} /> |
| 55 | </div> |
| 56 | <div className="mt-2"> |
| 57 | <CommitButton data={{ profile }}>Save profile</CommitButton> |
| 58 | <a |
| 59 | className="btn btn-outline-primary ms-2" |
| 60 | href={`#/mob.near/widget/Profile?accountId=${accountId}`} |
| 61 | > |
| 62 | View profile |
| 63 | </a> |
| 64 | </div> |
| 65 | </div> |
| 66 | </div> |
| 67 | ); |
| 68 | "}} |
| 69 | |
| 70 | node_id: 2, value: {"ProfileEditor":"const accountId = context.accountId; |
| 71 | |
| 72 | if (!accountId) { |
| 73 | return "Please sign in with NEAR wallet to edit your profile"; |
| 74 | } |
| 75 | |
| 76 | let profile = Social.getr(`${accountId}/profile`); |
| 77 | |
| 78 | if (profile === null) { |
| 79 | return "Loading"; |
| 80 | } |
| 81 | |
| 82 | initState({ |
| 83 | profile: profile ?? {}, |
| 84 | img: { cid: profile.image.ipfs_cid }, |
| 85 | }); |
| 86 | |
| 87 | profile = { |
| 88 | name: state.profile.name, |
| 89 | image: {}, |
| 90 | }; |
| 91 | |
| 92 | if (state.img.cid) { |
| 93 | profile.image.ipfs_cid = state.img.cid; |
| 94 | } else if (state.profile.image.url) { |
| 95 | profile.image.url = state.profile.image.url; |
| 96 | } |
| 97 | |
| 98 | return ( |
| 99 | <div className="container"> |
| 100 | <div className="row mb-3"> |
| 101 | <div> |
| 102 | <h4>Edit profile of @{accountId}</h4> |
| 103 | </div> |
| 104 | <div className="mb-2"> |
| 105 | Name: |
| 106 | <input type="text" value={state.profile.name} /> |
| 107 | </div> |
| 108 | <div className="mb-2"> |
| 109 | Picture: |
| 110 | <br /> |
| 111 | <IpfsImageUpload image={state.img} /> |
| 112 | </div> |
| 113 | {!state.img.cid && state.profile.image.url && ( |
| 114 | <div className="mb-2"> |
| 115 | Image URL: |
| 116 | <input type="text" value={state.profile.image.url} /> |
| 117 | </div> |
| 118 | )} |
| 119 | <div>Preview</div> |
| 120 | <div> |
| 121 | <Widget src="mob.near/widget/Profile" props={{ accountId, profile }} /> |
| 122 | </div> |
| 123 | <div className="mt-2"> |
| 124 | <CommitButton data={{ profile }}>Save profile</CommitButton> |
| 125 | <a |
| 126 | className="btn btn-outline-primary ms-2" |
| 127 | href={`#/mob.near/widget/Profile?accountId=${accountId}`} |
| 128 | > |
| 129 | View profile |
| 130 | </a> |
| 131 | </div> |
| 132 | </div> |
| 133 | </div> |
| 134 | ); |
| 135 | "} |