Skip to content

Commit

Permalink
Member detail page and inductions use new Member model.
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonfancher committed Nov 23, 2021
1 parent 1da616e commit 251d1b1
Show file tree
Hide file tree
Showing 12 changed files with 153 additions and 101 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { Card } from "_app";
import { MemberData, MemberHoloCard, MemberCard } from "members";
import { Member, MemberHoloCard, MemberCard } from "members";

export const MemberCardPreview = ({
cardTitle = "Invitee information",
memberData,
member,
}: {
cardTitle?: string;
memberData: MemberData;
member: Member;
}) => (
<Card title={cardTitle} titleSize={2}>
<div className="flex justify-center items-center space-y-10 xl:space-y-0 xl:space-x-10 flex-col xl:flex-row">
<div className="max-w-xl">
<MemberHoloCard member={memberData} inducted={false} />
<MemberHoloCard member={member} inducted={false} />
</div>
<MemberCard member={memberData} />
<MemberCard member={member} />
</div>
</Card>
);
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { Dispatch, SetStateAction, useState } from "react";

import { Heading, Link, Text, useIsCommunityActive } from "_app";
import { MemberData } from "members";
import { Member } from "members";

import {
convertPendingProfileToMemberData,
convertPendingProfileToMember,
EndorsementsStatus,
InductionExpiresIn,
InductionStepGenesis,
Expand Down Expand Up @@ -96,7 +96,7 @@ export default InviteeJourney;

interface ContainerProps {
step: InductionStepInvitee | InductionStepGenesis;
memberPreview?: MemberData;
memberPreview?: Member;
children: React.ReactNode;
}

Expand All @@ -105,7 +105,7 @@ const Container = ({ step, memberPreview, children }: ContainerProps) => (
<InductionStepsContainer step={step}>
{children}
</InductionStepsContainer>
{memberPreview && <MemberCardPreview memberData={memberPreview} />}
{memberPreview && <MemberCardPreview member={memberPreview} />}
</>
);

Expand Down Expand Up @@ -188,15 +188,15 @@ const PendingCeremonyVideoStep = ({
induction,
setIsRevisitingProfile,
}: PendingCeremonyVideoStepProps) => {
const memberData = convertPendingProfileToMemberData(
const member = convertPendingProfileToMember(
induction.new_member_profile,
induction.invitee,
induction.video
);
return (
<Container
step={InductionStepInvitee.PendingVideoAndEndorsements}
memberPreview={memberData}
memberPreview={member}
>
<WaitingForVideo induction={induction} />
<Text className="my-3">
Expand All @@ -220,15 +220,15 @@ const PendingEndorsementStep = ({
endorsements,
setIsRevisitingProfile,
}: PendingCompletionStepProps) => {
const memberData = convertPendingProfileToMemberData(
const member = convertPendingProfileToMember(
induction.new_member_profile,
induction.invitee,
induction.video
);
return (
<Container
step={InductionStepInvitee.PendingVideoAndEndorsements}
memberPreview={memberData}
memberPreview={member}
>
<Heading size={1} className="mb-2">
Endorsements
Expand Down Expand Up @@ -256,7 +256,7 @@ const PendingDonationStep = ({
endorsements,
setIsRevisitingProfile,
}: PendingCompletionStepProps) => {
const memberData = convertPendingProfileToMemberData(
const member = convertPendingProfileToMember(
induction.new_member_profile,
induction.invitee,
induction.video
Expand All @@ -269,7 +269,7 @@ const PendingDonationStep = ({
? InductionStepInvitee.Donate
: InductionStepGenesis.Donate
}
memberPreview={memberData}
memberPreview={member}
>
<Heading size={1} className="mb-2">
Pending donation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
useUALAccount,
} from "_app";
import {
convertPendingProfileToMemberData,
convertPendingProfileToMember,
MemberCardPreview,
setInductionProfileTransaction,
} from "inductions";
Expand Down Expand Up @@ -70,7 +70,7 @@ export const InductionProfilePreview = ({

setDidSubmitProfile(true);
} catch (error) {
onError(error, "Unable to set the profile");
onError(error as Error, "Unable to set the profile");
}
setIsLoading(false);
};
Expand All @@ -81,15 +81,15 @@ export const InductionProfilePreview = ({
const img = URL.createObjectURL(selectedPhoto);
pendingProfile = { ...profileInfo!, img };
}
return convertPendingProfileToMemberData(
return convertPendingProfileToMember(
pendingProfile!,
induction.invitee
);
}, [induction.invitee, profileInfo, selectedPhoto]);

return (
<>
<MemberCardPreview cardTitle="" memberData={memberCardData} />
<MemberCardPreview cardTitle="" member={memberCardData} />
<Card title="Review your profile">
<form
onSubmit={submitInductionProfileTransaction}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React, { Dispatch, SetStateAction, useState } from "react";

import { Heading, Link, Text, useIsCommunityActive, useUALAccount } from "_app";

import { MemberData } from "members";
import { Member } from "members";
import {
convertPendingProfileToMemberData,
convertPendingProfileToMember,
EndorsementsStatus,
InductionExpiresIn,
InductionStepGenesis,
Expand Down Expand Up @@ -87,7 +87,7 @@ export default InviterWitnessJourney;

interface ContainerProps {
step: InductionStepInviter | InductionStepGenesis;
memberPreview?: MemberData;
memberPreview?: Member;
children: React.ReactNode;
}

Expand All @@ -96,7 +96,7 @@ const Container = ({ step, memberPreview, children }: ContainerProps) => (
<InductionStepsContainer step={step}>
{children}
</InductionStepsContainer>
{memberPreview && <MemberCardPreview memberData={memberPreview} />}
{memberPreview && <MemberCardPreview member={memberPreview} />}
</>
);

Expand Down Expand Up @@ -125,15 +125,15 @@ const RecommendReview = ({
);

const SubmittedVideoStep = ({ induction }: { induction: Induction }) => {
const memberData = convertPendingProfileToMemberData(
const member = convertPendingProfileToMember(
induction.new_member_profile,
induction.invitee,
induction.video
);
return (
<Container
step={InductionStepInviter.VideoAndEndorse}
memberPreview={memberData}
memberPreview={member}
>
<InductionVideoSubmitConfirmation />
</Container>
Expand All @@ -151,15 +151,15 @@ const VideoStep = ({
isRevisitingVideo,
setSubmittedVideo,
}: VideoStepProps) => {
const memberData = convertPendingProfileToMemberData(
const member = convertPendingProfileToMember(
induction.new_member_profile,
induction.invitee,
induction.video
);
return (
<Container
step={InductionStepInviter.VideoAndEndorse}
memberPreview={memberData}
memberPreview={member}
>
<InductionVideoFormContainer
induction={induction}
Expand Down Expand Up @@ -197,7 +197,7 @@ const PendingEndorsementStep = ({
setIsRevisitingVideo,
}: PendingCompletionProps) => {
const [ualAccount] = useUALAccount();
const memberData = convertPendingProfileToMemberData(
const member = convertPendingProfileToMember(
induction.new_member_profile,
induction.invitee,
induction.video
Expand All @@ -209,7 +209,7 @@ const PendingEndorsementStep = ({
return (
<Container
step={InductionStepInviter.VideoAndEndorse}
memberPreview={memberData}
memberPreview={member}
>
<Heading size={1} className="mb-2">
Endorsements
Expand Down Expand Up @@ -241,7 +241,7 @@ const PendingDonationStep = ({
setIsRevisitingVideo,
}: PendingCompletionProps) => {
const { data: isCommunityActive } = useIsCommunityActive();
const memberData = convertPendingProfileToMemberData(
const member = convertPendingProfileToMember(
induction.new_member_profile,
induction.invitee,
induction.video
Expand All @@ -253,7 +253,7 @@ const PendingDonationStep = ({
? InductionStepInviter.PendingDonation
: InductionStepGenesis.Donate
}
memberPreview={memberData}
memberPreview={member}
>
<Heading size={1} className="mb-2">
Pending donation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";

import { Heading, Text, useIsCommunityActive } from "_app";
import { MemberData } from "members";
import { Member } from "members";
import {
convertPendingProfileToMemberData,
convertPendingProfileToMember,
EndorsementsStatus,
InductionExpiresIn,
InductionStepGenesis,
Expand All @@ -17,7 +17,7 @@ import { Endorsement, Induction, InductionStatus } from "inductions/interfaces";

interface ContainerProps {
step: InductionStepInvitee | InductionStepGenesis;
memberPreview?: MemberData;
memberPreview?: Member;
children: React.ReactNode;
}

Expand All @@ -26,7 +26,7 @@ const Container = ({ step, memberPreview, children }: ContainerProps) => (
<InductionStepsContainer step={step}>
{children}
</InductionStepsContainer>
{memberPreview && <MemberCardPreview memberData={memberPreview} />}
{memberPreview && <MemberCardPreview member={memberPreview} />}
</>
);

Expand Down Expand Up @@ -83,15 +83,15 @@ const PendingProfileStep = ({ induction }: { induction: Induction }) => {
};

const PendingVideoStep = ({ induction }: { induction: Induction }) => {
const memberData = convertPendingProfileToMemberData(
const member = convertPendingProfileToMember(
induction.new_member_profile,
induction.invitee,
induction.video
);
return (
<Container
step={InductionStepInvitee.PendingVideoAndEndorsements}
memberPreview={memberData}
memberPreview={member}
>
<WaitingForVideo induction={induction} />
</Container>
Expand All @@ -107,15 +107,15 @@ const PendingEndorsementStep = ({
induction,
endorsements,
}: PendingCompletionProps) => {
const memberData = convertPendingProfileToMemberData(
const member = convertPendingProfileToMember(
induction.new_member_profile,
induction.invitee,
induction.video
);
return (
<Container
step={InductionStepInvitee.PendingVideoAndEndorsements}
memberPreview={memberData}
memberPreview={member}
>
<Heading size={1} className="mb-2">
Endorsements
Expand All @@ -132,7 +132,7 @@ const PendingDonationStep = ({
endorsements,
}: PendingCompletionProps) => {
const { data: isCommunityActive } = useIsCommunityActive();
const memberData = convertPendingProfileToMemberData(
const member = convertPendingProfileToMember(
induction.new_member_profile,
induction.invitee,
induction.video
Expand All @@ -144,7 +144,7 @@ const PendingDonationStep = ({
? InductionStepInvitee.Donate
: InductionStepGenesis.Donate
}
memberPreview={memberData}
memberPreview={member}
>
<Heading size={1} className="mb-2">
Pending donation
Expand Down
32 changes: 20 additions & 12 deletions packages/webapp/src/inductions/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import dayjs from "dayjs";

import { eosBlockTimestampISO } from "_app";
import { MemberData, memberDataDefaults } from "members";
import { eosBlockTimestampISO, ipfsUrl } from "_app";
import { Member, memberDefaults } from "members";
import {
Endorsement,
Induction,
Expand All @@ -12,19 +12,27 @@ import {

const INDUCTION_EXPIRATION_DAYS = 7;

export const convertPendingProfileToMemberData = (
export const convertPendingProfileToMember = (
profile: NewMemberProfile,
inviteeChainAccountName: string,
inductionVideo?: string
): MemberData => ({
...memberDataDefaults,
name: profile.name,
image: profile.img,
account: inviteeChainAccountName,
bio: profile.bio,
socialHandles: JSON.parse(profile.social || "{}"),
inductionVideo: inductionVideo || "",
attributions: profile.attributions || "",
): Member => ({
...memberDefaults,
accountName: inviteeChainAccountName,
profile: {
name: profile.name,
image: {
cid: profile.img,
url: ipfsUrl(profile.img),
attributions: profile.attributions || "",
},
bio: profile.bio,
socialHandles: JSON.parse(profile.social || "{}"),
},
inductionVideo: {
cid: inductionVideo || "",
url: inductionVideo ? ipfsUrl(inductionVideo) : "",
},
});

export const getInductionStatus = (
Expand Down
Loading

0 comments on commit 251d1b1

Please sign in to comment.