File tree Expand file tree Collapse file tree 3 files changed +15
-15
lines changed
events/components/EventDetail Expand file tree Collapse file tree 3 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -312,12 +312,10 @@ const EventDetail = () => {
312
312
313
313
< Line />
314
314
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
+ />
321
319
322
320
{ ( actionGrant . includes ( 'edit' ) || actionGrant . includes ( 'delete' ) ) && (
323
321
< Line />
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import DisplayContent from '~/components/DisplayContent';
13
13
import InfoList from '~/components/InfoList' ;
14
14
import { jobType , Year , Workplaces } from '~/components/JoblistingItem/Items' ;
15
15
import PropertyHelmet from '~/components/PropertyHelmet' ;
16
+ import ShareButton from '~/components/ShareButton' ;
16
17
import Time from '~/components/Time' ;
17
18
import { fetchJoblisting } from '~/redux/actions/JoblistingActions' ;
18
19
import { useAppDispatch , useAppSelector } from '~/redux/hooks' ;
@@ -185,6 +186,11 @@ const JoblistingDetail = () => {
185
186
</ LinkButton >
186
187
) }
187
188
189
+ < ShareButton
190
+ title = { 'Del jobbannonse' }
191
+ url = { `${ appConfig ?. webUrl } /joblistings/${ joblisting ?. id } ` }
192
+ />
193
+
188
194
{ ( joblisting . responsible || joblisting . contactMail ) && (
189
195
< div >
190
196
< h3 > Kontaktinfo</ h3 >
Original file line number Diff line number Diff line change @@ -11,12 +11,8 @@ type Props = {
11
11
const ShareButton : React . FC < Props > = ( { title, url } ) => {
12
12
const dispatch = useAppDispatch ( ) ;
13
13
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 } ) ;
20
16
} else {
21
17
{
22
18
navigator . clipboard . writeText ( url ) ;
@@ -25,16 +21,16 @@ const ShareButton: React.FC<Props> = ({ title, url }) => {
25
21
addToast ( {
26
22
message : 'Link er kopiert til utklippstavlen' ,
27
23
type : 'success' ,
28
- dismissAfter : 10000 ,
29
24
} ) ,
30
25
) ;
31
26
}
32
27
} ;
33
28
34
29
return (
35
30
< 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 }
38
34
</ Flex >
39
35
</ Button >
40
36
) ;
You can’t perform that action at this time.
0 commit comments