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

Feature/organization logo #1041

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
097c13e
feat: fetch logo url from api
spomberg Mar 1, 2023
3ed7be0
feat: implement logoURL state
spomberg Mar 1, 2023
d8e5bda
feat: import and implement useEffect to fetch logo url
spomberg Mar 1, 2023
6866356
feat: change logo alt to logo
spomberg Mar 1, 2023
8f4b35f
feat: use ternary operator to change the logo alt attribute
spomberg Mar 1, 2023
7070022
feat: make useEffect only run if user is logged in and has an organiz…
spomberg Mar 2, 2023
892f8df
feat: test that the greenstand logo shows when the user does not belo…
spomberg Mar 2, 2023
d8850ff
feat: move logo URL state and useEffect from IconLogo component AppCo…
spomberg Mar 2, 2023
a2ceb57
feat: rename logoURL state to logoPath
spomberg Mar 2, 2023
5d233be
feat: implement isVisible function that hides logo if URL is not avai…
spomberg Mar 3, 2023
5743b23
feat: refactor isVisible function to hide greenstand logo if user wit…
spomberg Mar 3, 2023
5204b0c
feat: add comments
spomberg Mar 3, 2023
120e9c5
feat: refactor isInvisible function to not hide the greenstand logo i…
spomberg Mar 3, 2023
f844cc6
feat: fetch logo url from api
spomberg Mar 1, 2023
369b102
feat: implement logoURL state
spomberg Mar 1, 2023
3baf925
feat: import and implement useEffect to fetch logo url
spomberg Mar 1, 2023
917485a
feat: change logo alt to logo
spomberg Mar 1, 2023
53fd8ff
feat: use ternary operator to change the logo alt attribute
spomberg Mar 1, 2023
f1c470a
feat: make useEffect only run if user is logged in and has an organiz…
spomberg Mar 2, 2023
942bddd
feat: test that the greenstand logo shows when the user does not belo…
spomberg Mar 2, 2023
e6b0fd4
feat: move logo URL state and useEffect from IconLogo component AppCo…
spomberg Mar 2, 2023
6bd16f9
feat: rename logoURL state to logoPath
spomberg Mar 2, 2023
b51bb1a
feat: implement isVisible function that hides logo if URL is not avai…
spomberg Mar 3, 2023
0042adf
feat: refactor isVisible function to hide greenstand logo if user wit…
spomberg Mar 3, 2023
c4d03ac
feat: add comments
spomberg Mar 3, 2023
72655e2
feat: refactor isInvisible function to not hide the greenstand logo i…
spomberg Mar 3, 2023
c6f95fd
feat: fix setLogoPath name typo
spomberg Mar 4, 2023
6fef96f
feat: implement get request for logo url at login if user belongs to …
spomberg Mar 4, 2023
0f73aee
feat: use axios instead of fetch to retrieve the logo URL
spomberg Mar 4, 2023
faba887
feat: change response to res on logo url axios call
spomberg Mar 4, 2023
b62a881
feat: remove login from logo url useEffect dependency
spomberg Mar 4, 2023
ff3400a
feat: remove IconLogo component from login page and use the svg file …
spomberg Mar 5, 2023
63f709e
feat: implement getStakeholder(id) function
spomberg Mar 5, 2023
c148f1d
feat: call getStakeholder(id) api function to retrieve logo url
spomberg Mar 5, 2023
8fd5700
feat: add cypress.env.json
spomberg Mar 5, 2023
3c80d22
feat: create cypress.env file to store credentials to be used in inte…
spomberg Mar 5, 2023
81cd029
test: remove credentials and use cypress.env instead
spomberg Mar 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: import and implement useEffect to fetch logo url
spomberg committed Mar 4, 2023
commit 3baf9258ea1538ef349024a3d4ab4a8a9cffb8c3
23 changes: 14 additions & 9 deletions src/components/IconLogo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Link } from 'react-router-dom';
import logo from './images/logo.svg';
import { AppContext } from '../context/AppContext';
import { React, useContext, useState } from 'react';
import { React, useContext, useState, useEffect } from 'react';

/*
* Just a logo icon
@@ -10,15 +10,20 @@ import { React, useContext, useState } from 'react';
export default function IconLogo() {
const appContext = useContext(AppContext);
const { user } = appContext;
const [logoURL, setLogoURL] = useState();
const [logoURL, setLogoURL] = useState('');

if (user) {
const STAKEHOLDER_API = process.env.REACT_APP_STAKEHOLDER_API_ROOT;
const orgID = user.policy.organization.id;
fetch(`${STAKEHOLDER_API}/stakeholders/${orgID}`)
.then((response) => response.json())
.then((data) => console.log(data.stakeholders[0].logo_url));
}
useEffect(() => {
if (user) {
const STAKEHOLDER_API = process.env.REACT_APP_STAKEHOLDER_API_ROOT;
const orgID = user.policy.organization.id;
fetch(`${STAKEHOLDER_API}/stakeholders/${orgID}`)
.then((response) => response.json())
.then((data) => {
const orgLogo = data.stakeholders[0].logo_url;
orgLogo ? setLogoURL(orgLogo) : setLogoURL(logo);
});
} else setLogoURL(logo);
}, [user]);

return (
<Link to="/">