Skip to content

Commit 4da5603

Browse files
committed
fix various bugs on the profile page
1 parent 3ee2075 commit 4da5603

File tree

8 files changed

+49
-31
lines changed

8 files changed

+49
-31
lines changed

app/profile/[login]/components/layout-left-column.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ export const LayoutLeftColumn: FC<LayoutLeftColumnProps> = ({ user, children, cl
7676
</ActionsContainer>
7777
<DetailsContainer>
7878
<div className="flex flex-col gap-1.5">
79-
<ProfileListItem value={user.location} Icon={MapPin} />
79+
<ProfileListItem
80+
value={`${user.countryFlag ? `${user.countryFlag} ` : ''}${user.location}`}
81+
Icon={MapPin}
82+
/>
8083
<ProfileListItem value={user.company} Icon={BriefcaseBusiness} />
8184
<ProfileListItem value={'Profile age: ' + formatDistanceToNow(user.githubCreatedAt)} Icon={Hourglass} />
8285
<ProfileListItem

app/profile/[login]/components/overview-cards/overview-rank-card.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ const CardFooterRank: FC<PropsWithChildren> = ({ children }) => {
3232

3333
export const ProfileRankCard: FC<ProfileRankCardProps> = ({ login, ranks, tiers, country }) => {
3434
const { sTier, cTier, fTier, bestTier } = calculateTiers(ranks, tiers as RankTier);
35-
const sRank = ranks?.s ?? ranks?.sProvisional ?? 0;
36-
const cRank = ranks?.c ?? ranks?.cProvisional ?? 0;
37-
const fRank = ranks?.f ?? ranks?.fProvisional ?? 0;
35+
const sRank = sTier?.notRanked || sTier?.notAvailable ? 0 : ranks?.s ?? ranks?.sProvisional ?? 0;
36+
const cRank = cTier?.notRanked || cTier?.notAvailable ? 0 : ranks?.c ?? ranks?.cProvisional ?? 0;
37+
const fRank = fTier?.notRanked || fTier?.notAvailable ? 0 : ranks?.f ?? ranks?.fProvisional ?? 0;
3838

3939
const getCardContent = () => {
4040
if (sTier?.notAvailable && cTier?.notAvailable && fTier?.notAvailable) {

app/profile/[login]/languages/components/languages-page.tsx

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ export const LanguagesPage: FC<OverviewPageProps> = ({ user, isGlobalContext })
2727
const rankProp = isGlobalContext ? 'rankGlobal' : 'rankCountry';
2828
const langsWithRank = langsWithScore?.filter((lang) => lang[rankProp]);
2929

30-
return langsWithScore?.length && !langsWithRank?.length;
30+
return !!langsWithScore?.length && !langsWithRank?.length;
3131
}, [langsWithScore, isGlobalContext]);
3232

33+
const ranksAreNotAvailable = !langsWithScore?.length;
34+
3335
if (user.fetchingStatus === 'FETCHING' && !user.avatarUrl) {
3436
// user is being fetched for the first time
3537
return <NotFound fetchingStatus={user.fetchingStatus} fetchingUpdatedAt={user.fetchingUpdatedAt} />;
@@ -50,16 +52,23 @@ export const LanguagesPage: FC<OverviewPageProps> = ({ user, isGlobalContext })
5052
</p>
5153
)}
5254

53-
<ProfileCardsGrid>
54-
{langsWithScore?.map((language) => (
55-
<LanguageRankCard
56-
key={language.name}
57-
language={language as UserLanguage}
58-
isGlobalContext={isGlobalContext}
59-
country={user.country}
60-
/>
61-
))}
62-
</ProfileCardsGrid>
55+
{ranksAreNotAvailable ? (
56+
<p>
57+
No language rankings yet! We parsed languages from your public repositories, but none have enough stars to
58+
generate rankings. Once your projects gain stars, we&apos;ll show your top languages here.
59+
</p>
60+
) : (
61+
<ProfileCardsGrid>
62+
{langsWithScore?.map((language) => (
63+
<LanguageRankCard
64+
key={language.name}
65+
language={language as UserLanguage}
66+
isGlobalContext={isGlobalContext}
67+
country={user.country}
68+
/>
69+
))}
70+
</ProfileCardsGrid>
71+
)}
6372
</>
6473
</LayoutLeftColumn>
6574
);

app/profile/[login]/timeline/components/profile-timeline.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ type ProfileTimelineDescriptionProps = {
2424

2525
const parseChangesetItem = (changesetItem: ChangeItemType, type: ChangeItemType) => {
2626
if (isObject<NonNullable<SocialAccountChangeItem>>(changesetItem)) {
27-
if (!changesetItem.totalCount) {
28-
return null;
27+
if (changesetItem.totalCount) {
28+
return changesetItem.nodes
29+
?.map((account) => `${account.provider?.toLowerCase()}: ${account.displayName}`)
30+
.join('; ');
2931
}
3032

31-
return changesetItem.nodes
32-
?.map((account) => `${account.provider?.toLowerCase()}: ${account.displayName}`)
33-
.join('; ');
33+
if ('name' in changesetItem) {
34+
return `${changesetItem.name}`;
35+
}
3436
}
3537

3638
if (Array.isArray(changesetItem) && type === 'repoRemoved') {

graphql/fragments/profile-base-fields.gql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ fragment UserBaseFields on User {
55
avatarUrl
66
location
77
country
8+
countryFlag
89
company
910
email
1011
f

types/generated/graphql.ts

Lines changed: 11 additions & 10 deletions
Large diffs are not rendered by default.

types/generated/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ type User {
363363
contributedRepoCount: Int
364364
contributions(limit: Int, offset: Int! = 0): [Contribution!]
365365
country: String
366+
countryFlag: String
366367
createdAt: DateTime!
367368
email: String
368369
f: Int

types/profile-timeline.types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { PageProfileOverviewQuery } from './generated/graphql';
22

33
export type SocialAccountChangeItem = NonNullable<PageProfileOverviewQuery['user']>['socialAccounts'];
4+
export type OrganizationChangeItem = { name?: string; login?: string };
45

5-
export type ChangeItemType = string | number | boolean | SocialAccountChangeItem;
6+
export type ChangeItemType = string | number | boolean | SocialAccountChangeItem | OrganizationChangeItem;
67

78
export type ChangeSetItemType = {
89
a: ChangeItemType;

0 commit comments

Comments
 (0)