@@ -15,8 +15,13 @@ import {
1515 getSymbolFromCurrency ,
1616 Link ,
1717 TextRenderer ,
18+ useToast ,
1819} from "@courselit/components-library" ;
19- import { ProfileContext , SiteInfoContext } from "@components/contexts" ;
20+ import {
21+ AddressContext ,
22+ ProfileContext ,
23+ SiteInfoContext ,
24+ } from "@components/contexts" ;
2025import {
2126 Dialog ,
2227 DialogContent ,
@@ -27,7 +32,8 @@ import {
2732 DialogTrigger ,
2833} from "@components/ui/dialog" ;
2934import { checkPermission } from "@courselit/utils" ;
30- import { COMMUNITY_SETTINGS } from "@ui-config/strings" ;
35+ import { COMMUNITY_SETTINGS , TOAST_TITLE_SUCCESS } from "@ui-config/strings" ;
36+ import { Share2 } from "lucide-react" ;
3137const { permissions } = UIConstants ;
3238
3339interface CommunityInfoProps {
@@ -40,6 +46,7 @@ interface CommunityInfoProps {
4046 rejectionReason ?: string ;
4147 paymentPlan : PaymentPlan ;
4248 joiningReasonText ?: string ;
49+ pageId : string ;
4350 onJoin : ( joiningReason ?: string ) => void ;
4451 onLeave : ( ) => void ;
4552}
@@ -54,17 +61,20 @@ export function CommunityInfo({
5461 rejectionReason,
5562 paymentPlan,
5663 joiningReasonText,
64+ pageId,
5765 onJoin,
5866 onLeave,
5967} : CommunityInfoProps ) {
6068 const [ showLeaveConfirmation , setShowLeaveConfirmation ] = useState ( false ) ;
6169 const [ isJoinDialogOpen , setIsJoinDialogOpen ] = useState ( false ) ;
6270 const [ joiningReason , setJoiningReason ] = useState ( "" ) ;
6371 const { amount, period } = getPlanPrice ( paymentPlan ) ;
72+ const address = useContext ( AddressContext ) ;
6473 const siteinfo = useContext ( SiteInfoContext ) ;
6574 const { profile } = useContext ( ProfileContext ) ;
6675 const currencySymbol =
6776 getSymbolFromCurrency ( siteinfo . currencyISOCode || "USD" ) || "$" ;
77+ const { toast } = useToast ( ) ;
6878
6979 const handleJoinSubmit = async ( e : FormEvent ) => {
7080 e . preventDefault ( ) ;
@@ -80,10 +90,25 @@ export function CommunityInfo({
8090 setShowLeaveConfirmation ( false ) ;
8191 } ;
8292
93+ const handleShareClick = ( ) => {
94+ navigator . clipboard . writeText ( `${ address . frontend } /p/${ pageId } ` ) ;
95+ toast ( {
96+ title : TOAST_TITLE_SUCCESS ,
97+ description : "Page ID copied to clipboard!" ,
98+ } ) ;
99+ } ;
100+
83101 return (
84102 < Card >
85- < CardHeader >
86- < CardTitle > { name } </ CardTitle >
103+ < CardHeader className = "flex justify-between items-center w-full" >
104+ < CardTitle className = "w-full" >
105+ < div class = "flex justify-between items-center w-full" >
106+ < p > { name } </ p >
107+ < Button variant = "ghost" onClick = { handleShareClick } >
108+ < Share2 className = "h-5 w-5" />
109+ </ Button >
110+ </ div >
111+ </ CardTitle >
87112 </ CardHeader >
88113 < CardContent className = "space-y-4" >
89114 < img
0 commit comments