Skip to content

Commit

Permalink
Use new profilePictureUrl field instead of Slack avatar URL
Browse files Browse the repository at this point in the history
  • Loading branch information
zoul committed Oct 28, 2024
1 parent a4086f5 commit 532351f
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 30 deletions.
3 changes: 2 additions & 1 deletion app/events/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import { getProjectById, type Project } from "~/src/data/project";
import { getUserProfile, type UserProfile } from "~/src/data/user-profile";
import { Route } from "~/src/routing";
import { defaultAvatarUrl } from "~/src/utils";

type Params = {
slug: string;
Expand Down Expand Up @@ -113,7 +114,7 @@ const EventSidebar = ({
<SidebarSection title="Kontakt">
<ImageLabel
link={Route.toProfile({ id: owner.id })}
imageUrl={owner.avatarUrl}
imageUrl={owner.profilePictureUrl ?? defaultAvatarUrl}
label={owner.name}
/>
</SidebarSection>
Expand Down
3 changes: 2 additions & 1 deletion app/opportunities/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { getAllProjects, type Project } from "~/src/data/project";
import { getAlternativeOpenRoles } from "~/src/data/queries";
import { getUserProfile, type UserProfile } from "~/src/data/user-profile";
import { Route } from "~/src/routing";
import { defaultAvatarUrl } from "~/src/utils";

type Params = {
slug: string;
Expand Down Expand Up @@ -97,7 +98,7 @@ const RoleSidebar = ({
<SidebarSection title="Kontaktní osoba">
<ImageLabel
link={Route.toProfile({ id: owner.id })}
imageUrl={owner.avatarUrl}
imageUrl={owner.profilePictureUrl ?? defaultAvatarUrl}
label={owner.name}
/>
</SidebarSection>
Expand Down
3 changes: 2 additions & 1 deletion app/people/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from "~/src/data/team-engagement";
import { getUserProfile, type UserProfile } from "~/src/data/user-profile";
import { Route } from "~/src/routing";
import { defaultAvatarUrl } from "~/src/utils";

import { ContactRows } from "./ContactInfo";
import { InfoRow } from "./InfoRow";
Expand Down Expand Up @@ -197,7 +198,7 @@ const ProjectSection = ({ engagements }: EngagementProps) => {
const Avatar = ({ profile }: ProfileProps) => (
<div className="relative mx-auto aspect-square w-[200px]">
<Image
src={profile.avatarUrl}
src={profile.profilePictureUrl ?? defaultAvatarUrl}
className="aspect-square rounded-full bg-pebble object-cover object-top"
width={200}
height={200}
Expand Down
2 changes: 1 addition & 1 deletion app/projects/[slug]/ProjectTeamSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const ProjectTeamSection = ({
profile={{
id: e.userId,
name: e.userName,
avatarUrl: e.userAvatarUrl ?? defaultAvatarUrl,
profilePictureUrl: e.profilePictureUrl ?? defaultAvatarUrl,
}}
/>
))}
Expand Down
4 changes: 2 additions & 2 deletions app/projects/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from "~/src/data/team-engagement";
import { getAllPlaylistVideos } from "~/src/data/youtube";
import { Route } from "~/src/routing";
import { shuffleInPlace } from "~/src/utils";
import { defaultAvatarUrl, shuffleInPlace } from "~/src/utils";

import "react-lite-youtube-embed/dist/LiteYouTubeEmbed.css";

Expand Down Expand Up @@ -245,7 +245,7 @@ const ProjectSidebar = ({
<ImageLabel
key={c.id}
link={Route.toProfile({ id: c.userId })}
imageUrl={c.userAvatarUrl}
imageUrl={c.profilePictureUrl ?? defaultAvatarUrl}
label={c.userName}
faded={c.inactive}
/>
Expand Down
5 changes: 3 additions & 2 deletions components/UserProfileCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import clsx from "clsx";
import { CeskoDigital } from "~/components/icons/generic";
import { type UserProfile } from "~/src/data/user-profile";
import { Route } from "~/src/routing";
import { defaultAvatarUrl } from "~/src/utils";

export type Props = {
profile: Pick<UserProfile, "name" | "avatarUrl" | "id"> &
profile: Pick<UserProfile, "name" | "profilePictureUrl" | "id"> &
Partial<Pick<UserProfile, "roles">>;
label?: ReactNode;
};
Expand All @@ -26,7 +27,7 @@ export const UserProfileCard = ({ profile, label }: Props) => (
<div className="shrink-0">
<div className="relative mx-auto w-[80px]">
<Image
src={profile.avatarUrl}
src={profile.profilePictureUrl ?? defaultAvatarUrl}
className={clsx(
"shrink-0 rounded-full bg-gray shadow",
// This fixes the appearance of non-square images
Expand Down
2 changes: 1 addition & 1 deletion components/districts/districts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import sourceData from "./districts.json";
/** Map member is a subset of user profile containing just the necessary fields */
export type MapMember = Pick<
UserProfile,
"name" | "slackId" | "slackAvatarUrl" | "slackProfileUrl"
"name" | "slackId" | "slackProfileUrl"
>;

/** Map model is a map where the keys are district names and the values are lists of users in given district */
Expand Down
2 changes: 1 addition & 1 deletion src/data/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const decodeUser = record({
email: string,
emailVerified: optionalAsNull(date),
name: optionalAsNull(string),
image: field("slackAvatarUrl", relationToZeroOrOne),
image: field("profilePictureUrl", relationToZeroOrOne),
});

const encodeUser = (user: Partial<User>): Partial<UserTableSchema> => ({
Expand Down
6 changes: 1 addition & 5 deletions src/data/team-engagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
takeFirst,
withDefault,
} from "~/src/decoding";
import { defaultAvatarUrl } from "~/src/utils";

import { appBase, unwrapRecords } from "./airtable";

Expand All @@ -38,10 +37,7 @@ export const decodeTeamEngagement = record({
projectId: field("project", relationToOne),
userId: relationToOne,
userName: relationToOne,
userAvatarUrl: field(
"userAvatarUrl",
withDefault(relationToZeroOrOne, defaultAvatarUrl),
),
profilePictureUrl: relationToZeroOrOne,
projectRole: optional(string),
projectName: relationToOne,
projectSlug: relationToOne,
Expand Down
11 changes: 3 additions & 8 deletions src/data/user-profile.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { defaultAvatarUrl } from "~/src/utils";

import {
compareNames,
decodeUserProfile,
Expand Down Expand Up @@ -29,8 +27,7 @@ test("Decode user with no skills", () => {
slackUserRelationId: undefined,
slackId: "slack-id",
state: "confirmed",
slackAvatarUrl: undefined,
avatarUrl: defaultAvatarUrl,
profilePictureUrl: undefined,
slackProfileUrl: undefined,
featureFlags: [],
notificationFlags: [],
Expand Down Expand Up @@ -70,8 +67,7 @@ test("Decode Slack Users relation", () => {
slackUserRelationId: undefined,
slackId: "slack-id",
state: "confirmed",
slackAvatarUrl: undefined,
avatarUrl: defaultAvatarUrl,
profilePictureUrl: undefined,
slackProfileUrl: undefined,
featureFlags: [],
notificationFlags: ["receiveNewRoleNotifications"],
Expand Down Expand Up @@ -108,8 +104,7 @@ test("Decode Slack Users relation", () => {
slackUserRelationId: "someDatabaseId",
slackId: "slack-id",
state: "confirmed",
slackAvatarUrl: undefined,
avatarUrl: defaultAvatarUrl,
profilePictureUrl: undefined,
slackProfileUrl: undefined,
featureFlags: [],
notificationFlags: [],
Expand Down
12 changes: 5 additions & 7 deletions src/data/user-profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
withDefault,
} from "~/src/decoding";
import { decodeFlags } from "~/src/flags";
import { defaultAvatarUrl, normalizeEmailAddress } from "~/src/utils";
import { normalizeEmailAddress } from "~/src/utils";

import { unwrapRecord, unwrapRecords, usersBase } from "./airtable";

Expand Down Expand Up @@ -57,7 +57,7 @@ export interface Schema extends FieldSet {
slackUser: ReadonlyArray<string>;
slackId: ReadonlyArray<string>;
slackProfileUrl: string;
slackAvatarUrl: string;
profilePictureUrl: string;
notificationFlags: ReadonlyArray<string>;
privacyFlags: ReadonlyArray<string>;
featureFlags: ReadonlyArray<string>;
Expand Down Expand Up @@ -98,11 +98,7 @@ export const decodeUserProfile = record({
slackUserRelationId: field("slackUser", relationToZeroOrOne),
slackId: relationToZeroOrOne,
slackProfileUrl: relationToZeroOrOne,
slackAvatarUrl: relationToZeroOrOne,
avatarUrl: field(
"slackAvatarUrl",
withDefault(relationToZeroOrOne, defaultAvatarUrl),
),
profilePictureUrl: optional(string),
state: union("unconfirmed", "confirmed"),
featureFlags: decodeFlags(union(...featureFlags)),
notificationFlags: decodeFlags(union(...notificationFlags)),
Expand All @@ -128,6 +124,7 @@ export function encodeUserProfile(
occupation: profile.occupation,
organizationName: profile.organizationName,
profileUrl: profile.profileUrl,
profilePictureUrl: profile.profilePictureUrl,
state: profile.state,
notificationFlags: profile.notificationFlags,
privacyFlags: profile.privacyFlags,
Expand Down Expand Up @@ -211,6 +208,7 @@ export async function updateUserProfile(
| "bio"
| "occupation"
| "profileUrl"
| "profilePictureUrl"
| "organizationName"
>
>,
Expand Down

0 comments on commit 532351f

Please sign in to comment.