-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: integrate application page styling
- Loading branch information
Showing
34 changed files
with
1,078 additions
and
391 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { ReactNode } from "react"; | ||
import { tv } from "tailwind-variants"; | ||
|
||
import { createComponent } from "~/components/ui"; | ||
|
||
const StatusBarContainer = createComponent( | ||
"div", | ||
tv({ | ||
base: "flex rounded-md border p-4 justify-center mb-4", | ||
variants: { | ||
status: { | ||
default: "text-blue-600 border-blue-600 bg-blue-400", | ||
pending: "text-[#4E1D0D] border-[#4E1D0D] bg-[#FFEDD5]", | ||
approved: "text-[#14532D] border-[#14532D] bg-[#BBF7D0]", | ||
declined: "text-[#F87171] border-[#F87171] bg-[#FEE2E2]", | ||
}, | ||
}, | ||
defaultVariants: { | ||
status: "default", | ||
}, | ||
}), | ||
); | ||
|
||
interface IStatusBarProps { | ||
status: string; | ||
content: ReactNode; | ||
} | ||
|
||
export const StatusBar = ({ status, content }: IStatusBarProps): JSX.Element => ( | ||
<StatusBarContainer status={status}>{content}</StatusBarContainer> | ||
); |
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
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,36 @@ | ||
import { useCallback } from "react"; | ||
|
||
import { Button } from "~/components/ui/Button"; | ||
import { useIsAdmin } from "~/hooks/useIsAdmin"; | ||
import { useIsCorrectNetwork } from "~/hooks/useIsCorrectNetwork"; | ||
|
||
import { useApproveApplication } from "../hooks/useApproveApplication"; | ||
|
||
interface IAdminButtonsBarProps { | ||
projectId: string; | ||
} | ||
|
||
export const AdminButtonsBar = ({ projectId }: IAdminButtonsBarProps): JSX.Element => { | ||
const isAdmin = useIsAdmin(); | ||
const { isCorrectNetwork, correctNetwork } = useIsCorrectNetwork(); | ||
|
||
const approve = useApproveApplication({}); | ||
|
||
const onClick = useCallback(() => { | ||
approve.mutate([projectId]); | ||
}, [approve, projectId]); | ||
|
||
return ( | ||
<div className="my-3 flex justify-end gap-2"> | ||
<Button | ||
suppressHydrationWarning | ||
disabled={!isAdmin || !isCorrectNetwork} | ||
size="auto" | ||
variant="primary" | ||
onClick={onClick} | ||
> | ||
{!isCorrectNetwork ? `Connect to ${correctNetwork.name}` : "Approve application"} | ||
</Button> | ||
</div> | ||
); | ||
}; |
136 changes: 136 additions & 0 deletions
136
src/features/applications/components/ApplicationButtons.tsx
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,136 @@ | ||
import { useMemo, useCallback, useState } from "react"; | ||
import { useFormContext } from "react-hook-form"; | ||
import { useAccount } from "wagmi"; | ||
|
||
import { Button, IconButton } from "~/components/ui/Button"; | ||
import { Dialog } from "~/components/ui/Dialog"; | ||
import { Spinner } from "~/components/ui/Spinner"; | ||
import { useIsCorrectNetwork } from "~/hooks/useIsCorrectNetwork"; | ||
|
||
import type { Application } from "../types"; | ||
import type { ImpactMetrix, ContributionLink, FundingSource } from "~/features/projects/types"; | ||
|
||
export enum EApplicationStep { | ||
PROFILE, | ||
ADVANCED, | ||
REVIEW, | ||
} | ||
|
||
interface IApplicationButtonsProps { | ||
step: EApplicationStep; | ||
isUploading: boolean; | ||
isPending: boolean; | ||
onNextStep: () => void; | ||
onBackStep: () => void; | ||
} | ||
|
||
export const ApplicationButtons = ({ | ||
step, | ||
isUploading, | ||
isPending, | ||
onNextStep, | ||
onBackStep, | ||
}: IApplicationButtonsProps): JSX.Element => { | ||
const { isCorrectNetwork } = useIsCorrectNetwork(); | ||
|
||
const { address } = useAccount(); | ||
|
||
const [showDialog, setShowDialog] = useState<boolean>(false); | ||
|
||
const form = useFormContext<Application>(); | ||
|
||
const application = useMemo(() => form.getValues(), [form]); | ||
|
||
const checkLinks = (links: Pick<ContributionLink | ImpactMetrix | FundingSource, "description">[]): boolean => | ||
links.reduce((prev, link) => prev && link.description.length > 0, true); | ||
|
||
const stepComplete = useMemo((): boolean => { | ||
const { | ||
name, | ||
bio, | ||
payoutAddress, | ||
websiteUrl, | ||
profileImageUrl, | ||
bannerImageUrl, | ||
contributionDescription, | ||
impactDescription, | ||
impactCategory, | ||
contributionLinks, | ||
impactMetrics, | ||
fundingSources, | ||
} = application; | ||
|
||
if (step === EApplicationStep.PROFILE) { | ||
return ( | ||
bannerImageUrl !== undefined && | ||
profileImageUrl !== undefined && | ||
bio.length > 0 && | ||
name.length > 0 && | ||
payoutAddress.length > 0 && | ||
websiteUrl.length > 0 | ||
); | ||
} | ||
|
||
if (step === EApplicationStep.ADVANCED) { | ||
return ( | ||
impactCategory !== undefined && | ||
contributionDescription.length > 0 && | ||
impactDescription.length > 0 && | ||
checkLinks(contributionLinks) && | ||
checkLinks(impactMetrics) && | ||
checkLinks(fundingSources) | ||
); | ||
} | ||
|
||
return true; | ||
}, [step, application]); | ||
|
||
const handleOnClickNextStep = useCallback(() => { | ||
if (stepComplete) { | ||
onNextStep(); | ||
} else { | ||
setShowDialog(true); | ||
} | ||
}, [onNextStep, setShowDialog, stepComplete]); | ||
|
||
const handleOnOpenChange = useCallback(() => { | ||
setShowDialog(false); | ||
}, [setShowDialog]); | ||
|
||
return ( | ||
<div className="flex justify-end gap-2"> | ||
<Dialog | ||
description="There are still some inputs not fulfilled, please complete all the required information." | ||
isOpen={showDialog} | ||
size="sm" | ||
title="Please complete all the required information" | ||
onOpenChange={handleOnOpenChange} | ||
/> | ||
|
||
{step !== EApplicationStep.PROFILE && ( | ||
<Button className="text-gray-300 underline" size="auto" variant="ghost" onClick={onBackStep}> | ||
Back | ||
</Button> | ||
)} | ||
|
||
{step !== EApplicationStep.REVIEW && ( | ||
<Button size="auto" variant="primary" onClick={handleOnClickNextStep}> | ||
Next | ||
</Button> | ||
)} | ||
|
||
{step === EApplicationStep.REVIEW && ( | ||
<IconButton | ||
disabled={isPending || !address || !isCorrectNetwork} | ||
icon={isPending ? Spinner : null} | ||
isLoading={isPending} | ||
size="auto" | ||
type="submit" | ||
variant="primary" | ||
> | ||
{isUploading ? "Uploading metadata" : "Submit"} | ||
</IconButton> | ||
)} | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.