Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
copying event code
Browse files Browse the repository at this point in the history
our original method did not work with the site having https certifications.
  • Loading branch information
mirmirmirr committed Dec 3, 2024
1 parent 2e01ac5 commit 7118a4f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 16 deletions.
31 changes: 22 additions & 9 deletions src/pages/ConfirmCreated.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,28 @@ export default function ConfirmCreated() {
const [copySuccess, setCopySuccess] = useState(false);

const handleCopy = () => {
navigator.clipboard
.writeText(eventCode)
.then(() => {
setCopySuccess(true);
setTimeout(() => setCopySuccess(false), 2000);
})
.catch((err) => {
console.error('Failed to copy text: ', err);
});
// navigator.clipboard
// .writeText(eventCode)
// .then(() => {
// setCopySuccess(true);
// setTimeout(() => setCopySuccess(false), 2000);
// })
// .catch((err) => {
// console.error('Failed to copy text: ', err);
// });

const textArea = document.createElement('textarea');
textArea.value = eventCode;
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand('copy');
setCopySuccess(true);
setTimeout(() => setCopySuccess(false), 2000);
} catch (err) {
console.error('Unable to copy to clipboard', err);
}
document.body.removeChild(textArea);
};

// Styling based on the current theme
Expand Down
24 changes: 18 additions & 6 deletions src/pages/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,26 @@ export default function Dashboard() {
const [notification, setNotification] = useState('');

const handleCopyLink = async (event) => {
const textArea = document.createElement('textarea');
textArea.value = event.code;
document.body.appendChild(textArea);
textArea.select();
try {
navigator.clipboard.writeText(event.code).then(() => {
setNotification('Link copied to clipboard');
setTimeout(() => setNotification(''), 3000);
});
} catch (error) {
console.error('Error copying link:', error);
document.execCommand('copy');
setNotification('Link copied');
} catch (err) {
console.error('Unable to copy to clipboard', err);
}
document.body.removeChild(textArea);

// try {
// navigator.clipboard.writeText(event.code).then(() => {
// setNotification('Link copied to clipboard');
// setTimeout(() => setNotification(''), 3000);
// });
// } catch (error) {
// console.error('Error copying link:', error);
// }
};

const handleViewBookingLink = async (event) => {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export default function Login() {
</div>

{/*login form */}
<div className="w-full lg:w-1/2 flex flex-col items-center space-y-4 p-6">
<div className="w-full lg:w-1/2 h-[90vh] flex flex-col items-center space-y-4 p-6">
{error.error && (
<div
className={`hidden lg:block absolute w-[35vw] h-8 mb-4 -mt-8 bg-[#FF5C5C] flex items-center justify-center ${isDarkMode ? 'text-white' : 'text-black'}`}
Expand Down

0 comments on commit 7118a4f

Please sign in to comment.