Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove impact metrics #215

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/02_adding_projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
- **contributionDescription** - describe your contribution
- **impactDescription** - describe your impact
- **contributionLinks** - links to contributions
- **impactMetrics** - links to your impact
- **fundingSources** - list your funding sources

This will create an Attestation with the Metadata schema and populate the fields:
Expand Down
6 changes: 1 addition & 5 deletions src/components/ui/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,7 @@ export const FieldArray = <S extends z.Schema>({

return (
<div className="mb-8">
<p className="dark:text-white">
{title}

<span className="text-blue-400">*</span>
</p>
<p className="dark:text-white">{title}</p>

<p className="mb-2 text-gray-300">{description}</p>

Expand Down
7 changes: 4 additions & 3 deletions src/features/applications/components/ApplicationButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ export const ApplicationButtons = ({

const application = useMemo(() => form.getValues(), [form]);

const checkLinks = (links: Pick<ContributionLink | ImpactMetrix | FundingSource, "description">[]): boolean =>
const checkLinks = (
links: Pick<ContributionLink | ImpactMetrix | FundingSource, "description">[] | undefined,
): boolean =>
links === undefined ||
links.reduce((prev, link) => prev && link.description !== undefined && link.description.length > 0, true);

const stepComplete = useMemo((): boolean => {
Expand All @@ -56,7 +59,6 @@ export const ApplicationButtons = ({
impactDescription,
impactCategory,
contributionLinks,
impactMetrics,
fundingSources,
} = application;

Expand All @@ -77,7 +79,6 @@ export const ApplicationButtons = ({
contributionDescription.length > 0 &&
impactDescription.length > 0 &&
checkLinks(contributionLinks) &&
checkLinks(impactMetrics) &&
checkLinks(fundingSources)
);
}
Expand Down
24 changes: 0 additions & 24 deletions src/features/applications/components/ApplicationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ export const ApplicationForm = (): JSX.Element => {
<Form
defaultValues={{
payoutAddress: address,
contributionLinks: [{}],
impactMetrics: [{}],
fundingSources: [{}],
}}
schema={ApplicationSchema}
onSubmit={(application) => {
Expand Down Expand Up @@ -166,27 +163,6 @@ export const ApplicationForm = (): JSX.Element => {
title="Contribution links"
/>

<FieldArray
description="What kind of impact have your project made?"
name="impactMetrics"
renderField={(field, i) => (
<div className="mb-4 flex flex-wrap gap-2">
<FormControl required className="min-w-96" name={`impactMetrics.${i}.description`}>
<Input placeholder="Type the name of your impact metric" />
</FormControl>

<FormControl required className="min-w-72" name={`impactMetrics.${i}.url`}>
<Input placeholder="https://" />
</FormControl>

<FormControl required valueAsNumber name={`impactMetrics.${i}.number`}>
<Input placeholder="Type a metric number" type="number" />
</FormControl>
</div>
)}
title="Impact metrics"
/>

<FieldArray
description="From what sources have you received funding?"
name="fundingSources"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const ApplicationItem = ({

const form = useFormContext();

const { fundingSources = [], impactMetrics = [], profileImageUrl } = metadata.data ?? {};
const { fundingSources = [], profileImageUrl } = metadata.data ?? {};

return (
<Link href={`/projects/${id}`} target="_blank">
Expand All @@ -117,8 +117,6 @@ export const ApplicationItem = ({

<div className="text-sm text-gray-400">
<div>{fundingSources.length} funding sources</div>

<div>{impactMetrics.length} impact metrics</div>
</div>
</div>
</div>
Expand Down
18 changes: 4 additions & 14 deletions src/features/applications/components/ReviewApplicationDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const ValueField = ({ title, body = undefined, required = false }: IValueFieldPr
<div className="text-light flex flex-wrap gap-2 text-gray-400">
{body === undefined && emptyPlaceholder}

{Array.isArray(body) && body.length === 0 && emptyPlaceholder}

{typeof body === "string" && body.length === 0 && emptyPlaceholder}

{((typeof body === "string" && body.length > 0) || typeof body !== "string") && body}
Expand Down Expand Up @@ -105,26 +107,14 @@ export const ReviewApplicationDetails = (): JSX.Element => {
/>

<ValueField
required
body={application.contributionLinks.map((link) => (
body={application.contributionLinks?.map((link) => (
<LinkField key={link.description} contributionLink={link} />
))}
title="Contribution links"
/>

<ValueField
required
body={application.impactMetrics.map((link) => (
<LinkField key={link.description} impactMetrix={link} />
))}
title="Impact metrics"
/>

<ValueField
required
body={application.fundingSources.map((link) => (
<LinkField key={link.description} fundingSource={link} />
))}
body={application.fundingSources?.map((link) => <LinkField key={link.description} fundingSource={link} />)}
title="Funding sources"
/>
</div>
Expand Down
21 changes: 4 additions & 17 deletions src/features/applications/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,8 @@ export const ApplicationSchema = z.object({
),
}),
)
.min(1),
impactMetrics: z
.array(
z.object({
description: z.string().min(3),
url: z
.string()
.min(1)
.transform((url) =>
// Automatically prepend "https://" if it's missing
/^(http:\/\/|https:\/\/)/i.test(url) ? url : `https://${url}`,
),
number: z.number(),
}),
)
.min(1),
.default([])
.optional(),
fundingSources: z
.array(
z.object({
Expand All @@ -79,7 +65,8 @@ export const ApplicationSchema = z.object({
type: z.nativeEnum(reverseKeys(fundingSourceTypes)),
}),
)
.default([]),
.default([])
.optional(),
});

export type Application = z.infer<typeof ApplicationSchema>;
6 changes: 0 additions & 6 deletions src/features/projects/components/ProjectDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ const ProjectDetails = ({
title="contributions"
/>

<ProjectDescriptionSection
description={metadata.data?.impactDescription}
impacts={metadata.data?.impactMetrics}
title="impact"
/>

<ProjectDescriptionSection
description={metadata.data?.impactDescription}
fundings={fundingSources}
Expand Down
43 changes: 0 additions & 43 deletions src/features/projects/components/ProjectImpact.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
}
}

@media (prefers-color-scheme: dark) {
@media (prefers-color-scheme: "dark") {
h3 {
color: white;
}
Expand Down
Loading