Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add profile image #139

Merged
merged 6 commits into from
Dec 8, 2021
Merged

add profile image #139

merged 6 commits into from
Dec 8, 2021

Conversation

diegoalzate
Copy link
Contributor

Overview

This PR adds an upload profile image functionality to the create-profile page
ISSUE

In order to create this i installed the following packages:

  • web3.storage

How the AddAvatar component works

Firstly, i checked the supabase client and hooks were being created, very cool btw. So i followed that arcihtecture and stored the web3StorageClient in the common folder

import { Web3Storage } from 'web3.storage';

export const makeStorageClient = () => {
  return new Web3Storage({ token: process.env.WEB3STORAGE_TOKEN ?? '' });
};

note: this whole functionality requires a web3Storage token to be added to doppler, as of right now this token is associated to my account, ill leave this up to you guys @carlomigueldy @angeljgomezc @Dhaiwat10

AddAvatarComponent

This component recieves a src as a prop which will be the image that is rendered initially.

  • In this component we switch from a Image to Div with a background image using the state variable hoverImage.
  • The variable hoverImage changes with the toggleHover function that is triggered by the events onMouseLeave while it is a div with a background image and onMouseEnter while it is just an image component, in order to show a button while mouse is over the image and remove it when it is no longer there.
  • In order to upload the image we use the function submitProfilePicture, this function shows what we send to web3Storage and what they return, i added a todo so the result is updated in db

@diegoalzate diegoalzate self-assigned this Dec 7, 2021
@vercel
Copy link

vercel bot commented Dec 7, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/developdao/dao-job-board/5ytcsqcrxCAtx2kwHbJHr7kGVKGK
✅ Preview: https://dao-job-board-git-feature-add-profile-image-developdao.vercel.app

@carlomigueldy
Copy link
Contributor

@allcontributors please add @diegoalzate for code

@allcontributors
Copy link
Contributor

@carlomigueldy

I've put up a pull request to add @diegoalzate! 🎉

Copy link
Contributor

@carlomigueldy carlomigueldy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall thank you @diegoalzate 🎉

I've requested some minor changes. But I also noticed that yarn.lock was removed and package-lock.json is added, I am not entirely sure if this is a problem but would like to request your review 👀 on this PR @with-heart @Dhaiwat10

client/pages/create-profile/add-avatar.tsx Outdated Show resolved Hide resolved
client/package.json Outdated Show resolved Hide resolved
import { Web3Storage } from 'web3.storage';

export const makeStorageClient = () => {
return new Web3Storage({ token: process.env.WEB3STORAGE_TOKEN ?? '' });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently this token will be exposed in our front-end bundle, meaning any malicious actor can take this and put an infinite amount of files. Do we want to make this part of user-retrieval, ...? Or is this token scoped to only read?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @JoviDeCroock, you're completely right about it being available to malicious actors. How can i not expose the token? I was not aware that it would be exposed in our front end bundle.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do this as a follow-up issue as we're not live yet but I'd suggest incorporating this in our api-routes so /ap/upload-avatar which will stream fe --> api-route --> web3.storage this makes our tokens safely stored in a serverless function and away from our users

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah definitely make an API route for this. You don't wanna expose it to the browser.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #143

@diegoalzate
Copy link
Contributor Author

Looks good overall thank you @diegoalzate 🎉

I've requested some minor changes. But I also noticed that yarn.lock was removed and package-lock.json is added, I am not entirely sure if this is a problem but would like to request your review 👀 on this PR @with-heart @Dhaiwat10

@carlomigueldy True i didnt notice that I removed the yarn.lock, i did a back merge to fix conflicts with the new changes that were uploaded to main but something obviously went wrong along the way. Just let me know how i should fix it :)

src="/DevDAO.png"
alt="developer"
/>
<AddAvatar src="/DevDAO.png" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A page file should not accept any props. Please see my comment above. Basically, if anyone vistis the create-profile/add-avatar route, will render automatically since it's the default export from the file named add-avatar.tsx.

You should be just redirecting the user to that route.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get that pages shouldn't accept any props, in this case I thought a component was the solution to the issue

Comment on lines +63 to 80
export const ButtonGreen = ({ children, as, onClick }: ChakraButtonProps) => {
return (
<Button
size="sm"
bgColor="#38A169"
textColor="white"
_hover={{ cursor: 'pointer', bg: '#2F855A' }}
m="5px"
ms="0px"
w="auto"
fontSize="14px"
onClick={onClick}
as={as}
>
{children}
</Button>
);
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing a lot of repetition in this file. Most of these variants of the Chakra Button component share most of their props. Can we clean this up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I don't remember changing this page it might just be style changes that show up in the git log, I'll look into it either way 😃

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These buttons will probably be changed, but you're right about cleaning the code

Dhaiwat10
Dhaiwat10 previously approved these changes Dec 8, 2021
Copy link
Member

@Dhaiwat10 Dhaiwat10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean up the Buttons file and you're good to go!

@carlomigueldy
Copy link
Contributor

carlomigueldy commented Dec 8, 2021

Looks good overall thank you @diegoalzate 🎉
I've requested some minor changes. But I also noticed that yarn.lock was removed and package-lock.json is added, I am not entirely sure if this is a problem but would like to request your review 👀 on this PR @with-heart @Dhaiwat10

@carlomigueldy True i didnt notice that I removed the yarn.lock, i did a back merge to fix conflicts with the new changes that were uploaded to main but something obviously went wrong along the way. Just let me know how i should fix it :)

Yo @diegoalzate ! Just delete all package-lock.json files and run yarn install this creates the yarn.lock files. Then that should be it for the quick fix.

And then we're ready to merge this in!

@diegoalzate
Copy link
Contributor Author

Looks good overall thank you @diegoalzate 🎉
I've requested some minor changes. But I also noticed that yarn.lock was removed and package-lock.json is added, I am not entirely sure if this is a problem but would like to request your review 👀 on this PR @with-heart @Dhaiwat10

@carlomigueldy True i didnt notice that I removed the yarn.lock, i did a back merge to fix conflicts with the new changes that were uploaded to main but something obviously went wrong along the way. Just let me know how i should fix it :)

Yo @diegoalzate ! Just delete all package-lock.json files and run yarn install this creates the yarn.lock files. Then that should be it for the quick fix.

And then we're ready to merge this in!

@carlomigueldy sounds great, just pushed these changes, not sure why it says i dismissed @Dhaiwat10 stale review :/

@carlomigueldy
Copy link
Contributor

Looks good overall thank you @diegoalzate 🎉
I've requested some minor changes. But I also noticed that yarn.lock was removed and package-lock.json is added, I am not entirely sure if this is a problem but would like to request your review 👀 on this PR @with-heart @Dhaiwat10

@carlomigueldy True i didnt notice that I removed the yarn.lock, i did a back merge to fix conflicts with the new changes that were uploaded to main but something obviously went wrong along the way. Just let me know how i should fix it :)

Yo @diegoalzate ! Just delete all package-lock.json files and run yarn install this creates the yarn.lock files. Then that should be it for the quick fix.
And then we're ready to merge this in!

@carlomigueldy sounds great, just pushed these changes, not sure why it says i dismissed @Dhaiwat10 stale review :/

Whoops sorry, I think it was the branch rules that I put. I removed that rule instead so it doesn't get dismissed unintentionally

Copy link
Contributor

@carlomigueldy carlomigueldy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done mate @diegoalzate 🥂

@carlomigueldy carlomigueldy merged commit badd2ea into main Dec 8, 2021
@carlomigueldy carlomigueldy deleted the feature/add-profile-image branch December 8, 2021 06:36
@4gnle 4gnle mentioned this pull request Dec 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants