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

2713 team type componen #2889

Open
wants to merge 1 commit into
base: feature/recruitment_and_onboarding
Choose a base branch
from

Conversation

Aaryan1203
Copy link
Contributor

@Aaryan1203 Aaryan1203 commented Oct 14, 2024

Changes

Created the team type component
Created a helper to download an image

For testing purposes I only had a picture in the software division just to see what it would look like so heres a video for that

373267527-fd06d3a7-90fb-4ea5-9671-915ca471c32d.mov

Checklist

It can be helpful to check the Checks and Files changed tabs.
Please review the contributor guide and reach out to your Tech Lead if anything is unclear.
Please request reviewers and ping on slack only after you've gone through this whole checklist.

  • All commits are tagged with the ticket number
  • No linting errors / newline at end of file warnings
  • All code follows repository-configured prettier formatting
  • No merge conflicts
  • All checks passing
  • Screenshots of UI changes (see Screenshots section)
  • Remove any non-applicable sections of this template
  • Assign the PR to yourself
  • No yarn.lock changes (unless dependencies have changed)
  • Request reviewers & ping on Slack
  • PR is linked to the ticket (fill in the closes line below)

Closes #2713

@Aaryan1203 Aaryan1203 changed the base branch from develop to feature/recruitment_and_onboarding October 14, 2024 16:48
@Aaryan1203 Aaryan1203 self-assigned this Oct 14, 2024
static async downloadReceiptImage(fileId: string, submitter: User, organization: Organization) {
await validateUserIsPartOfFinanceTeamOrAdmin(submitter, organization.organizationId);
static async downloadReceiptImage(fileId: string, _submitter: User, _organization: Organization) {
// await validateUserIsPartOfFinanceTeamOrAdmin(submitter, organization.organizationId);
Copy link
Member

Choose a reason for hiding this comment

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

Why is this method changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah so the problem I was having was that this method only allows finance or admins to be able to download an image, i was going to ask if this permissions is necessary because everyone should be able to download images. In that case I could change the name of the function and just remove that permissions check

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see, I think you should just leave it as it was though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wait so should I make a new function then or how should I do it?

}

const TeamTypeSection = ({ teamType }: TeamTypeSectionProps) => {
const [imageUrl, setImageUrl] = useState<string>('');
Copy link
Member

Choose a reason for hiding this comment

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

Why does this have to be a usestate if its not going to change?

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 made it a useState because it gets reset every time the page renders like on line 14. Is there a better way to do this.

Copy link
Member

Choose a reason for hiding this comment

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

Ok I see what you mean. Generally you really want to avoid using a setState within a useEffect - I think you can achieve this using useRef

Copy link
Member

Choose a reason for hiding this comment

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

You could declare the imageUrl like this:

const imageUrlRef = useRef<string>('');
And then you can assign values to imageUrlRef.current

Copy link
Member

Choose a reason for hiding this comment

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

Honestly its pretty tricky and you might wanna do some googling/chatgpt but i think that would work. Lmk if you have questions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay yeah i just tried that and i realized the issue comes because each division is a tab and that does't trigger a rerender. so that means once a picture shows up for one of the divisions, then it stays the same image even if I switch tabs because thats not considered a refresh. Is there another way I can do this

static async downloadReceiptImage(fileId: string, submitter: User, organization: Organization) {
await validateUserIsPartOfFinanceTeamOrAdmin(submitter, organization.organizationId);
static async downloadReceiptImage(fileId: string, _submitter: User, _organization: Organization) {
// await validateUserIsPartOfFinanceTeamOrAdmin(submitter, organization.organizationId);
Copy link
Member

Choose a reason for hiding this comment

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

Ah I see, I think you should just leave it as it was though

}

const TeamTypeSection = ({ teamType }: TeamTypeSectionProps) => {
const [imageUrl, setImageUrl] = useState<string>('');
Copy link
Member

Choose a reason for hiding this comment

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

Ok I see what you mean. Generally you really want to avoid using a setState within a useEffect - I think you can achieve this using useRef

}

const TeamTypeSection = ({ teamType }: TeamTypeSectionProps) => {
const [imageUrl, setImageUrl] = useState<string>('');
Copy link
Member

Choose a reason for hiding this comment

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

You could declare the imageUrl like this:

const imageUrlRef = useRef<string>('');
And then you can assign values to imageUrlRef.current

}

const TeamTypeSection = ({ teamType }: TeamTypeSectionProps) => {
const [imageUrl, setImageUrl] = useState<string>('');
Copy link
Member

Choose a reason for hiding this comment

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

Honestly its pretty tricky and you might wanna do some googling/chatgpt but i think that would work. Lmk if you have questions

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.

2 participants