Skip to content

Commit

Permalink
feat: add embed item action (#437)
Browse files Browse the repository at this point in the history
Co-authored-by: LinaYahya <[email protected]>
  • Loading branch information
spaenleh and LinaYahya authored Nov 16, 2023
1 parent 9eb0348 commit 1b64388
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 652 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
"@emotion/react": "11.11.1",
"@emotion/server": "11.11.0",
"@emotion/styled": "11.11.0",
"@graasp/query-client": "2.0.1",
"@graasp/sdk": "2.0.1",
"@graasp/query-client": "2.0.2",
"@graasp/sdk": "2.1.0",
"@graasp/translations": "1.19.4",
"@graasp/ui": "4.0.0",
"@graasp/ui": "4.0.1",
"@mui/icons-material": "5.14.3",
"@mui/lab": "5.0.0-alpha.140",
"@mui/material": "5.14.5",
Expand Down
11 changes: 9 additions & 2 deletions src/components/collection/CopyLinkButton.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { MouseEvent } from 'react';
import React, { MouseEvent, useContext } from 'react';

import CodeIcon from '@mui/icons-material/Code';
import IconButton from '@mui/material/IconButton';
import Tooltip from '@mui/material/Tooltip';

import { DiscriminatedItem } from '@graasp/sdk';
import { DiscriminatedItem, Triggers } from '@graasp/sdk';

import { useLibraryTranslation } from '../../config/i18n';
import notifier, {
Expand All @@ -13,13 +13,20 @@ import notifier, {
import { buildPlayerViewItemRoute } from '../../config/paths';
import LIBRARY from '../../langs/constants';
import { copyToClipboard } from '../../utils/clipboard';
import { QueryClientContext } from '../QueryClientContext';

export const useEmbedAction = (itemId?: DiscriminatedItem['id']) => {
const startEmbed = (event: MouseEvent<HTMLButtonElement>) => {
const link = buildPlayerViewItemRoute(itemId);
const { mutations } = useContext(QueryClientContext);

const { mutate: triggerAction } = mutations.usePostItemAction();
copyToClipboard(link, {
onSuccess: () => {
if (itemId) {
triggerAction({ itemId, payload: { type: Triggers.ItemEmbed } });
}

notifier({
type: COPY_RESOURCE_LINK_TO_CLIPBOARD.SUCCESS,
payload: {},
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/MyFavorites.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const MyFavorites = ({ tab, index }: Props) => {
<TabPanel value={tab} index={index}>
<CollectionsGrid
id={MY_FAVORITES_COLLECTIONS_ID}
collections={collections as any}
collections={collections}
isLoading={isLoading}
/>
</TabPanel>
Expand Down
Loading

0 comments on commit 1b64388

Please sign in to comment.