mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
fix(core): show SentRequestPage when invitation status is NeedMoreSeat (#11207)
This commit is contained in:
@@ -10,7 +10,7 @@ export const JoinFailedPage = ({
|
|||||||
inviteInfo,
|
inviteInfo,
|
||||||
error,
|
error,
|
||||||
}: {
|
}: {
|
||||||
inviteInfo: GetInviteInfoQuery['getInviteInfo'];
|
inviteInfo?: GetInviteInfoQuery['getInviteInfo'];
|
||||||
error?: any;
|
error?: any;
|
||||||
}) => {
|
}) => {
|
||||||
const userFriendlyError = UserFriendlyError.fromAny(error);
|
const userFriendlyError = UserFriendlyError.fromAny(error);
|
||||||
@@ -27,8 +27,8 @@ export const JoinFailedPage = ({
|
|||||||
1: (
|
1: (
|
||||||
<div className={styles.avatarWrapper}>
|
<div className={styles.avatarWrapper}>
|
||||||
<Avatar
|
<Avatar
|
||||||
url={`data:image/png;base64,${inviteInfo.workspace.avatar}`}
|
url={`data:image/png;base64,${inviteInfo?.workspace.avatar}`}
|
||||||
name={inviteInfo.workspace.name}
|
name={inviteInfo?.workspace.name}
|
||||||
size={20}
|
size={20}
|
||||||
colorfulFallback
|
colorfulFallback
|
||||||
/>
|
/>
|
||||||
@@ -37,7 +37,7 @@ export const JoinFailedPage = ({
|
|||||||
2: <span className={styles.inviteName} />,
|
2: <span className={styles.inviteName} />,
|
||||||
}}
|
}}
|
||||||
values={{
|
values={{
|
||||||
workspaceName: inviteInfo.workspace.name,
|
workspaceName: inviteInfo?.workspace.name,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<div>{t['com.affine.fail-to-join-workspace.description-2']()}</div>
|
<div>{t['com.affine.fail-to-join-workspace.description-2']()}</div>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export const RequestToJoinPage = ({
|
|||||||
onSignOut,
|
onSignOut,
|
||||||
}: {
|
}: {
|
||||||
user: User | null;
|
user: User | null;
|
||||||
inviteInfo: GetInviteInfoQuery['getInviteInfo'];
|
inviteInfo?: GetInviteInfoQuery['getInviteInfo'];
|
||||||
requestToJoin: () => void;
|
requestToJoin: () => void;
|
||||||
onSignOut: () => void;
|
onSignOut: () => void;
|
||||||
}) => {
|
}) => {
|
||||||
@@ -28,23 +28,23 @@ export const RequestToJoinPage = ({
|
|||||||
<div className={styles.content}>
|
<div className={styles.content}>
|
||||||
<div className={styles.userWrapper}>
|
<div className={styles.userWrapper}>
|
||||||
<Avatar
|
<Avatar
|
||||||
url={inviteInfo.user.avatarUrl || ''}
|
url={inviteInfo?.user.avatarUrl || ''}
|
||||||
name={inviteInfo.user.name}
|
name={inviteInfo?.user.name}
|
||||||
size={20}
|
size={20}
|
||||||
/>
|
/>
|
||||||
<span className={styles.inviteName}>{inviteInfo.user.name}</span>
|
<span className={styles.inviteName}>{inviteInfo?.user.name}</span>
|
||||||
</div>
|
</div>
|
||||||
<div>{t['invited you to join']()}</div>
|
<div>{t['invited you to join']()}</div>
|
||||||
<div className={styles.userWrapper}>
|
<div className={styles.userWrapper}>
|
||||||
<Avatar
|
<Avatar
|
||||||
url={`data:image/png;base64,${inviteInfo.workspace.avatar}`}
|
url={`data:image/png;base64,${inviteInfo?.workspace.avatar}`}
|
||||||
name={inviteInfo.workspace.name}
|
name={inviteInfo?.workspace.name}
|
||||||
size={20}
|
size={20}
|
||||||
style={{ marginLeft: 4 }}
|
style={{ marginLeft: 4 }}
|
||||||
colorfulFallback
|
colorfulFallback
|
||||||
/>
|
/>
|
||||||
<span className={styles.inviteName}>
|
<span className={styles.inviteName}>
|
||||||
{inviteInfo.workspace.name}
|
{inviteInfo?.workspace.name}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { notify } from '@affine/component';
|
|||||||
import {
|
import {
|
||||||
AcceptInvitePage,
|
AcceptInvitePage,
|
||||||
ExpiredPage,
|
ExpiredPage,
|
||||||
FailedToSendPage,
|
|
||||||
JoinFailedPage,
|
JoinFailedPage,
|
||||||
RequestToJoinPage,
|
RequestToJoinPage,
|
||||||
SentRequestPage,
|
SentRequestPage,
|
||||||
@@ -35,6 +34,7 @@ const AcceptInvite = ({ inviteId: targetInviteId }: { inviteId: string }) => {
|
|||||||
const workspaces = useLiveData(workspacesService.list.workspaces$);
|
const workspaces = useLiveData(workspacesService.list.workspaces$);
|
||||||
const navigateHelper = useNavigateHelper();
|
const navigateHelper = useNavigateHelper();
|
||||||
const [accepted, setAccepted] = useState(false);
|
const [accepted, setAccepted] = useState(false);
|
||||||
|
const [requestToJoinLoading, setRequestToJoinLoading] = useState(false);
|
||||||
const [acceptError, setAcceptError] = useState<UserFriendlyError | null>(
|
const [acceptError, setAcceptError] = useState<UserFriendlyError | null>(
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
@@ -63,6 +63,7 @@ const AcceptInvite = ({ inviteId: targetInviteId }: { inviteId: string }) => {
|
|||||||
}, [accepted, inviteInfo?.workspace.id, openWorkspace, workspaces]);
|
}, [accepted, inviteInfo?.workspace.id, openWorkspace, workspaces]);
|
||||||
|
|
||||||
const requestToJoin = useAsyncCallback(async () => {
|
const requestToJoin = useAsyncCallback(async () => {
|
||||||
|
setRequestToJoinLoading(true);
|
||||||
await invitationService
|
await invitationService
|
||||||
.acceptInvite(targetInviteId)
|
.acceptInvite(targetInviteId)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@@ -77,17 +78,18 @@ const AcceptInvite = ({ inviteId: targetInviteId }: { inviteId: string }) => {
|
|||||||
setAcceptError(err);
|
setAcceptError(err);
|
||||||
notify.error(err);
|
notify.error(err);
|
||||||
});
|
});
|
||||||
|
setRequestToJoinLoading(false);
|
||||||
}, [invitationService, openWorkspace, targetInviteId]);
|
}, [invitationService, openWorkspace, targetInviteId]);
|
||||||
|
|
||||||
const onSignOut = useAsyncCallback(async () => {
|
const onSignOut = useAsyncCallback(async () => {
|
||||||
await authService.signOut();
|
await authService.signOut();
|
||||||
}, [authService]);
|
}, [authService]);
|
||||||
|
|
||||||
if (loading || inviteId !== targetInviteId) {
|
if ((loading && !requestToJoinLoading) || inviteId !== targetInviteId) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inviteInfo) {
|
if (!inviteInfo && !loading) {
|
||||||
return <ExpiredPage onOpenAffine={onOpenAffine} />;
|
return <ExpiredPage onOpenAffine={onOpenAffine} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +100,7 @@ const AcceptInvite = ({ inviteId: targetInviteId }: { inviteId: string }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// for email invite
|
// for email invite
|
||||||
if (accepted && inviteInfo.status === WorkspaceMemberStatus.Accepted) {
|
if (accepted && inviteInfo?.status === WorkspaceMemberStatus.Accepted) {
|
||||||
return (
|
return (
|
||||||
<AcceptInvitePage
|
<AcceptInvitePage
|
||||||
onOpenWorkspace={openWorkspace}
|
onOpenWorkspace={openWorkspace}
|
||||||
@@ -107,15 +109,12 @@ const AcceptInvite = ({ inviteId: targetInviteId }: { inviteId: string }) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inviteInfo.status === WorkspaceMemberStatus.UnderReview) {
|
|
||||||
return <SentRequestPage user={user} inviteInfo={inviteInfo} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
inviteInfo.status === WorkspaceMemberStatus.NeedMoreSeatAndReview ||
|
inviteInfo?.status === WorkspaceMemberStatus.UnderReview ||
|
||||||
inviteInfo.status === WorkspaceMemberStatus.NeedMoreSeat
|
inviteInfo?.status === WorkspaceMemberStatus.NeedMoreSeatAndReview ||
|
||||||
|
inviteInfo?.status === WorkspaceMemberStatus.NeedMoreSeat
|
||||||
) {
|
) {
|
||||||
return <FailedToSendPage user={user} inviteInfo={inviteInfo} />;
|
return <SentRequestPage user={user} inviteInfo={inviteInfo} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user