Skip to content

Commit

Permalink
fix: resolve wrong share link for completed endorsement
Browse files Browse the repository at this point in the history
  • Loading branch information
martines3000 committed Jun 22, 2024
1 parent 7f25950 commit 0318bcb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
15 changes: 7 additions & 8 deletions packages/dapp/src/components/EndorseForm/EndorsementModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,26 @@ import { MemoizedImage } from '@/components/MemoizedImage';
import { Input } from '@/components/ui/input';
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import { APP_URL, PlatformType, formatHandle, startsWithVowel } from '@/utils';
import { ProfileAvatarSkeleton } from '../ProfileAvatar';
import { PlatformType, formatHandle, startsWithVowel } from '@/utils';
import { Skeleton } from '../ui/skeleton';
import { EndorseeSkeleton } from '../Endorsee';
import { useEndorsementStore } from '@/stores';

type EndorsementModalProps = {
open: boolean;
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
endorsementId: string | null;
shareLink: string | null;
endorsee: React.ReactNode;
};

export const EndorsementModal = ({
open,
setOpen,
endorsementId,
shareLink,
endorsee,
}: EndorsementModalProps) => {
// TODO[Martin]: Add network name, so we can support multiple networks
const shareLink = `${APP_URL}/endorsement/${endorsementId}`;
// const shareLink = `${APP_URL}/endorsement/${endorsementId}`;
const { displayValue, endorsementType, platform } = useEndorsementStore(
(state) => ({
displayValue: state.displayValue,
Expand All @@ -42,7 +41,7 @@ export const EndorsementModal = ({
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogContent className="sm:max-w-[625px] p-4">
{endorsementId && (
{shareLink && (
<>
<DialogHeader>
<DialogTitle>Endorsement</DialogTitle>
Expand Down Expand Up @@ -111,15 +110,15 @@ export const EndorsementModal = ({
<Button
size="lg"
variant="outline"
onClick={() => navigator.clipboard.writeText('')}
onClick={() => navigator.clipboard.writeText(shareLink)}
>
Copy Link
</Button>
</div>
</div>
</>
)}
{!endorsementId && <EndorsementModalSkeleton />}
{!shareLink && <EndorsementModalSkeleton />}
</DialogContent>
</Dialog>
);
Expand Down
7 changes: 6 additions & 1 deletion packages/dapp/src/components/EndorseForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
import { cn } from '@/lib/utils';
import { ConnectButtonCustom } from '@/components/ConnectButtonCustom';
import { EndorsementModal } from './EndorsementModal';
import { APP_URL } from '@/utils';

type EndorseeProps = {
endorsee: React.ReactNode;
Expand Down Expand Up @@ -332,7 +333,11 @@ export const EndorseForm = ({ endorsee }: EndorseeProps) => {
<EndorsementModal
open={endorsementModalOpen}
setOpen={setEndorsementModalOpen}
endorsementId={endorsementData?.uid ?? null}
shareLink={
displayValue && platform && endorsementData?.uid
? `${APP_URL}/profile/${displayValue}?platform=${platform}&tab=explorer&endorsementId=${endorsementData?.uid}`
: null
}
endorsee={endorsee}
/>
</>
Expand Down

0 comments on commit 0318bcb

Please sign in to comment.