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

only show lastLogin in production for reviewers #2978

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Changes from all commits
Commits
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
10 changes: 8 additions & 2 deletions src/components/pages/user/profile.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { faInfoCircle, faPencilAlt } from '@fortawesome/free-solid-svg-icons'
import { Entity } from '@serlo/authorization'
import { NextPage } from 'next'
import Image from 'next/image'
import { useState, useEffect } from 'react'

import { useAuthentication } from '@/auth/use-authentication'
import { useCanDo } from '@/auth/use-can-do'
import { Link } from '@/components/content/link'
import { FaIcon } from '@/components/fa-icon'
import { StaticInfoPanel } from '@/components/static-info-panel'
Expand All @@ -18,6 +20,7 @@ import { useInstanceData } from '@/contexts/instance-context'
import { UserPage, UuidType } from '@/data-types'
import { Instance } from '@/fetcher/graphql-types/operations'
import { breakpoints } from '@/helper/breakpoints'
import { isProduction } from '@/helper/is-production'
import { renderArticle } from '@/schema/article-renderer'

export interface ProfileProps {
Expand All @@ -27,6 +30,7 @@ export interface ProfileProps {
export const Profile: NextPage<ProfileProps> = ({ userData }) => {
const { strings, lang } = useInstanceData()
const auth = useAuthentication()
const canDo = useCanDo()

const {
id,
Expand Down Expand Up @@ -168,15 +172,17 @@ export const Profile: NextPage<ProfileProps> = ({ userData }) => {
}

function renderRoles() {
const showLastLogin = !isProduction || canDo(Entity.checkoutRevision)

return (
<aside className="mx-side mt-20 text-sm text-gray-500">
<ProfileRoles roles={userData.roles} />
{userData.lastLogin && (
{showLastLogin && userData.lastLogin ? (
<p>
{strings.profiles.lastLogin}:{' '}
<TimeAgo className="pl-2 font-bold" datetime={userData.lastLogin} />
</p>
)}
) : null}
</aside>
)
}
Expand Down