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

chore: wallet-ui send workflow allow return back #468

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

khanti42
Copy link
Collaborator

Based on QA review, this PR introduces functionality that allows users to navigate back from the “Send Summary Modal View” to the “Send View” while retaining the address and value of the transaction. This ensures users can easily update the transaction parameters if needed without starting over.

@khanti42 khanti42 requested a review from a team as a code owner December 18, 2024 14:02
@khanti42 khanti42 requested review from Julink-eth and wantedsystem and removed request for a team December 18, 2024 14:02
Copy link

Quality Gate Passed Quality Gate passed for 'consensys_starknet-snap-starknet-snap'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

Copy link

Quality Gate Passed Quality Gate passed for 'consensys_starknet-snap-wallet-ui'

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@@ -47,6 +47,18 @@ export const SendModalView = ({ closeModal }: Props) => {
const debounceRef = useRef<NodeJS.Timeout | null>(null);
const [loading, setLoading] = useState(false);

useEffect(() => {}, [fields]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the purpose to have the useEffect?

@@ -110,29 +103,29 @@ export const AmountInputView = ({
};

const handleMaxClick = () => {
if (inputRef.current && asset.usdPrice) {
if (value && asset.usdPrice) {
Copy link
Collaborator

@stanleyyconsensys stanleyyconsensys Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to check the value here, as either the value is empty or not, the Max button should behave the same

<ButtonStyled onClick={closeModal} backgroundTransparent borderVisible>
REJECT
<ButtonStyled
onClick={() => handleBack(amount, address)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
onClick={() => handleBack(amount, address)}
onClick={() => handleBack()}

Comment on lines +52 to +60
const handleBack = (amount: string, address: string) => {
setSummaryModalOpen(false);

setFields((prevFields) => ({
...prevFields,
amount: amount,
address: address,
}));
};
Copy link
Collaborator

@stanleyyconsensys stanleyyconsensys Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const handleBack = (amount: string, address: string) => {
setSummaryModalOpen(false);
setFields((prevFields) => ({
...prevFields,
amount: amount,
address: address,
}));
};
const handleBack = () => {
setSummaryModalOpen(false);
};

setFields is not necessary, as the user still in the send model after the confirmation model render, the state will be remained

@@ -39,6 +39,7 @@ interface Props {
amount: string;
chainId: string;
closeModal?: () => void;
handleBack: (amount: string, address: string) => void;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
handleBack: (amount: string, address: string) => void;
handleBack: () => void;

? getAmountPrice(asset, amountFloat, false)
: amountStr;
fetchTotalPrice();
resizeInput();
triggerOnChange();
triggerOnChange(value);
}
};

useEffect(() => {
Copy link
Collaborator

@stanleyyconsensys stanleyyconsensys Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this useEffect block is no need, as setInputValue has fired in triggerOnChange


useEffect(() => {
fetchTotalPrice();
}, [fetchTotalPrice]);
Copy link
Collaborator

@stanleyyconsensys stanleyyconsensys Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}, [fetchTotalPrice]);
}, [asset, inputValue, usdMode]);

remove the useCallback , but move it to useEffect for easier understand

inputRef.current && fetchTotalPrice();
};

}, [resizeInput]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}, [resizeInput]);
}, [inputValue]);

same comment as below, remove the useCallback

Comment on lines 114 to 115
fetchTotalPrice();
resizeInput();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fetchTotalPrice();
resizeInput();

this 2 can be removed, as they will triggered at onEffect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants