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

Fix/Show discordId #252

Merged
merged 3 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,18 @@ export async function fetchTeamDirectory({

if (res) {
updateDirectoryWithCurrentTime(res);
const teamMember = res.voyageTeamMembers;
const elementToSort = teamMember.find(
(element) => element.member.discordId === user?.discordId,
const teamMembers = res.voyageTeamMembers;
const userDiscordId = user?.oAuthProfiles.find(
(profile) => profile.provider.name === "discord",
)?.providerUsername;
const elementToSort = teamMembers.find(
(element) =>
element.member.oAuthProfiles.find(
(profile) => profile.provider.name === "discord",
)?.providerUsername === userDiscordId,
);
moveElementToFirst(teamMember, elementToSort);

moveElementToFirst(teamMembers, elementToSort);
}

return [res, error];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ interface TeamMemberProps {

export default function TeamMember({ teamMember }: TeamMemberProps) {
const user = useUser().voyageTeamMembers;
const { firstName, lastName, discordId, currentTime } = teamMember.member;
const { firstName, lastName, oAuthProfiles, currentTime } = teamMember.member;
const { id, hrPerSprint, voyageRole } = teamMember;
const isCurrentUser = user.some((user) => user.id === id);
const [isEditing, setIsEditing] = useState<boolean>(false);
const newRef = useRef<HTMLDivElement>(null);

const discordId =
oAuthProfiles.find((profile) => profile.provider.name === "discord")
?.providerUsername || "";

useEffect(() => {
document.addEventListener("mousedown", handleOutsideClick);
return () => {
Expand Down
24 changes: 16 additions & 8 deletions src/store/features/directory/directorySlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
type VoyageStatus,
} from "@/store/features/user/userSlice";

type providerType = "discord";

interface VoyageTier {
id: number;
name: string;
Expand All @@ -20,10 +22,12 @@ interface VoyageMember {
firstName: string;
lastName: string;
avatar: string;
githubId: string | null;
discordId: string | null;
twitterId: string | null;
linkedinId: string | null;
oAuthProfiles: {
provider: {
name: providerType;
};
providerUsername: string;
}[];
countryCode: string;
timezone: string;
currentTime: string;
Expand Down Expand Up @@ -73,10 +77,14 @@ const initialState: DirectoryState = {
firstName: "",
lastName: "",
avatar: "",
githubId: null,
discordId: null,
twitterId: null,
linkedinId: null,
oAuthProfiles: [
{
provider: {
name: "discord",
},
providerUsername: "",
},
],
countryCode: "",
timezone: "",
currentTime: "",
Expand Down
24 changes: 16 additions & 8 deletions src/store/features/user/userSlice.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { type PayloadAction, createSlice } from "@reduxjs/toolkit";
import { clientSignOut } from "@/store/features/auth/authSlice";

type providerType = "discord";

export interface VoyageStatus {
name: string;
}
Expand Down Expand Up @@ -31,10 +33,12 @@ export interface User {
firstName: string;
lastName: string;
countryCode: string;
discordId: string;
githubId: string;
twitterId: string;
linkedinId: string;
oAuthProfiles: {
provider: {
name: providerType;
};
providerUsername: string;
}[];
email: string;
timezone: string;
avatar: string;
Expand All @@ -48,10 +52,14 @@ const initialState: User = {
firstName: "",
lastName: "",
countryCode: "",
discordId: "",
githubId: "",
twitterId: "",
linkedinId: "",
oAuthProfiles: [
{
provider: {
name: "discord",
},
providerUsername: "",
},
],
email: "",
timezone: "",
avatar: "",
Expand Down
Loading