Skip to content

Commit

Permalink
Fix/Coping URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryczko authored Sep 6, 2023
1 parent 982670f commit f918ac9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LinkIcon } from '@heroicons/react/outline';
import React, { useCallback, useRef } from 'react';
import React from 'react';
import Button, { ButtonVariant } from 'shared/components/Button/Button';
import StyledDialog from 'shared/components/StyledDialog/StyledDialog';
import useTranslation from 'next-translate/useTranslation';
Expand All @@ -18,40 +18,24 @@ export default function ShareSurveyModal({
}: ShareSurveyModalProps) {
const { t } = useTranslation('common');
const { copy } = useCopyToClipboard();
const inputEl = useRef<HTMLInputElement>(null);

const link = `${window.location.protocol}//${window.location.host}/survey/${surveyId}`;

const handleCopy = () => {
copy(link);

if (inputEl.current) {
inputEl.current.select();
}
};

const handleInputFocus = useCallback(
(e: React.FocusEvent<HTMLInputElement>) => {
e.target.select();
},
[]
);

return (
<StyledDialog
isOpen={isOpened}
onClose={closeModal}
title={t('shareSurveyModal.title')}
contentClassName="!w-[800px]"
content={
<>
<div className="mt-4">
<input
onFocus={handleInputFocus}
ref={inputEl}
className="block w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:outline-none"
value={`${link}`}
/>
<span className="block w-full select-all break-words rounded-md border border-gray-300 px-3 py-2 text-center text-sm focus:outline-none">
{link}
</span>
</div>

<div className="mt-4 flex flex-col-reverse justify-between gap-2 sm:flex-row">
Expand Down
4 changes: 2 additions & 2 deletions src/shared/components/StyledDialog/StyledDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function StyledDialog({
isOpen,
onClose,
contentClassName = '',
centerTitle = false,
centerTitle = true,
}: StyledDialogProps) {
return (
<Transition appear show={isOpen} as={Fragment}>
Expand Down Expand Up @@ -47,7 +47,7 @@ export default function StyledDialog({
>
<Dialog.Panel
className={clsx(
'flex w-auto max-w-md flex-col justify-center overflow-hidden rounded-md bg-white p-6 text-left shadow-xl transition-all',
'flex w-auto max-w-lg flex-col justify-center overflow-hidden rounded-md bg-white p-6 text-left shadow-xl transition-all',
contentClassName
)}
>
Expand Down

1 comment on commit f918ac9

@vercel
Copy link

@vercel vercel bot commented on f918ac9 Sep 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

formslab – ./

formslab-ryczko.vercel.app
formslab.vercel.app
formslab-git-main-ryczko.vercel.app

Please sign in to comment.