Skip to content

Commit d014588

Browse files
tindevwviljeno
andcommitted
Fix comment
Co-authored-by: viljeno <[email protected]>
1 parent 65d7ac3 commit d014588

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

lego-webapp/app/routes/events/components/EventDetail/index.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,10 @@ const EventDetail = () => {
312312

313313
<Line />
314314

315-
{loggedIn && (
316-
<ShareButton
317-
title={event?.title || 'Sjekk ut dette arrangementet!'}
318-
url={`${appConfig?.webUrl}/events/${event?.id}`}
319-
/>
320-
)}
315+
<ShareButton
316+
title={'Del arrangement'}
317+
url={`${appConfig?.webUrl}/events/${event?.id}`}
318+
/>
321319

322320
{(actionGrant.includes('edit') || actionGrant.includes('delete')) && (
323321
<Line />

lego-webapp/app/routes/joblistings/components/JoblistingDetail.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import DisplayContent from '~/components/DisplayContent';
1313
import InfoList from '~/components/InfoList';
1414
import { jobType, Year, Workplaces } from '~/components/JoblistingItem/Items';
1515
import PropertyHelmet from '~/components/PropertyHelmet';
16+
import ShareButton from '~/components/ShareButton';
1617
import Time from '~/components/Time';
1718
import { fetchJoblisting } from '~/redux/actions/JoblistingActions';
1819
import { useAppDispatch, useAppSelector } from '~/redux/hooks';
@@ -185,6 +186,11 @@ const JoblistingDetail = () => {
185186
</LinkButton>
186187
)}
187188

189+
<ShareButton
190+
title={'Del jobbannonse'}
191+
url={`${appConfig?.webUrl}/joblistings/${joblisting?.id}`}
192+
/>
193+
188194
{(joblisting.responsible || joblisting.contactMail) && (
189195
<div>
190196
<h3>Kontaktinfo</h3>

lego-webapp/components/ShareButton/index.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,8 @@ type Props = {
1111
const ShareButton: React.FC<Props> = ({ title, url }) => {
1212
const dispatch = useAppDispatch();
1313
const handleShare = async () => {
14-
if (navigator.share) {
15-
try {
16-
await navigator.share({ title, url });
17-
} catch (error) {
18-
console.error('Kunne ikke dele:', error);
19-
}
14+
if (navigator?.canShare?.({ title, url })) {
15+
navigator.share({ title, url });
2016
} else {
2117
{
2218
navigator.clipboard.writeText(url);
@@ -25,16 +21,16 @@ const ShareButton: React.FC<Props> = ({ title, url }) => {
2521
addToast({
2622
message: 'Link er kopiert til utklippstavlen',
2723
type: 'success',
28-
dismissAfter: 10000,
2924
}),
3025
);
3126
}
3227
};
3328

3429
return (
3530
<Button onPress={handleShare}>
36-
<Flex justifyContent="center">
37-
<Icon name="share" iconNode={<ShareIcon />} size={20} />
31+
<Flex justifyContent="center" gap="var(--spacing-sm)">
32+
<Icon iconNode={<ShareIcon />} size={20} />
33+
{title}
3834
</Flex>
3935
</Button>
4036
);

0 commit comments

Comments
 (0)