Skip to content

Commit 2bb443f

Browse files
authored
Small fixes (#35)
do some small fixes
2 parents 6bde592 + a52eba0 commit 2bb443f

File tree

11 files changed

+73
-45
lines changed

11 files changed

+73
-45
lines changed

src/components/SCLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function SCLink({
1212
<Link
1313
href={href}
1414
target={target}
15-
className={`underline text-alternateMedium hover:text-alternateLight ${className}`}
15+
className={`underline text-stellarYellow hover:text-alternateLight ${className}`}
1616
>
1717
{children}
1818
</Link>

src/components/dashboard/overview/OverviewContactInfo.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ export default function OverviewContactInfo() {
4343
}, [setShowForm]);
4444

4545
const onClickConfirmRegistration = useCallback(() => {
46-
updateAccount(
47-
walletConnection!.recipient!.email,
48-
walletConnection?.recipient?.name ?? undefined
49-
);
46+
if (jwt) {
47+
updateAccount(
48+
walletConnection!.recipient!.email,
49+
walletConnection?.recipient?.name ?? undefined
50+
);
51+
} else {
52+
router.push("/sep10");
53+
}
5054
}, [walletConnection, updateAccount]);
5155

5256
const handleDelete = useCallback(() => {

src/components/icons/SignIcon.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ interface SignIconProps {
55
export default function SignIcon({ large }: SignIconProps) {
66
return (
77
<svg
8-
width={"64px"}
9-
height={"64px"}
8+
width={"92px"}
9+
height={"92px"}
1010
viewBox="0 0 24 24"
1111
fill="none"
1212
xmlns="http://www.w3.org/2000/svg"

src/containers/connect_wallet/AcceptTnC.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,24 @@ export default function AcceptTnC() {
1010
<div className="flex flex-col gap-4">
1111
<div className="flex flex-col">
1212
<DashboardHeader>Fine print</DashboardHeader>
13-
<span>
14-
Read our <Link href="/terms-of-use" target="_blank" className="underline">
13+
<span className="mt-2">
14+
Read our{" "}
15+
<Link href="/terms-of-use" target="_blank" className="underline">
1516
Terms of Use
16-
</Link> and <Link href="/privacy-policy" target="_blank" className="underline">
17+
</Link>{" "}
18+
and{" "}
19+
<Link href="/privacy-policy" target="_blank" className="underline">
1720
Privacy Policy
18-
</Link> before you continue.
21+
</Link>{" "}
22+
before you continue.
1923
</span>
2024
</div>
2125

2226
{tncError && (
2327
<ConnectWalletFormError
24-
message={"You have to accept the terms, as they are part of your contract with Stellarcarbon."}
28+
message={
29+
"You have to accept the terms, as they are part of your contract with Stellarcarbon."
30+
}
2531
/>
2632
)}
2733

@@ -45,8 +51,7 @@ export default function AcceptTnC() {
4551
className="p-2 cursor-pointer text-sm "
4652
htmlFor="checkbox_policy"
4753
>
48-
I have read and agree with the Terms of Use and the Privacy
49-
Policy.
54+
I have read and agree with the Terms of Use and the Privacy Policy.
5055
</label>
5156
</div>
5257
</div>

src/containers/connect_wallet/SelectWallet.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default function SelectWallet() {
2828
<div ref={containerRef} className="flex flex-col gap-4">
2929
<div className="flex flex-col w-full">
3030
<DashboardHeader>Wallet selection</DashboardHeader>
31-
<span className="hidden md:block">
31+
<span className="hidden md:block mt-2">
3232
Select your wallet. You’ll connect it when you submit the form.
3333
</span>
3434

src/containers/sink/steps/Await.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ export default function AwaitSinking({ message }: { message: string }) {
55
return (
66
<ModalStep title="Waiting for API">
77
<span className="text-center">{message}</span>
8-
<div className="flex-1 flex items-center justify-center my-4">
8+
<div className="flex-1 flex items-center justify-center my-12">
99
<Hourglass
1010
visible={true}
11-
height="80"
12-
width="80"
11+
height="92"
12+
width="92"
1313
ariaLabel="hourglass-loading"
1414
wrapperStyle={{}}
1515
wrapperClass=""

src/containers/sink/steps/Sign.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default function SignSinking() {
77
<span className="text-center">
88
{"Sign the transaction using your wallet in the pop-up."}
99
</span>
10-
<div className="flex-1 flex items-center justify-center my-4">
10+
<div className="flex-1 flex items-center justify-center my-12">
1111
<SignIcon />
1212
</div>
1313
</ModalStep>

src/context/SinkingContext.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ export const SinkingContextProvider = ({ children }: PropsWithChildren) => {
117117
const result = await server.submitTransaction(
118118
TransactionBuilder.fromXDR(signedTxXdr, appConfig.network)
119119
);
120-
setStep(CheckoutSteps.COMPLETED);
120+
setTimeout(() => {
121+
// Let the user wait a bit so their dashboard can be updated
122+
setStep(CheckoutSteps.COMPLETED);
123+
}, 1000);
121124
} catch (error) {
122125
displayHorizonError(error);
123126
}

src/hooks/useSCAccount.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export function useSCAccount() {
7676

7777
if (res.response.status === 200 && res.data) {
7878
updateWalletConnection(res.data);
79+
setIsStale(false);
7980
}
8081
},
8182
[jwt, walletConnection, updateWalletConnection]

src/hooks/useTransactionHistory.tsx

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ const defaultData: TransactionHistoryData = {
3737
export function useTransactionHistory(
3838
account?: string
3939
): UseMyTransactionsResult {
40-
const [data, setData] = useState<TransactionHistoryData>(defaultData);
40+
const [txData, setTxData] = useState<TransactionHistoryData>(defaultData);
4141
const [loading, setLoading] = useState<boolean>(false);
4242

43-
const fetchData = useCallback(async () => {
44-
if (!account) return;
43+
const fetchTxData = useCallback(async (): Promise<TransactionHistoryData> => {
44+
if (!account) return defaultData;
4545
setLoading(true);
4646

4747
const response = await getSinkTxsForRecipient({
@@ -50,39 +50,50 @@ export function useTransactionHistory(
5050

5151
if (response.data === undefined) {
5252
setLoading(false);
53-
return;
53+
return defaultData;
5454
}
5555

5656
const serializedTransactions =
5757
TransactionHistoryService.serializeTxsResponse(response.data);
5858

59-
setData({
59+
setLoading(false);
60+
61+
return {
6062
myTransactions: serializedTransactions,
6163
totalSunk: Number(response.data.total_carbon_sunk),
6264
totalPending: Number(response.data.total_carbon_pending),
6365
retirementGraceDays: response.data.retirement_grace_days,
64-
});
66+
};
6567

66-
setLoading(false);
68+
// setTxData({
69+
// myTransactions: serializedTransactions,
70+
// totalSunk: Number(response.data.total_carbon_sunk),
71+
// totalPending: Number(response.data.total_carbon_pending),
72+
// retirementGraceDays: response.data.retirement_grace_days,
73+
// });
74+
75+
// setLoading(false);
6776
}, [account]);
6877

6978
async function pollForNewTransaction(
7079
maxRetries: number = 5,
71-
delay: number = 3000 // delay in milliseconds
80+
delay: number = 800 // delay in milliseconds
7281
): Promise<void> {
7382
if (!account) throw new Error("No account for polling");
7483

7584
let retries = 0;
76-
const oldTransactions = data.myTransactions;
85+
const oldTransactions = txData.myTransactions;
7786

7887
while (retries < maxRetries) {
79-
const transactionRecords =
80-
await TransactionHistoryService.fetchAccountHistory(account);
81-
82-
if (hasNewItem(transactionRecords)) {
83-
setData((prev) => {
84-
return { ...prev, myTransactions: transactionRecords };
85-
});
88+
console.log("polling", retries);
89+
const transactionRecords = await fetchTxData();
90+
91+
if (hasNewItem(transactionRecords.myTransactions)) {
92+
console.log(
93+
transactionRecords.totalPending,
94+
transactionRecords.totalSunk
95+
);
96+
setTxData(transactionRecords);
8697
return;
8798
}
8899

@@ -107,21 +118,23 @@ export function useTransactionHistory(
107118

108119
useEffect(() => {
109120
if (!account) {
110-
setData(defaultData);
121+
setTxData(defaultData);
111122
} else {
112-
fetchData();
123+
fetchTxData().then((txData) => {
124+
setTxData(txData);
125+
});
113126
}
114-
}, [fetchData, account]);
127+
}, [fetchTxData, account]);
115128

116129
const refetch = useCallback(() => {
117-
if (account) fetchData();
118-
}, [account, fetchData]);
130+
if (account) fetchTxData();
131+
}, [account, fetchTxData]);
119132

120133
return {
121-
myTransactions: data.myTransactions,
122-
totalSunk: data.totalSunk,
123-
totalPending: data.totalPending,
124-
retirementGraceDays: data.retirementGraceDays,
134+
myTransactions: txData.myTransactions,
135+
totalSunk: txData.totalSunk,
136+
totalPending: txData.totalPending,
137+
retirementGraceDays: txData.retirementGraceDays,
125138
loading,
126139
refetch,
127140
pollForNewTransaction,

0 commit comments

Comments
 (0)