-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: basket feature refactoring (#3117)
- Loading branch information
Showing
134 changed files
with
4,449 additions
and
3,316 deletions.
There are no files selected for viewing
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
File renamed without changes.
22 changes: 1 addition & 21 deletions
22
src/renderer/entities/transaction/ui/TransactionTitle/TransactionTitle.test.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
25 changes: 10 additions & 15 deletions
25
src/renderer/entities/transaction/ui/TransactionTitle/TransactionTitle.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
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,2 @@ | ||
export { BasketFilter } from './ui/BasketFilter'; | ||
export { filter } from './model/filter'; |
File renamed without changes.
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
File renamed without changes.
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
94 changes: 94 additions & 0 deletions
94
src/renderer/features/basket-operations/components/BasketOperations.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,94 @@ | ||
import { useGate, useUnit } from 'effector-react'; | ||
|
||
import { type BasketTransaction } from '@/shared/core'; | ||
import { Slot, createSlot } from '@/shared/di'; | ||
import { useI18n } from '@/shared/i18n'; | ||
import { Button, FootnoteText } from '@/shared/ui'; | ||
import { Checkbox } from '@/shared/ui-kit'; | ||
import { selectOperations } from '../model/select'; | ||
import { signOperations } from '../model/sign'; | ||
|
||
import { EmptyBasket } from './EmptyBasket'; | ||
import { RemoveOperation } from './RemoveOperation'; | ||
import { SignOperation } from './SignOperation'; | ||
import { SignOperations } from './SignOperations'; | ||
|
||
type Props = { | ||
operations: BasketTransaction[]; | ||
}; | ||
|
||
export const operationTitleSlot = createSlot<{ operation: BasketTransaction }>(); | ||
|
||
export const BasketOperations = ({ operations }: Props) => { | ||
const { t } = useI18n(); | ||
useGate(selectOperations.flow); | ||
|
||
const selectedTxs = useUnit(selectOperations.$selectedTxs); | ||
|
||
const isSignAvailable = selectedTxs.length > 0; | ||
|
||
return ( | ||
<> | ||
<div className="mt-4 flex w-full flex-col items-center gap-4"> | ||
<div className="flex w-[736px] items-center justify-between"> | ||
<div className="ml-3"> | ||
<Checkbox | ||
checked={operations.length > 0 && operations.length === selectedTxs.length} | ||
semiChecked={selectedTxs.length > 0 && operations.length !== selectedTxs.length} | ||
onChange={() => selectOperations.selectTxs(operations)} | ||
> | ||
<FootnoteText className="text-text-secondary"> | ||
{t('basket.selectedStatus', { count: operations.length, selected: selectedTxs.length })} | ||
</FootnoteText> | ||
</Checkbox> | ||
</div> | ||
<div className="flex items-center gap-4"> | ||
<Button | ||
size="sm" | ||
className="w-[125px]" | ||
disabled={!isSignAvailable} | ||
onClick={() => signOperations.events.flowStarted({ transactions: selectedTxs, feeMap: {} })} | ||
> | ||
{t(selectedTxs.length === 0 ? 'basket.emptySignButton' : 'basket.signButton')} | ||
</Button> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{operations.length > 0 && ( | ||
<div className="scrollbar-stable mt-4 flex w-full flex-col items-center gap-4 overflow-y-auto"> | ||
<ul className="flex w-[736px] flex-col gap-y-1.5 divide-y rounded-md"> | ||
{operations.map((operation) => ( | ||
<li key={operation.id} className="flex gap-x-4 bg-block-background-default px-3"> | ||
<div className="flex items-center justify-center"> | ||
<Checkbox | ||
checked={selectedTxs.includes(operation)} | ||
onClick={(e) => { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
|
||
selectOperations.selectTx(operation); | ||
}} | ||
/> | ||
</div> | ||
|
||
<div | ||
className="flex h-[52px] w-full items-center gap-x-4 overflow-hidden" | ||
onClick={() => signOperations.events.flowStarted({ transactions: [operation], feeMap: {} })} | ||
> | ||
<Slot id={operationTitleSlot} props={{ operation }} /> | ||
</div> | ||
|
||
<RemoveOperation operation={operation} /> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
)} | ||
|
||
{operations.length === 0 && <EmptyBasket />} | ||
|
||
{selectedTxs.length > 1 ? <SignOperations /> : <SignOperation />} | ||
</> | ||
); | ||
}; |
File renamed without changes.
Oops, something went wrong.