Skip to content

Commit

Permalink
test Files component
Browse files Browse the repository at this point in the history
  • Loading branch information
wpdas committed Jul 30, 2024
1 parent f10638e commit e335fbc
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions src/pages/CreateProject/components/Profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Button from "@app/components/Button";
import Image from "@app/components/mob.near/Image";
import constants from "@app/constants";
import uploadFileUpdateState from "../../utils/uploadFileUpdateState";
import { Container, BackgroundImage, ProfileImage } from "./styles";
import { Container, BackgroundImage, ProfileImage, FileLabel } from "./styles";

const Profile = () => {
const { IPFS_BASE_URL } = constants;
Expand All @@ -14,14 +14,29 @@ const Profile = () => {
const fallbackImg = "bafkreidsqk5rg6mdcdrfpedadeqejfwlfan75tjrybxu6cnlwzs4qizjdq";

const handleBgChange = (files: any) => {
console.log("Files:", files);

if (files) {
uploadFileUpdateState(files[0], (res: any) => {
const ipfs_cid = res.body.cid;
console.log("PIFS:", ipfs_cid);
State.update({ backgroundImage: { ipfs_cid } });
});
}
};

// const handleBgChange = (files: any) => {
// console.log("Files:", files);

// if (files) {
// // uploadFileUpdateState(files[0], (res: any) => {
// // const ipfs_cid = res.body.cid;
// // console.log("PIFS:", ipfs_cid);
// // State.update({ backgroundImage: { ipfs_cid } });
// // });
// }
// };

const handleImgChange = (files: any) => {
if (files) {
uploadFileUpdateState(files[0], (res: any) => {
Expand All @@ -43,7 +58,7 @@ const Profile = () => {
accepts={["image/*"]}
minFileSize={1}
style={{
zIndex: 1,
// zIndex: 1,
top: 0,
width: "100%",
height: "100%",
Expand All @@ -53,6 +68,22 @@ const Profile = () => {
onChange={handleBgChange}
/>
</Button>
<Files
multiple={false}
accepts={["image/*"]}
minFileSize={1}
className="btn btn-outline-primary"
style={{
top: 0,
width: "100%",
height: "100%",
position: "absolute",
}}
clickable
onChange={handleBgChange}
>
Upload BG Test
</Files>
</BackgroundImage>
<ProfileImage>
<Image className="profile-image" image={profileImage} fallbackUrl={IPFS_BASE_URL + fallbackImg} />
Expand Down

0 comments on commit e335fbc

Please sign in to comment.