-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Schedule table in Link Schedule modal is collapsed (#1501)
Co-authored-by: kyrias <[email protected]>
- Loading branch information
Showing
7 changed files
with
116 additions
and
68 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
65 changes: 0 additions & 65 deletions
65
packages/desktop-client/src/components/schedules/LinkSchedule.js
This file was deleted.
Oops, something went wrong.
95 changes: 95 additions & 0 deletions
95
packages/desktop-client/src/components/schedules/LinkSchedule.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,95 @@ | ||
import React, { useCallback, useRef, useState } from 'react'; | ||
|
||
import { useSchedules } from 'loot-core/src/client/data-hooks/schedules'; | ||
import { send } from 'loot-core/src/platform/client/fetch'; | ||
import { type Query } from 'loot-core/src/shared/query'; | ||
|
||
import { type BoundActions } from '../../hooks/useActions'; | ||
import { type CommonModalProps } from '../../types/modals'; | ||
import Modal from '../common/Modal'; | ||
import Search from '../common/Search'; | ||
import Text from '../common/Text'; | ||
import View from '../common/View'; | ||
|
||
import { ROW_HEIGHT, SchedulesTable } from './SchedulesTable'; | ||
|
||
export default function ScheduleLink({ | ||
modalProps, | ||
actions, | ||
transactionIds: ids, | ||
}: { | ||
actions: BoundActions; | ||
modalProps?: CommonModalProps; | ||
transactionIds: string[]; | ||
}) { | ||
let [filter, setFilter] = useState(''); | ||
|
||
let scheduleData = useSchedules({ | ||
transform: useCallback((q: Query) => q.filter({ completed: false }), []), | ||
}); | ||
|
||
let searchInput = useRef(null); | ||
if (scheduleData == null) { | ||
return null; | ||
} | ||
|
||
let { schedules, statuses } = scheduleData; | ||
|
||
async function onSelect(scheduleId: string) { | ||
if (ids?.length > 0) { | ||
await send('transactions-batch-update', { | ||
updated: ids.map(id => ({ id, schedule: scheduleId })), | ||
}); | ||
} | ||
actions.popModal(); | ||
} | ||
|
||
return ( | ||
<Modal title="Link Schedule" size={{ width: 600 }} {...modalProps}> | ||
<View | ||
style={{ | ||
flexDirection: 'row', | ||
gap: 4, | ||
marginBottom: 20, | ||
alignItems: 'center', | ||
}} | ||
> | ||
<Text> | ||
Choose the schedule{' '} | ||
{ids?.length > 1 | ||
? `these ${ids.length} transactions belong` | ||
: `this transaction belongs`}{' '} | ||
to: | ||
</Text> | ||
<Search | ||
inputRef={searchInput} | ||
isInModal | ||
width={300} | ||
placeholder="Filter schedules…" | ||
value={filter} | ||
onChange={setFilter} | ||
/> | ||
</View> | ||
|
||
<View | ||
style={{ | ||
marginTop: 15, | ||
flexBasis: (ROW_HEIGHT - 1) * (Math.max(schedules.length, 1) + 1), | ||
overflow: 'hidden', | ||
}} | ||
> | ||
<SchedulesTable | ||
allowCompleted={false} | ||
filter={filter} | ||
minimal={true} | ||
onAction={() => {}} | ||
onSelect={onSelect} | ||
schedules={schedules} | ||
statuses={statuses} | ||
style={null} | ||
tableStyle={{ marginInline: -20 }} | ||
/> | ||
</View> | ||
</Modal> | ||
); | ||
} |
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,10 @@ | ||
import { type PopModalAction } from 'loot-core/src/client/state-types/modals'; | ||
|
||
export type CommonModalProps = { | ||
onClose: () => PopModalAction; | ||
onBack: () => PopModalAction; | ||
showBack: boolean; | ||
isCurrent: boolean; | ||
isHidden: boolean; | ||
stackIndex: number; | ||
}; |
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,6 @@ | ||
--- | ||
category: Bugfix | ||
authors: [trevdor] | ||
--- | ||
|
||
Fix collapsed schedules table in Link Schedule modal |