From 2a9b85c9b3a1969faec6d5d570b967811b1c403e Mon Sep 17 00:00:00 2001
From: Caleb Parikh
Date: Mon, 13 May 2024 16:49:52 -0600
Subject: [PATCH 01/12] added radio buttons to app form for ltff and eaif, add
some questions based on cause areas
---
app/create/create-project-form.tsx | 101 ++++++++++++++++++++---
components/checkbox.tsx | 126 +++++++++++++++++++++++++++++
2 files changed, 214 insertions(+), 13 deletions(-)
create mode 100644 components/checkbox.tsx
diff --git a/app/create/create-project-form.tsx b/app/create/create-project-form.tsx
index 0b1bbeb1..8bdecc61 100644
--- a/app/create/create-project-form.tsx
+++ b/app/create/create-project-form.tsx
@@ -24,7 +24,7 @@ import { Checkbox } from '@/components/input'
import { usePartialUpdater } from '@/hooks/user-partial-updater'
import { ProjectParams } from '@/utils/upsert-project'
-const DESCRIPTION_OUTLINE = `
+var DESCRIPTION_OUTLINE = `
Project summary
What are this project's goals and how will you achieve them?
@@ -38,8 +38,23 @@ const DESCRIPTION_OUTLINE = `
What other funding are you or your project getting?
`
+
+const LTFF_QUESTIONS = `
+LTFF QUESTIONS
+
+How will you solve x-risk?
+
+`
+const EAIF_QUESTIONS = `
+ EAIF QUESTIONS
+
+ How will you solve EA community building?
+
+`
+
const DESCRIPTION_KEY = 'ProjectDescription'
+
export function CreateProjectForm(props: { causesList: Cause[] }) {
const { causesList } = props
const [projectParams, updateProjectParams] = usePartialUpdater(
@@ -56,6 +71,8 @@ export function CreateProjectForm(props: { causesList: Cause[] }) {
}
)
const [isSubmitting, setIsSubmitting] = useState(false)
+ const [isLTFFSelected, setIsLTFFSelected] = useState(false);
+ const [isEAIFSelected, setIsEAIFSelected] = useState(false);
const editor = useTextEditor(DESCRIPTION_OUTLINE, DESCRIPTION_KEY)
const [madeChanges, setMadeChanges] = useState(false)
@@ -72,17 +89,26 @@ export function CreateProjectForm(props: { causesList: Cause[] }) {
(1 -
(projectParams.selectedPrize?.cert_params?.defaultInvestorShares ??
0) /
- TOTAL_SHARES) *
+ TOTAL_SHARES) *
100,
- })
+ });
if (!madeChanges) {
- editor?.commands.setContent(
- projectParams.selectedPrize?.project_description_outline ??
- DESCRIPTION_OUTLINE
- )
- setMadeChanges(false)
+ let descriptionOutline = projectParams.selectedPrize?.project_description_outline ??
+ DESCRIPTION_OUTLINE;
+ if (isLTFFSelected) {
+ descriptionOutline += LTFF_QUESTIONS;
+ }
+ if (isEAIFSelected) {
+ descriptionOutline += EAIF_QUESTIONS;
+ }
+ // Check for other causes and add their custom questions
+ // ...
+ editor?.commands.setContent(descriptionOutline);
+ setMadeChanges(false);
}
- }, [projectParams.selectedPrize])
+ }, [projectParams.selectedPrize, isLTFFSelected, isEAIFSelected]); // Add other cause selection state variables as dependencies
+
+
const selectablePrizeCauses = causesList.filter(
(cause) => cause.open && cause.prize
)
@@ -110,7 +136,7 @@ export function CreateProjectForm(props: { causesList: Cause[] }) {
body: JSON.stringify({ ...projectParams, description: finalDescription }),
})
const newProject = await response.json()
- router.push(`/projects/${newProject.slug}`)
+ router.push(`/ projects / ${newProject.slug} `)
clearLocalStorageItem(DESCRIPTION_KEY)
setIsSubmitting(false)
}
@@ -149,9 +175,7 @@ export function CreateProjectForm(props: { causesList: Cause[] }) {
selectedPrize:
value === 'grant'
? null
- : selectablePrizeCauses.find(
- (cause) => cause.slug === value
- ) ?? null,
+ : selectablePrizeCauses.find((cause) => cause.slug === value) ?? null,
})
}
options={{
@@ -161,6 +185,57 @@ export function CreateProjectForm(props: { causesList: Cause[] }) {
),
}}
/>
+
+
+
+ cause.slug === 'ltff')}
+ onChange={(event) => {
+ const { checked } = event.target;
+ const ltffCause = causesList.find((cause) => cause.slug === 'ltff');
+ updateProjectParams({
+ selectedCauses: checked
+ ? [...projectParams.selectedCauses, ltffCause]
+ : projectParams.selectedCauses.filter((cause) => cause.slug !== 'ltff'),
+ });
+ setIsLTFFSelected(checked);
+ }}
+ />
+
+ LTFF Grant
+
+
+
+ cause.slug === 'eaif')}
+ onChange={(event) => {
+ const { checked } = event.target;
+ const eaifCause = causesList.find((cause) => cause.slug === 'eaif');
+ updateProjectParams({
+ selectedCauses: checked
+ ? [...projectParams.selectedCauses, eaifCause]
+ : projectParams.selectedCauses.filter((cause) => cause.slug !== 'eaif'),
+ });
+ setIsEAIFSelected(checked);
+ }}
+ />
+
+ EAIF Grant
+
+
+
+
+
+
+
Selected Causes:
+
+ {projectParams.selectedCauses.map((cause) => (
+ - {cause.title}
+ ))}
+
+
+
+
-
- updateProjectParams({
- selectedPrize:
- value === 'grant'
- ? null
- : selectablePrizeCauses.find(
- (cause) => cause.slug === value
- ) ?? null,
- })
- }
- options={{
- grant: 'A regular grant',
- ...Object.fromEntries(
- selectablePrizeCauses.map((cause) => [cause.slug, cause.title])
- ),
- }}
- />
- updateProjectParams({ selectedCauses: newCauses })
- }
+ setSelectedCauses={(newCauses: (MiniCause | undefined)[]) =>
+ updateProjectParams({
+ selectedCauses: newCauses.filter(
+ (cause): cause is MiniCause => !!cause
+ ),
+ })
+ } //added a type assertion to filter out any undefined values from the newCauses array before updating the selectedCauses property.
/>
diff --git a/seed.sql b/seed.sql
index 4a3e4c92..d22d523e 100644
--- a/seed.sql
+++ b/seed.sql
@@ -14,6 +14,7 @@ create table public.profiles (
long_description jsonb,
regranter_status boolean not null,
stripe_connect_id text,
+ managed_causes jsonb,
primary key (id)
);
@@ -96,6 +97,7 @@ create table if not exists public.projects (
approved boolean,
signed_agreement boolean not null default false,
markets jsonb,
+ private bool,
primary key (id)
);
@@ -110,7 +112,7 @@ UPDATE
CREATE POLICY "Enable read access for all users" ON "public"."projects" AS PERMISSIVE FOR
SELECT
- TO public USING (true);
+ TO public USING (private = false);
CREATE POLICY "Enable update for austin based on email" ON "public"."projects" AS PERMISSIVE FOR
UPDATE
@@ -154,6 +156,24 @@ INSERT
AND auth.uid() :: text = (storage.foldername(name)) [1]
);
+CREATE POLICY "Allow user to see own private records"
+ON "public"."projects"
+TO authenticated
+USING ((( SELECT auth.uid() AS uid) = creator)
+);
+
+CREATE policy "Allow cause managers to see cause grants"
+ON "public"."projects"
+TO public
+USING (
+ ((private = false) OR (id IN ( SELECT projects.id
+ FROM project_causes
+ WHERE (project_causes.cause_slug IN ( SELECT jsonb_array_elements_text(profiles.managed_causes) AS jsonb_array_elements_text
+ FROM profiles
+ WHERE (profiles.id = auth.uid()))))))
+);
+
+
--
--
--
From 4916cb6ddcf3f6b68b7ed7f608ba225aafc1de70 Mon Sep 17 00:00:00 2001
From: Austin Chen
Date: Wed, 15 May 2024 16:35:19 -0700
Subject: [PATCH 09/12] Clean up multi-funder UI
---
app/create/create-project-form.tsx | 140 +++++++++++++++--------------
1 file changed, 73 insertions(+), 67 deletions(-)
diff --git a/app/create/create-project-form.tsx b/app/create/create-project-form.tsx
index aa3ea1e4..316e69f0 100644
--- a/app/create/create-project-form.tsx
+++ b/app/create/create-project-form.tsx
@@ -25,6 +25,7 @@ import { usePartialUpdater } from '@/hooks/user-partial-updater'
import { ProjectParams } from '@/utils/upsert-project'
import questionBank from '../questions/questionBank.json'
import questionChoicesData from '../questions/questionChoices.json'
+import { CheckCircleIcon } from '@heroicons/react/24/solid'
interface QuestionsData {
id: string
@@ -49,6 +50,7 @@ var DESCRIPTION_OUTLINE = `
What other funding are you or your project getting?
`
+const FUNDERS = ['ltff', 'eaif']
const addQuestionsToDescription = (
selectedCauses: string[],
@@ -133,8 +135,12 @@ export function CreateProjectForm(props: { causesList: Cause[] }) {
(cause) => cause.open && cause.prize
)
const selectableCauses = causesList.filter(
- (cause) => cause.open && !cause.prize
+ (cause) => cause.open && !cause.prize && !FUNDERS.includes(cause.slug)
)
+ const funderCauses = causesList.filter((cause) =>
+ FUNDERS.includes(cause.slug)
+ )
+
const minMinFunding = projectParams.selectedPrize?.cert_params
? projectParams.selectedPrize.cert_params.minMinFunding
: 500
@@ -176,10 +182,10 @@ export function CreateProjectForm(props: { causesList: Cause[] }) {
return (
-
Add a project
+ Propose a project
- I am applying for...
+ {/* I am applying for...
Select "a regular grant" by default. The other options are
specific prizes that you can learn more about{' '}
@@ -206,65 +212,7 @@ export function CreateProjectForm(props: { causesList: Cause[] }) {
selectablePrizeCauses.map((cause) => [cause.slug, cause.title])
),
}}
- />
-
-
- cause.slug === 'ltff'
- )}
- onChange={(event) => {
- const { checked } = event.target
- const ltffCause = causesList.find(
- (cause) => cause.slug === 'ltff'
- )
- updateProjectParams({
- selectedCauses: checked
- ? [...projectParams.selectedCauses, ltffCause]
- : projectParams.selectedCauses.filter(
- (cause) => cause.slug !== 'ltff'
- ),
- })
- setIsLTFFSelected(checked)
- }}
- />
-
- LTFF Grant
-
-
-
- cause.slug === 'eaif'
- )}
- onChange={(event) => {
- const { checked } = event.target
- const eaifCause = causesList.find(
- (cause) => cause.slug === 'eaif'
- )
- updateProjectParams({
- selectedCauses: checked
- ? [...projectParams.selectedCauses, eaifCause]
- : projectParams.selectedCauses.filter(
- (cause) => cause.slug !== 'eaif'
- ),
- })
- setIsEAIFSelected(checked)
- }}
- />
-
- EAIF Grant
-
-
-
-
-
Selected Causes:
-
- {projectParams.selectedCauses.map((cause) => (
- - {cause.title}
- ))}
-
-
+ /> */}
@@ -287,6 +235,7 @@ export function CreateProjectForm(props: { causesList: Cause[] }) {
+
Subtitle
@@ -305,6 +254,62 @@ export function CreateProjectForm(props: { causesList: Cause[] }) {
+
+
+ Common app funders
+
+ Choose additional funders to review your project. Funders may ask
+ supplemental questions.
+
+
+
+ updateProjectParams({ selectedCauses: newCauses })
+ }
+ />
+ {projectParams.selectedCauses.map((c) => c.slug).includes('ltff') && (
+
+
+
+ Applying to{' '}
+
+ Long-Term Future Fund
+
+
+
+ Funds people or projects that aim to improve the long-term future,
+ such as by reducing risks from artificial intelligence and
+ engineered pandemics
+
+
+ )}
+ {projectParams.selectedCauses.map((c) => c.slug).includes('eaif') && (
+
+
+
+ Applying to{' '}
+
+ EA Infrastructure Fund
+
+
+
+ Funds organizations or people that aim to grow or improve the
+ effective altruism community
+
+
+ )}
+
+
@@ -321,14 +326,15 @@ export function CreateProjectForm(props: { causesList: Cause[] }) {
/>
- Note that the editor offers formatting shortcuts{' '}
-
like Notion
- {' '}
- for hyperlinks, bullet points, headers, and more.
+ {' '}
+ for links, bullet points, headings, images and more.
From 05fce8eaab98044cfa2b1e7892b481c4e1ccdde5 Mon Sep 17 00:00:00 2001
From: Austin Chen
Date: Wed, 15 May 2024 16:36:39 -0700
Subject: [PATCH 10/12] Move eval UI inside app status tab
---
app/projects/[slug]/comments.tsx | 2 --
app/projects/[slug]/project-tabs.tsx | 2 ++
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/projects/[slug]/comments.tsx b/app/projects/[slug]/comments.tsx
index 2edbe1b9..1567a9d9 100644
--- a/app/projects/[slug]/comments.tsx
+++ b/app/projects/[slug]/comments.tsx
@@ -18,7 +18,6 @@ import clsx from 'clsx'
import { clearLocalStorageItem } from '@/hooks/use-local-storage'
import { Comment } from '@/components/comment'
import { Select } from '@/components/select'
-import { JudgeApp } from './approve-app'
export function Comments(props: {
project: Project
@@ -125,7 +124,6 @@ export function Comments(props: {
commenter={userProfile}
specialPrompt={specialPrompt}
/>
-
)}
{commentsDisplay}
diff --git a/app/projects/[slug]/project-tabs.tsx b/app/projects/[slug]/project-tabs.tsx
index 244bdccf..315e2b2f 100644
--- a/app/projects/[slug]/project-tabs.tsx
+++ b/app/projects/[slug]/project-tabs.tsx
@@ -17,6 +17,7 @@ import { formatMoneyPrecise, formatPercent } from '@/utils/formatting'
import { MarketTab } from '../market-tab'
import clsx from 'clsx'
import { Col } from '@/components/layout/col'
+import { JudgeApp } from './approve-app'
export function ProjectTabs(props: {
project: FullProject
@@ -142,6 +143,7 @@ export function ProjectTabs(props: {
}
/>
+
),
From f5b4de62aadd9408b0fdc0955d71cbba93627095 Mon Sep 17 00:00:00 2001
From: Austin Chen
Date: Wed, 15 May 2024 16:46:51 -0700
Subject: [PATCH 11/12] Surface other funders at the top
---
app/causes/page.tsx | 19 +++++++++++++++++--
app/create/create-project-form.tsx | 6 +++---
utils/constants.ts | 2 ++
3 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/app/causes/page.tsx b/app/causes/page.tsx
index 6fb13df6..9e1a02d9 100644
--- a/app/causes/page.tsx
+++ b/app/causes/page.tsx
@@ -2,15 +2,29 @@ import { createServerClient } from '@/db/supabase-server'
import { FullCause, listFullCauses } from '@/db/cause'
import Image from 'next/image'
import Link from 'next/link'
+import { FUNDER_SLUGS } from '@/utils/constants'
export default async function CausesPage() {
const supabase = createServerClient()
const causesList = await listFullCauses(supabase)
+ const funders = causesList.filter((c) => FUNDER_SLUGS.includes(c.slug))
const prizes = causesList.filter((c) => c.prize)
- const regularCauses = causesList.filter((c) => !c.prize)
+ const regularCauses = causesList.filter(
+ (c) => !c.prize && !FUNDER_SLUGS.includes(c.slug)
+ )
return (
-
+ Funders
+
+ Other funders who partner with Manifund's common app
+
+
+ {funders.map((cause) => (
+
+ ))}
+
+
+
Prize rounds
@@ -21,6 +35,7 @@ export default async function CausesPage() {
))}
+
Causes
diff --git a/app/create/create-project-form.tsx b/app/create/create-project-form.tsx
index 316e69f0..6f4b4c83 100644
--- a/app/create/create-project-form.tsx
+++ b/app/create/create-project-form.tsx
@@ -26,6 +26,7 @@ import { ProjectParams } from '@/utils/upsert-project'
import questionBank from '../questions/questionBank.json'
import questionChoicesData from '../questions/questionChoices.json'
import { CheckCircleIcon } from '@heroicons/react/24/solid'
+import { FUNDER_SLUGS } from '@/utils/constants'
interface QuestionsData {
id: string
@@ -50,7 +51,6 @@ var DESCRIPTION_OUTLINE = `
What other funding are you or your project getting?
`
-const FUNDERS = ['ltff', 'eaif']
const addQuestionsToDescription = (
selectedCauses: string[],
@@ -135,10 +135,10 @@ export function CreateProjectForm(props: { causesList: Cause[] }) {
(cause) => cause.open && cause.prize
)
const selectableCauses = causesList.filter(
- (cause) => cause.open && !cause.prize && !FUNDERS.includes(cause.slug)
+ (cause) => cause.open && !cause.prize && !FUNDER_SLUGS.includes(cause.slug)
)
const funderCauses = causesList.filter((cause) =>
- FUNDERS.includes(cause.slug)
+ FUNDER_SLUGS.includes(cause.slug)
)
const minMinFunding = projectParams.selectedPrize?.cert_params
diff --git a/utils/constants.ts b/utils/constants.ts
index 83bf1643..4d90d108 100644
--- a/utils/constants.ts
+++ b/utils/constants.ts
@@ -98,3 +98,5 @@ export function isCharitableDeposit(txnId: string) {
}
export const CURRENT_AGREEMENT_VERSION = 3
+
+export const FUNDER_SLUGS = ['ltff', 'eaif']
From e1c443d4303a1a8390b04af9073ed23f2f3bacfe Mon Sep 17 00:00:00 2001
From: Austin Chen
Date: Wed, 15 May 2024 16:46:59 -0700
Subject: [PATCH 12/12] Remove console logs
---
pages/api/judge-app.ts | 2 --
1 file changed, 2 deletions(-)
diff --git a/pages/api/judge-app.ts b/pages/api/judge-app.ts
index e69f443f..ec17d4cd 100644
--- a/pages/api/judge-app.ts
+++ b/pages/api/judge-app.ts
@@ -23,7 +23,6 @@ type judgeAppProps = {
export default async function handler(req: NextRequest) {
const { projectId, causeSlug, decision, funding } =
(await req.json()) as judgeAppProps
- console.log('judgeAppProps', projectId, causeSlug, decision, funding)
const supabase = createEdgeClient(req)
// Turn off auth checks for hackathon
@@ -40,7 +39,6 @@ export default async function handler(req: NextRequest) {
})
.eq('project_id', projectId)
.eq('cause_slug', causeSlug)
- console.log('done', data, error)
return NextResponse.json('success')
}