Skip to content

Commit

Permalink
fix: add lost "copy link" feature
Browse files Browse the repository at this point in the history
  • Loading branch information
wowkalucky committed Jun 30, 2023
1 parent dfb50a5 commit 1fda588
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 20 deletions.
Binary file modified src/assets/images/appStore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/images/googleplay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 29 additions & 17 deletions src/components/ProgramCertificateModal/ProgramCertificateModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BrowserView, MobileView, isBrowser } from 'react-device-detect';
import {
ActionRow, Button, Row, StandardModal,
} from '@edx/paragon';
import { Info } from '@edx/paragon/icons';
import { Info, ContentCopy } from '@edx/paragon/icons';

import messages from './messages';
import appStoreImg from '../../assets/images/appStore.png';
Expand All @@ -17,8 +17,8 @@ function ProgramCertificateModal({
const {
deeplink,
qrcode,
app_link_android: appLinkAndroid,
app_link_ios: appLinkIos,
app_link_android: googlePlayAppLink,
app_link_ios: appleStoreAppLink,
error,
} = data;

Expand All @@ -31,6 +31,10 @@ function ProgramCertificateModal({
);
}

const handleCopyClick = () => {
navigator.clipboard.writeText(deeplink);
};

return (
<StandardModal
title={intl.formatMessage(messages.certificateModalTitle)}
Expand Down Expand Up @@ -62,6 +66,14 @@ function ProgramCertificateModal({
alt={intl.formatMessage(messages.certificateModalQrCodeLabel)}
/>
</div>
<button
className="justify-content-center align-items-center mt-2 copy-link"
onClick={handleCopyClick}
type="button"
>
<ContentCopy />
{intl.formatMessage(messages.certificateModalCopyLinkLabel)}
</button>
</div>
<div className="col-12 col-md-8">
<h4>
Expand All @@ -88,43 +100,43 @@ function ProgramCertificateModal({
messages.certificateModalInstructionStep4,
)}
</li>
<div className="d-flex justify-content-between buttons-wrapper">
<a href={googlePlayAppLink}>
<img src={googlePlayImg} alt="Google Play" />
</a>
<a href={appleStoreAppLink}>
<img src={appStoreImg} alt="Apple App Store" />
</a>
</div>
</ol>
</div>
</Row>
</BrowserView>
<MobileView>
<p>{intl.formatMessage(messages.certificateModalMobileTitle)}</p>
<Button
href={appLinkIos}
href={appleStoreAppLink}
target="_blank"
size="lg"
className="mb-2 bg-gray-900 p-2"
className="mb-3 mobile-button"
block
aria-label={intl.formatMessage(
messages.certificateModalAppStoreBtn,
)}
>
<img
src={appStoreImg}
style={{ maxHeight: '2rem' }}
alt="App Store"
/>
<img src={appStoreImg} alt="Apple App Store" />
</Button>
<Button
href={appLinkAndroid}
href={googlePlayAppLink}
target="_blank"
size="lg"
className="mb-3 bg-gray-900 p-2"
className="mb-3 mobile-button"
block
aria-label={intl.formatMessage(
messages.certificateModalGooglePlayBtn,
)}
>
<img
src={googlePlayImg}
style={{ maxHeight: '2rem' }}
alt="Google Play"
/>
<img src={googlePlayImg} alt="Google Play" />
</Button>
<p />
<ol>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.buttons-wrapper {
margin-top: 25px;

img {
max-height: 44px;
}
}

.copy-link {
font-size: 14px;
color: #152F52;
cursor: pointer;
background: none;
border: none;
margin: 0;
padding: 0;

&:hover {
color: #000;
}

svg {
width: 20px;
height: 20px;
margin-right: 7px;
}
}

.mobile-button {
background-color: #000;
padding: 0 !important;
border: none;

img {
max-height: 44px;
}
}
5 changes: 5 additions & 0 deletions src/components/ProgramCertificateModal/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ const messages = defineMessages({
defaultMessage: 'QR code to obtain the verifiable credential',
description: 'The label for verifiable credential QR code',
},
certificateModalCopyLinkLabel: {
id: 'credentials.modal.copyLink.label',
defaultMessage: 'Copy link',
description: 'Label for copy link from QR code',
},
credentialsModalError: {
id: 'credentials.modal.error',
defaultMessage:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function ProgramCertificatesList({ intl }) {
const [modalIsOpen, openModal, closeModal] = useToggle(false);

const [
verfifiableCredentialIssuanceData,
verifiableCredentialIssuanceData,
setVerifiableCredentialIssuanceData,
] = useState({});

Expand Down Expand Up @@ -171,7 +171,7 @@ function ProgramCertificatesList({ intl }) {
<ProgramCertificateModal
isOpen={modalIsOpen}
close={closeModal}
data={verfifiableCredentialIssuanceData}
data={verifiableCredentialIssuanceData}
/>
</main>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('program-certificates-list', () => {

it('renders the Program Certificates List', () => {
render(<ProgramCertificatesList />);

expect(screen.getByText('Verifiable Credentials')).toBeTruthy();
expect(screen.getByText('Back to My Profile')).toBeTruthy();
expect(screen.getByText('Questions about Verifiable Credentials?')).toBeTruthy();
Expand Down
1 change: 1 addition & 0 deletions src/components/index.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
@import './ProgramRecord/ProgramRecord.scss';
@import './ProgramRecordSendModal/SendLearnerRecordModal.scss';
@import './ProgramCertificateModal/ProgramCertificateModal.scss';

0 comments on commit 1fda588

Please sign in to comment.