Skip to content

Commit db091d8

Browse files
authored
Merge pull request #77 from VoiceDeck/dev
Hotfix 1.0.5.2 - progress bar styling and funding calculations
2 parents 60a4feb + 63f085d commit db091d8

File tree

6 files changed

+32
-42
lines changed

6 files changed

+32
-42
lines changed

components/report-details/funding-data-wrapper.tsx

+3-6
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,14 @@ const FundingDataWrapper: React.FC<FundingDataWrapperProps> = ({
4444
Loading funding data...
4545
</section>
4646
);
47-
// if (error) return <div>Error loading data</div>;
4847

49-
if (!genesisFraction || !hypercertClaim) {
48+
if (!hypercertClaim) {
5049
return <div>Missing data for calculations</div>;
5150
}
5251

5352
const totalUnits = hypercertClaim.totalUnits;
5453
const pricePerUnit = totalAmount / Number(totalUnits);
55-
const unitsRemaining = genesisFraction.units;
56-
const percentProgress =
57-
((totalUnits - genesisFraction.units) / totalUnits) * 100;
54+
const percentProgress = ((fundedAmount || 0) / totalAmount) * 100;
5855
const minUnitAmount = 1 / pricePerUnit;
5956
const dollarAmountNeeded = (totalAmount - (fundedAmount || 0)).toFixed(2);
6057

@@ -66,7 +63,7 @@ const FundingDataWrapper: React.FC<FundingDataWrapperProps> = ({
6663
pricePerUnit,
6764
totalUnits,
6865
totalAmount,
69-
unitsRemaining,
66+
// unitsRemaining,
7067
percentProgress,
7168
minUnitAmount,
7269
dollarAmountNeeded,

components/report-details/funding-progress.tsx

+12-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const FundingProgress: React.FC<FundingProgressProps> = ({
1515
reportInfo,
1616
}) => {
1717
const { percentProgress, dollarAmountNeeded } = useFunding();
18-
const isFullyFunded = percentProgress === 100;
18+
const isFullyFunded = percentProgress >= 100;
1919

2020
return (
2121
<section className="px-3 py-4 flex flex-col space-y-2 md:flex-row md:space-x-4 md:justify-between bg-slate-50/80 backdrop-blur-md rounded-t-xl md:rounded-b-xl shadow-md max-w-3xl">
@@ -39,11 +39,17 @@ const FundingProgress: React.FC<FundingProgressProps> = ({
3939
<Progress value={percentProgress} />
4040
</div>
4141
<div className="p-[2px]" />
42-
<SupportReport
43-
image={reportInfo.image}
44-
title={reportInfo.title}
45-
hypercertId={reportInfo.hypercertId}
46-
/>
42+
{isFullyFunded ? (
43+
<div>
44+
<p className="text-lg font-semibold text-vd-blue-900">Funded!</p>
45+
</div>
46+
) : (
47+
<SupportReport
48+
image={reportInfo.image}
49+
title={reportInfo.title}
50+
hypercertId={reportInfo.hypercertId}
51+
/>
52+
)}
4753
</section>
4854
);
4955
};

components/report-details/support/form.tsx

+5-25
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const transactionStatusContent: Record<
8686
icon: <CheckCircle size={36} />,
8787
title: "Thank you! We got your support.",
8888
content:
89-
"Your transaction was successful. We're grateful for your contribution!",
89+
"Your transaction was successful. We're grateful for your contribution! It might take a few minutes to show up on the report.",
9090
},
9191
};
9292

@@ -252,7 +252,7 @@ const SupportReportForm = ({ hypercertId }: SupportReportFormProps) => {
252252
rows={3}
253253
placeholder="Leave a message with your donation"
254254
{...field}
255-
className="w-full px-4 py-2 border rounded-lg resize-none"
255+
className="w-full px-4 py-2 border rounded-lg resize-none bg-stone-100"
256256
/>
257257
</FormControl>
258258
<FormMessage />
@@ -298,18 +298,17 @@ const SupportReportForm = ({ hypercertId }: SupportReportFormProps) => {
298298
<Alert className="bg-stone-50">
299299
{/* <AlertTitle className="font-semibold">Please note</AlertTitle> */}
300300
<AlertDescription>
301-
You will need WETH on the Sepolia testnet. Get some ETH from the
302-
faucet then wrap it to WETH.
301+
You will need ETH on the Sepolia testnet. You can get some from
302+
the link below.
303303
</AlertDescription>
304304
<AlertDescription className="flex gap-2 items-center py-1">
305-
<p className="hidden md:block font-semibold">Links:</p>
306305
<a
307306
href="https://www.alchemy.com/faucets/ethereum-sepolia"
308307
target="_blank"
309308
rel="noopener noreferrer"
310309
className={cn(
311310
buttonVariants({ variant: "link" }),
312-
"text-sm flex justify-between items-center group",
311+
"flex justify-between items-center group p-0",
313312
)}
314313
aria-label="Open Sepolia Faucet in a new tab"
315314
>
@@ -321,25 +320,6 @@ const SupportReportForm = ({ hypercertId }: SupportReportFormProps) => {
321320
aria-hidden="true"
322321
/>
323322
</a>
324-
<p className="text-stone-400">|</p>
325-
<a
326-
href="https://weth.altlayer.io/transfer"
327-
target="_blank"
328-
rel="noopener noreferrer"
329-
className={cn(
330-
buttonVariants({ variant: "link" }),
331-
"text-sm flex justify-between items-center group",
332-
)}
333-
aria-label="Open AltLayer's ETH Wrapper in a new tab"
334-
>
335-
ETH Wrapper
336-
<span className="sr-only">(opens in a new tab)</span>
337-
<ArrowUpRight
338-
size={16}
339-
className="ml-1 opacity-70 group-hover:translate-x-0.5 group-hover:opacity-100 group-hover:-translate-y-0.5 transition-transform duration-300 ease-in-out"
340-
aria-hidden="true"
341-
/>
342-
</a>
343323
</AlertDescription>
344324
<div className="p-2" />
345325
<Button

components/reports/report-card.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ const ReportCard: React.FC<ReportCardProps> = ({
8181
className="w-full"
8282
value={(fundedSoFar / totalCost) * 100}
8383
/>
84-
<p className="text-xs">${totalCost - fundedSoFar} needed</p>
84+
<p className="text-xs">
85+
{fundedSoFar === totalCost
86+
? "Funded!"
87+
: `${totalCost - fundedSoFar} needed`}
88+
</p>
8589
</CardFooter>
8690
</Card>
8791
</Link>

components/ui/progress.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"use client"
1+
"use client";
22
import * as ProgressPrimitive from "@radix-ui/react-progress";
33
import * as React from "react";
44

@@ -17,7 +17,10 @@ const Progress = React.forwardRef<
1717
{...props}
1818
>
1919
<ProgressPrimitive.Indicator
20-
className="h-full w-full flex-1 bg-vd-blue-900 transition-all dark:bg-vd-blue-200"
20+
className={cn(
21+
"h-full w-full flex-1 bg-vd-blue-900 transition-all dark:bg-vd-blue-200",
22+
value === 100 && "bg-green-500",
23+
)}
2124
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
2225
/>
2326
</ProgressPrimitive.Root>

contexts/funding-context.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import { type ReactNode, createContext, useContext } from "react";
55

66
// Define the shape of the context
77
interface FundingContextType {
8-
genesisFraction: ClaimToken;
8+
genesisFraction?: ClaimToken;
99
hypercertClaim: Claim;
1010
pricePerUnit: number;
1111
totalUnits: number;
1212
totalAmount: number;
13-
unitsRemaining: number;
13+
// unitsRemaining: number;
1414
percentProgress: number;
1515
minUnitAmount: number;
1616
dollarAmountNeeded: string;

0 commit comments

Comments
 (0)