diff --git a/src/components/PostDrawer.tsx b/src/components/PostDrawer.tsx index b7dd5df8..714e66d7 100644 --- a/src/components/PostDrawer.tsx +++ b/src/components/PostDrawer.tsx @@ -46,21 +46,10 @@ export const PostDrawer = ({ Link, Image.configure({ inline: true, allowBase64: true }), ], - onUpdate({ editor }) { - const newContent = editor.getJSON(); - localStorage.setItem(posterId, JSON.stringify(newContent)); - }, content, }); const { tx } = useTx(); - useEffect(() => { - const draft = localStorage.getItem(posterId); - if (editor && draft) { - editor.commands.setContent(JSON.parse(draft)); - } - }, [posterId, editor]); - const isOpen = location.pathname.includes('post'); const onClose = () => @@ -121,7 +110,6 @@ export const PostDrawer = ({ writeContractOptions: { onPollSuccess() { refetch?.(); - localStorage.removeItem(posterId); }, }, }); diff --git a/src/components/RTEditor.tsx b/src/components/RTEditor.tsx index 2ed3e870..c67fca53 100644 --- a/src/components/RTEditor.tsx +++ b/src/components/RTEditor.tsx @@ -40,6 +40,7 @@ export const RTEditor = ({ ref={editorContainerRef} bg={'transparent'} classNames={{ root: classes.editor }} + onClick={handleContentEditorFocus} > @@ -65,8 +66,6 @@ export const RTEditor = ({ p="lg" fz="md" bg={'transparent'} - // mih={editorHeight} - // h="100%" onClick={handleContentEditorFocus} /> diff --git a/src/components/dashboard/facilitator/FacPostUpdatePanel.tsx b/src/components/dashboard/facilitator/FacPostUpdatePanel.tsx index ae825a41..c9c5a414 100644 --- a/src/components/dashboard/facilitator/FacPostUpdatePanel.tsx +++ b/src/components/dashboard/facilitator/FacPostUpdatePanel.tsx @@ -1,36 +1,42 @@ -import React from 'react'; import { DAO_MASONS } from '../../../constants/gameSetup'; -import { UpdateInput } from '../../forms/UpdateInput'; -import { PINATA_GATEWAY } from '../../../utils/ipfs/get'; +import { getGatewayUrl } from '../../../utils/ipfs/get'; import { useTx } from '../../../hooks/useTx'; import GameManagerAbi from '../../../abi/GameManager.json'; import { ADDR } from '../../../constants/addresses'; import { Tag } from '../../../constants/tags'; import { notifications } from '@mantine/notifications'; -import { - ContentSchema, - basicUpdateSchema, -} from '../../forms/validationSchemas/updateSchemas'; + import { pinJSONToIPFS } from '../../../utils/ipfs/pin'; +import { Group } from '@mantine/core'; +import { PlayerAvatar } from '../../PlayerAvatar'; +import { Player } from '../../../types/ui'; +import { TxButton } from '../../TxButton'; +import { IconPlus } from '@tabler/icons-react'; +import { RTEditor } from '../../RTEditor'; +import { useEditor } from '@tiptap/react'; +import StarterKit from '@tiptap/starter-kit'; +import Link from '@tiptap/extension-link'; +import Image from '@tiptap/extension-image'; +import { tiptapContentSchema } from '../../forms/validationSchemas/tiptap'; +import { useGameManager } from '../../../hooks/useGameMangers'; +const defaultContent = { type: 'doc', content: [] }; export const FacPostUpdatePanel = () => { const { tx } = useTx(); + const { refetchGameManager } = useGameManager(); - const handlePostUpdate = async (text: string, clear: () => void) => { - if (text === '' || text === null) { - notifications.show({ - title: 'Error', - message: 'Update text is missing', - color: 'red', - }); + const editor = useEditor({ + extensions: [ + StarterKit, + Link, + Image.configure({ inline: true, allowBase64: true }), + ], - return; - } + content: defaultContent, + }); - const metadata = basicUpdateSchema.safeParse({ - text, - contentSchema: ContentSchema.BasicUpdate, - }); + const handlePostUpdate = async () => { + const metadata = tiptapContentSchema.safeParse(editor?.getJSON()); if (!metadata.success) { notifications.show({ @@ -61,15 +67,32 @@ export const FacPostUpdatePanel = () => { args: [Tag.GameUpdate, [1n, pinRes.IpfsHash]], }, onComplete() { - clear?.(); + refetchGameManager(); + editor?.commands.setContent(defaultContent); }, }); }; return ( - + <> + + + + } onClick={handlePostUpdate}> + Post + + + + + ); }; + +// diff --git a/src/components/feed/FeedCard.tsx b/src/components/feed/FeedCard.tsx index 0c30cd94..b1e5b99a 100644 --- a/src/components/feed/FeedCard.tsx +++ b/src/components/feed/FeedCard.tsx @@ -29,7 +29,6 @@ import { Link } from 'react-router-dom'; import { GAME_TOKEN } from '../../constants/gameSetup'; import { useElementSize, useIntersection } from '@mantine/hooks'; import { IconAward } from '@tabler/icons-react'; - import { PlayerAvatar } from '../PlayerAvatar'; import { Content } from '@tiptap/react'; import { RTDisplay } from '../RTDisplay'; @@ -246,13 +245,20 @@ export const FeedCard = ({ if (internalLink) { return ( - - + + + {Inner} @@ -261,15 +267,22 @@ export const FeedCard = ({ if (externalLink) { return ( - - + - {Inner} - + target="_blank" + rel="noopener noreferrer" + style={{ + textDecoration: 'none', + position: 'absolute', + top: 0, + left: 0, + bottom: 0, + right: 0, + zIndex: 1, + }} + /> + {Inner} ); } diff --git a/src/components/feed/RichTextUpdate.tsx b/src/components/feed/RichTextUpdate.tsx index d6ad945b..9f6accbc 100644 --- a/src/components/feed/RichTextUpdate.tsx +++ b/src/components/feed/RichTextUpdate.tsx @@ -12,6 +12,9 @@ import { secondsToShortRelativeTime } from '../../utils/time'; import { AddressAvatar } from '../AddressAvatar'; import { Address } from 'viem'; import { RTDisplay } from '../RTDisplay'; +import { Player } from '../../types/ui'; +import { getGatewayUrl } from '../../utils/ipfs/get'; +import { DAO_MASONS } from '../../constants/gameSetup'; export const getRTUpdate = async (id: string, chainId: number) => { const { getRTUpdate } = getBuiltGraphSDK(); @@ -21,7 +24,7 @@ export const getRTUpdate = async (id: string, chainId: number) => { chainId: chainId, }); - if (!Update) { + if (!Update[0].content) { throw new Error('No update found'); } @@ -77,10 +80,24 @@ export const RichTextUpdate = () => { return Error: {error.message}; } - if (!update || !update.content || !update.posterProfile) { + if (!update || !update.content) { return 404: No update found; } + const imgUrl = + update.playerType === Player.Facilitators + ? getGatewayUrl(DAO_MASONS.AVATAR_IMG) + : update?.posterProfile?.imgUrl + ? update.posterProfile.imgUrl + : '?'; + + const name = + update?.playerType === Player.Facilitators + ? 'Facilitators' + : update?.posterProfile?.name + ? update?.posterProfile?.name + : 'Unknown'; + return ( @@ -88,8 +105,8 @@ export const RichTextUpdate = () => { ยท diff --git a/src/components/grant/ApplicationDrawer.tsx b/src/components/grant/ApplicationDrawer.tsx index 63e20e4e..35778a8d 100644 --- a/src/components/grant/ApplicationDrawer.tsx +++ b/src/components/grant/ApplicationDrawer.tsx @@ -216,8 +216,9 @@ export const ApplicationDrawer = ({ {alreadyHasApplication && currentApplication.status !== GameStatus.Rejected && ( - You have already submitted an application. Resubmitting an old - application will overwrite the previous one. + WARNING: You have already submitted an application. Resubmitting an + old application will overwrite the previous one and restart the + grant process from the beginning. )} diff --git a/src/components/grant/FacilitatorActions.tsx b/src/components/grant/FacilitatorActions.tsx index 51d8e02b..a796b9b6 100644 --- a/src/components/grant/FacilitatorActions.tsx +++ b/src/components/grant/FacilitatorActions.tsx @@ -3,13 +3,18 @@ import { useDisclosure } from '@mantine/hooks'; import { IconPlus } from '@tabler/icons-react'; import { FacilitatorApprovalDrawer } from './FacilitatorApprovalDrawer'; import { useGrant } from '../../hooks/useGrant'; -import { GameStatus, GrantStatus } from '../../types/common'; +import { GrantStatus } from '../../types/common'; +import { DAO_MASONS } from '../../constants/gameSetup'; +import { Player } from '../../types/ui'; +import { PostGrantDrawer } from './PostGrantDrawer'; +import { getGatewayUrl } from '../../utils/ipfs/get'; export const FacilitatorActions = () => { const [approvalOpened, { open: openApprove, close: closeApprove }] = useDisclosure(); + const [postOpened, { open: openPost, close: closePost }] = useDisclosure(); - const { grant } = useGrant(); + const { grant, project, ship, refetchGrant } = useGrant(); const isReadyToApprove = grant?.status === GrantStatus.MilestonesApproved; return ( @@ -24,11 +29,24 @@ export const FacilitatorActions = () => { Review Grantee )} + + ); }; diff --git a/src/components/grant/FacilitatorApprovalDrawer.tsx b/src/components/grant/FacilitatorApprovalDrawer.tsx index 587856fd..8ff88b74 100644 --- a/src/components/grant/FacilitatorApprovalDrawer.tsx +++ b/src/components/grant/FacilitatorApprovalDrawer.tsx @@ -64,9 +64,6 @@ export const FacilitatorApprovalDrawer = ({ ] ); - console.log('encoded', encoded); - console.log('ship.poolId', ship.poolId); - tx({ writeContractParams: { abi: AlloAbi, diff --git a/src/components/grant/GrantTimeline.tsx b/src/components/grant/GrantTimeline.tsx index 876121ef..8761e877 100644 --- a/src/components/grant/GrantTimeline.tsx +++ b/src/components/grant/GrantTimeline.tsx @@ -18,6 +18,8 @@ import { FundsDistributed } from './FundsDistributed'; import { GrantHelper } from './GrantHelpers'; import { InsetUpdate } from './InsetUpdate'; import { IconMail } from '@tabler/icons-react'; +import { DAO_MASONS } from '../../constants/gameSetup'; +import { getGatewayUrl } from '../../utils/ipfs/get'; export const GrantTimeline = () => { const { timeline, ship, project } = useGrant(); @@ -42,7 +44,6 @@ export const GrantTimeline = () => { } if (item.tag === 'grant/update/ship') { const update = item as GrantUpdate; - return ( { /> ); } + if (item.tag === 'grant/update/facilitator') { + const update = item as GrantUpdate; + return ( + + ); + } if (item.tag === 'grant/invite/ship') { const update = item as GrantUpdate; - return ( { useDisclosure(); const isApplicationStage = - !grant || (grant?.status && grant.status < GrantStatus.ApplicationApproved); + !grant || (grant?.status && grant.status < GrantStatus.MilestonesApproved); + const isMilestonePlanning = grant?.status && grant.status >= GrantStatus.ApplicationApproved && @@ -45,6 +46,20 @@ export const ProjectActions = () => { return ( <> + {isApplicationStage && alreadyHasApplication && ( + + )} + {isMilestonePlanning && ( )} - {isApplicationStage && alreadyHasApplication && ( - - )} - {isApplicationStage && !alreadyHasApplication && (