MCPcopy Create free account
hub / github.com/artsy/force / ShareCollectionDialog

Function ShareCollectionDialog

src/Components/ShareCollectionDialog.tsx:33–158  ·  view source on GitHub ↗
({ onClose, collection })

Source from the content-addressed store, hash-verified

31export const ShareCollectionDialog: React.FC<
32 React.PropsWithChildren<ShareCollectionDialogProps>
33> = ({ onClose, collection }) => {
34 const { user } = useSystemContext()
35 const { trackEvent } = useTracking()
36 const [isShared, setIsShared] = useState(!collection.private)
37 const [isUpdating, setIsUpdating] = useState(false)
38 const [copyMode, setCopyMode] = useState<"Idle" | "Copied">("Idle")
39 const [slug, setSlug] = useState<string | null | undefined>(collection.slug)
40
41 const handleClick = () => {
42 navigator?.clipboard.writeText(url)
43 setCopyMode("Copied")
44
45 trackEvent(tracks.clickedCopyButton(collection.internalID))
46
47 setTimeout(() => {
48 setCopyMode("Idle")
49 }, 2000)
50 }
51
52 const handleOpenInNewTab = () => {
53 trackEvent(tracks.clickedOpenInNewTab(collection.internalID))
54 }
55
56 const { submitMutation } = useMutation<ShareCollectionDialogMutation>({
57 mutation: graphql`
58 mutation ShareCollectionDialogMutation($input: updateCollectionInput!) {
59 updateCollection(input: $input) {
60 clientMutationId
61 responseOrError {
62 ... on UpdateCollectionFailure {
63 mutationError {
64 message
65 }
66 }
67 ... on UpdateCollectionSuccess {
68 collection {
69 internalID
70 slug
71 private
72 }
73 }
74 }
75 }
76 }
77 `,
78 })
79
80 const { sendToast } = useToasts()
81
82 const handleToggle = async toggleValue => {
83 try {
84 setIsUpdating(true)
85 const result = await submitMutation({
86 variables: {
87 input: {
88 id: collection.internalID,
89 private: !toggleValue, // negate the toggle, because the flag is for 'private', not 'public'
90 },

Callers

nothing calls this directly

Calls 4

useSystemContextFunction · 0.90
useMutationFunction · 0.90
graphqlFunction · 0.90
getENVFunction · 0.90

Tested by

no test coverage detected