-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/Official-MoonDao/MoonDAO in…
…to update-jobs-cards
- Loading branch information
Showing
52 changed files
with
2,611 additions
and
440 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"MOONEYToken": "0x3B3024e49261866a420F2444Fa1f248902C8D143", | ||
"vMOONEYToken": "0xa83aceC4e6784a0c9C4Ba6fa414665Ba15F6F3b6" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"MOONEYToken": "0x6585a54A98fADA893904EB8A9E9CDFb927bddf39", | ||
"vMOONEYToken": "0x7f8f1B45c3FD6Be4F467520Fc1Cf030d5CaBAcF5" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
NEXT_PUBLIC_CHAIN=mumbai | ||
NEXT_PUBLIC_VMOONEY_REQUIRED_STAKE=1 | ||
NEXT_PUBLIC_SNAPSHOT_API_KEY=placeholder | ||
COORDINAPE_API_KEY=placeholder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import dynamic from "next/dynamic"; | ||
import { usePrivy, getAccessToken } from "@privy-io/react-auth"; | ||
import { GetMarkdown, SetMarkdown } from "@nance/nance-editor"; | ||
import { LoadingSpinner } from "@/components/layout/LoadingSpinner"; | ||
import { pinBlobOrFile } from "@/lib/ipfs/pinBlobOrFile"; | ||
import { createSession, destroySession } from "@/lib/iron-session/iron-session"; | ||
import useAccount from "@/lib/nance/useAccountAddress"; | ||
import { toast } from "react-hot-toast"; | ||
import "@nance/nance-editor/lib/css/dark.css"; | ||
import "@nance/nance-editor/lib/css/editor.css"; | ||
|
||
let getMarkdown: GetMarkdown; | ||
let setMarkdown: SetMarkdown; | ||
|
||
const NanceEditor = dynamic( | ||
async () => { | ||
const editorModule = await import("@nance/nance-editor"); | ||
getMarkdown = editorModule.getMarkdown; | ||
setMarkdown = editorModule.setMarkdown; | ||
return editorModule.NanceEditor; | ||
}, | ||
{ | ||
ssr: false, | ||
loading: () => <LoadingSpinner />, | ||
} | ||
); | ||
|
||
const CONTRIBUTION_TEMPLATE = ` | ||
## Contribution Summary | ||
When documenting contributions, please ensure they meet the following criteria: | ||
1. Completed Work Only: Contributions should reflect completed efforts, not ongoing or planned work. | ||
2. Specific and Measurable Results: Describe the tangible outcomes of the contribution. Include metrics, timelines, or other objective measures wherever possible. | ||
Clear, detailed, and results-focused contributions help us understand and value the impact of your work. | ||
*Example:* | ||
*Good Contribution:* | ||
• *"Improved search performance by optimizing database queries, reducing response times by 30% within one month."* | ||
*Poor Contribution:* | ||
• *"Worked on improving search performance."* | ||
`; | ||
|
||
const ContributionEditor: React.FC = () => { | ||
const { authenticated } = usePrivy(); | ||
const [submitting, setSubmitting] = useState(false); | ||
const [coordinapeLink, setCoordinapeLink] = useState<string | null>(null); | ||
const { address } = useAccount(); | ||
|
||
useEffect(() => { | ||
if (setMarkdown) { | ||
setMarkdown(CONTRIBUTION_TEMPLATE); | ||
} | ||
}, []); | ||
|
||
const handleSubmit = async () => { | ||
if (!authenticated) { | ||
toast.error("Please sign in to submit a contribution!"); | ||
return; | ||
} | ||
|
||
setSubmitting(true); | ||
const accessToken = await getAccessToken(); | ||
await createSession(accessToken); | ||
const loadingToast = toast.loading("Submitting contribution..."); | ||
|
||
try { | ||
const body = JSON.stringify({ | ||
description: getMarkdown(), | ||
address, | ||
}); | ||
|
||
const res = await fetch("/api/coordinape/createContribution", { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
Authorization: `Bearer ${accessToken}` | ||
}, | ||
body | ||
}); | ||
await destroySession(accessToken); | ||
const data = await res.json(); | ||
|
||
if (!res.ok) { | ||
throw new Error(data.error); | ||
} | ||
|
||
setCoordinapeLink(`https://app.coordinape.com/circles/${data.insert_contributions_one.circle_id}`); | ||
toast.success("Contribution submitted successfully!"); | ||
} catch (err) { | ||
toast.error("Failed to submit contribution"); | ||
} finally { | ||
toast.dismiss(loadingToast); | ||
setSubmitting(false); | ||
} | ||
}; | ||
|
||
if (!authenticated) { | ||
return <p className="py-24">Please sign in to submit a contribution!</p>; | ||
} | ||
|
||
if (coordinapeLink) { | ||
return ( | ||
<div className="w-full flex flex-col justify-center items-center md:w-auto space-y-4 pb-12"> | ||
<p className="text-2xl">Contribution submitted!</p> | ||
<p> | ||
View and edit your contribution {" "} | ||
<a href={coordinapeLink} target="_blank" rel="noopener noreferrer" className="underline"> | ||
here | ||
</a> | ||
</p> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div className="w-full md:w-auto px-4 sm:px-0"> | ||
<div className="h-[600px]"> | ||
<NanceEditor | ||
initialValue={CONTRIBUTION_TEMPLATE} | ||
fileUploadExternal={ async (val) => { | ||
const accessToken = await getAccessToken() | ||
await createSession(accessToken) | ||
const res = await pinBlobOrFile(val) | ||
await destroySession(accessToken) | ||
return res.url; | ||
}} | ||
darkMode={true} | ||
/> | ||
</div> | ||
<div className="flex justify-end"> | ||
<button | ||
type="submit" | ||
className="gradient-2 hover:pl-7 disabled:pl-5 disabled:opacity-30 transition-all ease-in-out duration-300 rounded-[2vmax] rounded-tl-[10px] mt-5 px-5 py-3 inline-block disabled:transform-none disabled:cursor-not-allowed" | ||
disabled={submitting} | ||
onClick={handleSubmit} | ||
> | ||
Submit Contribution | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ContributionEditor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.