-
Notifications
You must be signed in to change notification settings - Fork 115
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(spaceward): Further intents enhancements #168
Conversation
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
WalkthroughWalkthroughThe updates encompass a range of enhancements across various components in a project related to address validation, user interaction, and UI changes. Key modifications include the addition of validation logic for address inputs, new functionalities for selecting and managing addresses, and aesthetic adjustments to the user interface. Additionally, there's a significant refactor in the transaction monitoring hook to improve code clarity and maintainability. Changes
Recent Review DetailsConfiguration used: .coderabbit.yaml Files selected for processing (8)
Additional comments not posted (19)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
const CreateIntent = ({ | ||
intent, | ||
onIntentRemove, | ||
handleChangeIntent, | ||
handleRemoveCondition, | ||
}: { | ||
intent: Intent; | ||
onIntentRemove: (id: number) => void; | ||
handleChangeIntent?: (id: number, newCondition: Condition) => void; | ||
handleRemoveCondition: (id: number, conditionToRemove: Condition) => void; | ||
}) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider destructuring intent
and conditionToRemove
directly in the function parameters for cleaner code.
- const CreateIntent = ({
- intent,
- onIntentRemove,
- handleChangeIntent,
- handleRemoveCondition,
- }: {
- intent: Intent;
- onIntentRemove: (id: number) => void;
- handleChangeIntent?: (id: number, newCondition: Condition) => void;
- handleRemoveCondition: (id: number, conditionToRemove: Condition) => void;
- }) => {
+ const CreateIntent = ({
+ intent: { id, conditions },
+ onIntentRemove,
+ handleChangeIntent,
+ handleRemoveCondition,
+ }: {
+ intent: Intent;
+ onIntentRemove: (id: number) => void;
+ handleChangeIntent?: (id: number, newCondition: Condition) => void;
+ handleRemoveCondition: (id: number, conditionToRemove: Condition) => void;
+ }) => {
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
const CreateIntent = ({ | |
intent, | |
onIntentRemove, | |
handleChangeIntent, | |
handleRemoveCondition, | |
}: { | |
intent: Intent; | |
onIntentRemove: (id: number) => void; | |
handleChangeIntent?: (id: number, newCondition: Condition) => void; | |
handleRemoveCondition: (id: number, conditionToRemove: Condition) => void; | |
}) => { | |
const CreateIntent = ({ | |
intent: { id, conditions }, | |
onIntentRemove, | |
handleChangeIntent, | |
handleRemoveCondition, | |
}: { | |
intent: Intent; | |
onIntentRemove: (id: number) => void; | |
handleChangeIntent?: (id: number, newCondition: Condition) => void; | |
handleRemoveCondition: (id: number, conditionToRemove: Condition) => void; | |
}) => { |
|
||
<div className="mt-4 mb-4"> | ||
<div className="text-xl bg-transparent flex justify-between items-center font-bold"> | ||
Approval by certain amount | ||
<div className="flex items-center gap-2"> | ||
{warning && ( | ||
<img | ||
src="/images/alert-triangle.svg" | ||
alt="" | ||
/> | ||
)} | ||
<div | ||
onClick={() => | ||
handleRemoveCondition( | ||
intent.id, | ||
"group", | ||
) | ||
} | ||
className="group relative cursor-pointer" | ||
> | ||
<img src="/images/x.svg" alt="" /> | ||
<div className="opacity-0 w-fit bg-[rgba(229,238,255,0.15)] text-white text-center text-xs rounded py-2 px-3 absolute z-10 group-hover:opacity-100 top-[-18px] left-1/2 pointer-events-none whitespace-nowrap backdrop-blur-[20px] translate-x-[-50%] translate-y-[-100%] before:content-[''] before:absolute before:left-[50%] before:bottom-0 before:border-[rgba(229,238,255,0.15)] before:border-b-[8px] before:border-l-[8px] before:border-t-[transparent] before:border-r-[transparent] before:border-t-[8px] before:border-r-[8px] before:w-0 before:h-0 before:rotate-[-45deg] before:translate-y-[50%] before:translate-x-[-50%]"> | ||
Remove Condition | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="text-[rgba(229,238,255,0.60)] mt-1"> | ||
Any{" "} | ||
<span | ||
onClick={() => { | ||
setIsCountChange(!isCountChange); | ||
}} | ||
className="min-w-[17px] text-center inline-block bg-[rgba(229,238,255,0.15)] border-[1px] border-[rgba(229,238,255,0.30)] px-[2px] text-white rounded-sm cursor-pointer relative" | ||
> | ||
{approvalAmount} | ||
{isCountChange && ( | ||
<div className="w-[56px] bg-[rgba(229,238,255,0.15)] absolute z-10 top-1/2 right-[calc(-100%_-_12px)] translate-x-[100%] backdrop-blur-[20px] translate-y-[-50%] before:content-[''] before:absolute before:left-[0] before:top-1/2 before:border-[rgba(229,238,255,0.3)] before:border-b-[8px] before:border-l-[8px] before:border-t-[transparent] before:border-r-[transparent] before:border-t-[8px] before:border-r-[8px] before:w-0 before:h-0 before:rotate-[45deg] before:translate-y-[-50%] before:translate-x-[-50%]"> | ||
<div className="flex flex-col gap-[2px] text-white text-center text-sm py-1 px-1 max-h-[120px] overflow-scroll no-scrollbar"> | ||
{[2, 3, 4, 5, 6, 7, 8, 9].map( | ||
(item, key) => { | ||
return ( | ||
<div | ||
className={clsx( | ||
`min-h-[24px] flex justify-center items-center text-[rgba(229,238,255,0.60)]`, | ||
item == | ||
approvalAmount && | ||
`text-white bg-[rgba(229,238,255,0.15)]`, | ||
)} | ||
key={key} | ||
onClick={() => { | ||
setApprovalAmount( | ||
item, | ||
); | ||
}} | ||
> | ||
{item} | ||
</div> | ||
); | ||
}, | ||
)} | ||
</div> | ||
</div> | ||
)} | ||
</span>{" "} | ||
persons should approve the transaction | ||
</div> | ||
<div className="mt-8 flex items-center gap-[8px] flex-wrap"> | ||
{INTENTS.map((intent, key) => { | ||
return ( | ||
<AddressUnit intent={intent} key={key} /> | ||
); | ||
})} | ||
<button | ||
onClick={() => { | ||
setIsPersonsModal(true); | ||
}} | ||
className={clsx( | ||
`text-sm flex w-fit items-center gap-[10px] h-12`, | ||
warning | ||
? `text-[#E54545]` | ||
: `text-[#FFAEEE]`, | ||
)} | ||
> | ||
{warning ? ( | ||
<img | ||
src="/images/alert-triangle.svg" | ||
alt="" | ||
/> | ||
) : ( | ||
<img src="/images/plus.svg" alt="" /> | ||
)} | ||
Add Persons | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
) : ( | ||
<div></div> | ||
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conditional rendering for "group" and "anyone" conditions seems repetitive and could be refactored for better maintainability.
- {intent.conditions.includes("group") ? (
- <div>
- {/* group condition rendering */}
- </div>
- ) : (
- <div></div>
- )}
- {intent.conditions.indexOf("anyone") !== -1 ? (
- <div>
- {/* anyone condition rendering */}
- </div>
- ) : (
- <div></div>
- )}
+ {['group', 'anyone'].map(condition => (
+ intent.conditions.includes(condition) && (
+ <div>
+ {/* condition rendering */}
+ </div>
+ )
+ ))}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
{intent.conditions.includes("group") ? ( | |
<div | |
className={clsx( | |
intent.conditions.includes("joint") && | |
`mt-8 pt-4 mb-4 relative`, | |
)} | |
> | |
{intent.conditions.includes("joint") && ( | |
<div | |
className="absolute text-[rgba(229,238,255,0.30)] text-xs left-1/2 top-0 translate-x-[-50%] translate-y-[-50%] w-full text-center | |
before:content-[''] before:w-[calc(50%_-_16px)] before:h-[1px] before:bg-[rgba(229,238,255,0.30)] before:block before:top-1/2 before:left-0 before:absolute | |
after:content-[''] after:w-[calc(50%_-_16px)] after:h-[1px] after:bg-[rgba(229,238,255,0.30)] after:block after:top-1/2 after:right-0 after:absolute" | |
> | |
OR | |
</div> | |
)} | |
<div className="mt-4 mb-4"> | |
<div className="text-xl bg-transparent flex justify-between items-center font-bold"> | |
Approval by certain amount | |
<div className="flex items-center gap-2"> | |
{warning && ( | |
<img | |
src="/images/alert-triangle.svg" | |
alt="" | |
/> | |
)} | |
<div | |
onClick={() => | |
handleRemoveCondition( | |
intent.id, | |
"group", | |
) | |
} | |
className="group relative cursor-pointer" | |
> | |
<img src="/images/x.svg" alt="" /> | |
<div className="opacity-0 w-fit bg-[rgba(229,238,255,0.15)] text-white text-center text-xs rounded py-2 px-3 absolute z-10 group-hover:opacity-100 top-[-18px] left-1/2 pointer-events-none whitespace-nowrap backdrop-blur-[20px] translate-x-[-50%] translate-y-[-100%] before:content-[''] before:absolute before:left-[50%] before:bottom-0 before:border-[rgba(229,238,255,0.15)] before:border-b-[8px] before:border-l-[8px] before:border-t-[transparent] before:border-r-[transparent] before:border-t-[8px] before:border-r-[8px] before:w-0 before:h-0 before:rotate-[-45deg] before:translate-y-[50%] before:translate-x-[-50%]"> | |
Remove Condition | |
</div> | |
</div> | |
</div> | |
</div> | |
<div className="text-[rgba(229,238,255,0.60)] mt-1"> | |
Any{" "} | |
<span | |
onClick={() => { | |
setIsCountChange(!isCountChange); | |
}} | |
className="min-w-[17px] text-center inline-block bg-[rgba(229,238,255,0.15)] border-[1px] border-[rgba(229,238,255,0.30)] px-[2px] text-white rounded-sm cursor-pointer relative" | |
> | |
{approvalAmount} | |
{isCountChange && ( | |
<div className="w-[56px] bg-[rgba(229,238,255,0.15)] absolute z-10 top-1/2 right-[calc(-100%_-_12px)] translate-x-[100%] backdrop-blur-[20px] translate-y-[-50%] before:content-[''] before:absolute before:left-[0] before:top-1/2 before:border-[rgba(229,238,255,0.3)] before:border-b-[8px] before:border-l-[8px] before:border-t-[transparent] before:border-r-[transparent] before:border-t-[8px] before:border-r-[8px] before:w-0 before:h-0 before:rotate-[45deg] before:translate-y-[-50%] before:translate-x-[-50%]"> | |
<div className="flex flex-col gap-[2px] text-white text-center text-sm py-1 px-1 max-h-[120px] overflow-scroll no-scrollbar"> | |
{[2, 3, 4, 5, 6, 7, 8, 9].map( | |
(item, key) => { | |
return ( | |
<div | |
className={clsx( | |
`min-h-[24px] flex justify-center items-center text-[rgba(229,238,255,0.60)]`, | |
item == | |
approvalAmount && | |
`text-white bg-[rgba(229,238,255,0.15)]`, | |
)} | |
key={key} | |
onClick={() => { | |
setApprovalAmount( | |
item, | |
); | |
}} | |
> | |
{item} | |
</div> | |
); | |
}, | |
)} | |
</div> | |
</div> | |
)} | |
</span>{" "} | |
persons should approve the transaction | |
</div> | |
<div className="mt-8 flex items-center gap-[8px] flex-wrap"> | |
{INTENTS.map((intent, key) => { | |
return ( | |
<AddressUnit intent={intent} key={key} /> | |
); | |
})} | |
<button | |
onClick={() => { | |
setIsPersonsModal(true); | |
}} | |
className={clsx( | |
`text-sm flex w-fit items-center gap-[10px] h-12`, | |
warning | |
? `text-[#E54545]` | |
: `text-[#FFAEEE]`, | |
)} | |
> | |
{warning ? ( | |
<img | |
src="/images/alert-triangle.svg" | |
alt="" | |
/> | |
) : ( | |
<img src="/images/plus.svg" alt="" /> | |
)} | |
Add Persons | |
</button> | |
</div> | |
</div> | |
</div> | |
) : ( | |
<div></div> | |
)} | |
{['group', 'anyone'].map(condition => ( | |
intent.conditions.includes(condition) && ( | |
<div | |
className={clsx( | |
intent.conditions.includes("joint") && | |
`mt-8 pt-4 mb-4 relative`, | |
)} | |
> | |
{intent.conditions.includes("joint") && ( | |
<div | |
className="absolute text-[rgba(229,238,255,0.30)] text-xs left-1/2 top-0 translate-x-[-50%] translate-y-[-50%] w-full text-center | |
before:content-[''] before:w-[calc(50%_-_16px)] before:h-[1px] before:bg-[rgba(229,238,255,0.30)] before:block before:top-1/2 before:left-0 before:absolute | |
after:content-[''] after:w-[calc(50%_-_16px)] after:h-[1px] after:bg-[rgba(229,238,255,0.30)] after:block after:top-1/2 after:right-0 after:absolute" | |
> | |
OR | |
</div> | |
)} | |
<div className="mt-4 mb-4"> | |
<div className="text-xl bg-transparent flex justify-between items-center font-bold"> | |
Approval by certain amount | |
<div className="flex items-center gap-2"> | |
{warning && ( | |
<img | |
src="/images/alert-triangle.svg" | |
alt="" | |
/> | |
)} | |
<div | |
onClick={() => | |
handleRemoveCondition( | |
intent.id, | |
"group", | |
) | |
} | |
className="group relative cursor-pointer" | |
> | |
<img src="/images/x.svg" alt="" /> | |
<div className="opacity-0 w-fit bg-[rgba(229,238,255,0.15)] text-white text-center text-xs rounded py-2 px-3 absolute z-10 group-hover:opacity-100 top-[-18px] left-1/2 pointer-events-none whitespace-nowrap backdrop-blur-[20px] translate-x-[-50%] translate-y-[-100%] before:content-[''] before:absolute before:left-[50%] before:bottom-0 before:border-[rgba(229,238,255,0.15)] before:border-b-[8px] before:border-l-[8px] before:border-t-[transparent] before:border-r-[transparent] before:border-t-[8px] before:border-r-[8px] before:w-0 before:h-0 before:rotate-[-45deg] before:translate-y-[50%] before:translate-x-[-50%]"> | |
Remove Condition | |
</div> | |
</div> | |
</div> | |
</div> | |
<div className="text-[rgba(229,238,255,0.60)] mt-1"> | |
Any{" "} | |
<span | |
onClick={() => { | |
setIsCountChange(!isCountChange); | |
}} | |
className="min-w-[17px] text-center inline-block bg-[rgba(229,238,255,0.15)] border-[1px] border-[rgba(229,238,255,0.30)] px-[2px] text-white rounded-sm cursor-pointer relative" | |
> | |
{approvalAmount} | |
{isCountChange && ( | |
<div className="w-[56px] bg-[rgba(229,238,255,0.15)] absolute z-10 top-1/2 right-[calc(-100%_-_12px)] translate-x-[100%] backdrop-blur-[20px] translate-y-[-50%] before:content-[''] before:absolute before:left-[0] before:top-1/2 before:border-[rgba(229,238,255,0.3)] before:border-b-[8px] before:border-l-[8px] before:border-t-[transparent] before:border-r-[transparent] before:border-t-[8px] before:border-r-[8px] before:w-0 before:h-0 before:rotate-[45deg] before:translate-y-[-50%] before:translate-x-[-50%]"> | |
<div className="flex flex-col gap-[2px] text-white text-center text-sm py-1 px-1 max-h-[120px] overflow-scroll no-scrollbar"> | |
{[2, 3, 4, 5, 6, 7, 8, 9].map( | |
(item, key) => { | |
return ( | |
<div | |
className={clsx( | |
`min-h-[24px] flex justify-center items-center text-[rgba(229,238,255,0.60)]`, | |
item == | |
approvalAmount && | |
`text-white bg-[rgba(229,238,255,0.15)]`, | |
)} | |
key={key} | |
onClick={() => { | |
setApprovalAmount( | |
item, | |
); | |
}} | |
> | |
{item} | |
</div> | |
); | |
}, | |
)} | |
</div> | |
</div> | |
)} | |
</span>{" "} | |
persons should approve the transaction | |
</div> | |
<div className="mt-8 flex items-center gap-[8px] flex-wrap"> | |
{INTENTS.map((intent, key) => { | |
return ( | |
<AddressUnit intent={intent} key={key} /> | |
); | |
})} | |
<button | |
onClick={() => { | |
setIsPersonsModal(true); | |
}} | |
className={clsx( | |
`text-sm flex w-fit items-center gap-[10px] h-12`, | |
warning | |
? `text-[#E54545]` | |
: `text-[#FFAEEE]`, | |
)} | |
> | |
{warning ? ( | |
<img | |
src="/images/alert-triangle.svg" | |
alt="" | |
/> | |
) : ( | |
<img src="/images/plus.svg" alt="" /> | |
)} | |
Add Persons | |
</button> | |
</div> | |
</div> | |
</div> | |
) | |
))} |
Summary by CodeRabbit
New Features
CreateIntent
component for creating and managing intents with various conditions and approval settings.ChangePersonModal
.AddPersonModal
.Enhancements
Intent
component.Bug Fixes
.gitignore
settings to better manage local file exclusion from version control.Refactor
keplr
hook.handleSubmit
function inCreateIntentModal
to streamline component behavior.