Fix header profile button for no channels, use it as an icon for mobile unath instead of big login/signup buttons

This commit is contained in:
Rafael 2021-12-21 12:09:19 -03:00 committed by Thomas Zarebczan
parent 7001c27ed0
commit 4158b99453
3 changed files with 35 additions and 21 deletions

View file

@ -158,13 +158,13 @@ const Header = (props: Props) => {
{!hideProfile && <HeaderProfileMenuButton />} {!hideProfile && <HeaderProfileMenuButton />}
</> </>
) : ( ) : !isMobile ? (
<div className="header__authButtons"> <div className="header__authButtons">
{!isMobile && (
<Button navigate={`/$/${PAGES.AUTH_SIGNIN}`} button="link" label={__('Log In')} disabled={user === null} /> <Button navigate={`/$/${PAGES.AUTH_SIGNIN}`} button="link" label={__('Log In')} disabled={user === null} />
)}
<Button navigate={`/$/${PAGES.AUTH}`} button="primary" label={__('Sign Up')} disabled={user === null} /> <Button navigate={`/$/${PAGES.AUTH}`} button="primary" label={__('Sign Up')} disabled={user === null} />
</div> </div>
) : (
<HeaderProfileMenuButton />
)} )}
</div> </div>
); );

View file

@ -45,6 +45,8 @@ export default function HeaderProfileMenuButton(props: HeaderMenuButtonProps) {
)} )}
<MenuList className="menu__list--header"> <MenuList className="menu__list--header">
{email ? (
<>
<HeaderMenuLink page={PAGES.UPLOADS} icon={ICONS.PUBLISH} name={__('Uploads')} /> <HeaderMenuLink page={PAGES.UPLOADS} icon={ICONS.PUBLISH} name={__('Uploads')} />
<HeaderMenuLink page={PAGES.CHANNELS} icon={ICONS.CHANNEL} name={__('Channels')} /> <HeaderMenuLink page={PAGES.CHANNELS} icon={ICONS.CHANNEL} name={__('Channels')} />
<HeaderMenuLink page={PAGES.CREATOR_DASHBOARD} icon={ICONS.ANALYTICS} name={__('Creator Analytics')} /> <HeaderMenuLink page={PAGES.CREATOR_DASHBOARD} icon={ICONS.ANALYTICS} name={__('Creator Analytics')} />
@ -58,6 +60,15 @@ export default function HeaderProfileMenuButton(props: HeaderMenuButtonProps) {
</div> </div>
<span className="menu__link-help">{email}</span> <span className="menu__link-help">{email}</span>
</MenuItem> </MenuItem>
</>
) : (
<>
<HeaderMenuLink page={PAGES.AUTH_SIGNIN} icon={ICONS.SIGN_IN} name={__('Log In')} />
<HeaderMenuLink page={PAGES.AUTH} icon={ICONS.SIGN_UP} name={__('Sign Up')} />
<HeaderMenuLink page={PAGES.SETTINGS} icon={ICONS.SETTINGS} name={__('Settings')} />
<HeaderMenuLink page={PAGES.HELP} icon={ICONS.HELP} name={__('Help')} />
</>
)}
</MenuList> </MenuList>
</Menu> </Menu>
</div> </div>

View file

@ -1,5 +1,6 @@
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { selectClaimWithId, selectMyChannelClaims, selectStakedLevelForChannelUri } from 'redux/selectors/claims'; import { selectClaimWithId, selectMyChannelClaims, selectStakedLevelForChannelUri } from 'redux/selectors/claims';
import { selectUserEmail } from 'redux/selectors/user';
export const selectState = (state) => state.app || {}; export const selectState = (state) => state.app || {};
@ -66,15 +67,17 @@ export const selectActiveChannelId = (state) => selectState(state).activeChannel
export const selectActiveChannelClaim = createSelector( export const selectActiveChannelClaim = createSelector(
(state) => selectClaimWithId(state, selectActiveChannelId(state)), // i.e. 'byId[activeChannelId]' specifically, instead of just 'byId'. (state) => selectClaimWithId(state, selectActiveChannelId(state)), // i.e. 'byId[activeChannelId]' specifically, instead of just 'byId'.
(state) => selectUserEmail(state),
selectMyChannelClaims, selectMyChannelClaims,
(activeChannelClaim, myChannelClaims) => { (activeChannelClaim, userEmail, myChannelClaims) => {
if (!activeChannelClaim || !myChannelClaims || !myChannelClaims.length) { // Null: has none. Undefined: not resolved, default state, could have or not
if (!userEmail || myChannelClaims === null) {
return null;
} else if (!activeChannelClaim || !myChannelClaims || !myChannelClaims.length) {
return undefined; return undefined;
} }
if (activeChannelClaim) { if (activeChannelClaim) return activeChannelClaim;
return activeChannelClaim;
}
const myChannelClaimsByEffectiveAmount = myChannelClaims.slice().sort((a, b) => { const myChannelClaimsByEffectiveAmount = myChannelClaims.slice().sort((a, b) => {
const effectiveAmountA = (a.meta && Number(a.meta.effective_amount)) || 0; const effectiveAmountA = (a.meta && Number(a.meta.effective_amount)) || 0;