import styled from "styled-components";
import { useState } from "react";
import { Box, Button, Text, Flex, Flash } from "rimble-ui";
import { ContentCopy } from "@rimble/icons";
import { VC } from "vc-schema-tools";
import { HoverPathFill, ShareIcon, UnstyledButton } from "../../../elements";
import { ModalContentFullWidth, ModalWithX } from "../../../elements/Modals";
import { H3, H6 } from "../../../layouts/LayoutComponents";
import { colors, fonts } from "../../../../themes";
import { config } from "../../../../config";
import { CopyableTruncatableText } from "../../../elements/CopyableTruncatableText/CopyableTruncatableText";
import { ShareViaDidComm } from "./ShareViaDidComm";
import { ShareViaQr } from "./ShareViaQr";
import { ShareViaSocial } from "./ShareViaSocial";
const _ShareBox: React.FC<{ className?: string }> = (props) => (
{props.children}
);
const ShareBox = styled(_ShareBox)`
&:first-child {
padding-top: 0;
}
&:last-child {
padding-bottom: 0;
border-bottom: none;
}
`;
export interface CredentialShareProps {
vc: VC;
issueVcFlow?: boolean;
}
export const CredentialShare: React.FC = (props) => {
const { vc, issueVcFlow } = props;
if (!vc.proof?.jwt) {
return Cannot share VC: missing proof.jwt;
}
const vcUrl = `${config.SEARCH_UI_URL}/vc-validator?vc=${vc.proof.jwt}`;
return (
<>
{issueVcFlow ? "Recipient Information" : "Share Credential"}
Choose any methods below to send or share credential.
Send by Identifier (DID)
Share by link
(
)}
/>
Share on social media
{issueVcFlow && (
Share by QR code
)}
>
);
};
export const CredentialShareButton: React.FC = (props) => {
const { vc } = props;
const [modalOpen, setModalOpen] = useState(false);
if (!vc.proof) {
// VC has no JWT so can't initialize share component - it probably hasn't been isued yet
return <>>;
}
return (
<>
{props.children || (
setModalOpen(true)}>
)}
setModalOpen(false)} width={9}>
>
);
};