Skip to content

Commit

Permalink
Slightly improved UX
Browse files Browse the repository at this point in the history
  • Loading branch information
Jessseee committed Oct 22, 2023
1 parent 57d95a8 commit 53de427
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions packages/desktop-client/src/components/modals/ImportTransactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ function parseAmountFields(
trans,
splitMode,
inOutMode,
outText,
outValue,
flipAmount,
multiplierAmount,
) {
Expand All @@ -262,7 +262,7 @@ function parseAmountFields(
return {
amount:
parseAmount(trans.amount, n =>
trans.inout === outText ? Math.abs(n) * -1 : Math.abs(n),
trans.inout === outValue ? Math.abs(n) * -1 : Math.abs(n),
) * multiplier,
outflow: null,
inflow: null,
Expand All @@ -284,7 +284,7 @@ function Transaction({
dateFormat,
splitMode,
inOutMode,
outText,
outValue,
flipAmount,
multiplierAmount,
}) {
Expand All @@ -300,7 +300,7 @@ function Transaction({
transaction,
splitMode,
inOutMode,
outText,
outValue,
flipAmount,
multiplierAmount,
);
Expand Down Expand Up @@ -500,7 +500,13 @@ function MultiplierOption({
);
}

function InOutOption({ inOutMode, outText, disabled, onToggle, onChangeText }) {
function InOutOption({
inOutMode,
outValue,
disabled,
onToggle,
onChangeText,
}) {
return (
<View style={{ flexDirection: 'row', gap: 10, height: 28 }}>
<CheckboxOption
Expand All @@ -510,16 +516,17 @@ function InOutOption({ inOutMode, outText, disabled, onToggle, onChangeText }) {
onChange={onToggle}
>
{inOutMode
? 'In/out column'
? 'in/out field'
: 'Select column to specify if amount goes in/out'}
</CheckboxOption>
<Input
type="text"
style={{ display: inOutMode ? 'inherit' : 'none' }}
value={outText}
placeholder="Out text"
onUpdate={onChangeText}
/>
{inOutMode && (
<Input
type="text"
value={outValue}
onUpdate={onChangeText}
placeholder="Out value"
/>
)}
</View>
);
}
Expand Down Expand Up @@ -652,7 +659,7 @@ export default function ImportTransactions({ modalProps, options }) {
let [fieldMappings, setFieldMappings] = useState(null);
let [splitMode, setSplitMode] = useState(false);
let [inOutMode, setInOutMode] = useState(false);
let [outText, setOutText] = useState('Debit');
let [outValue, setOutValue] = useState('');
let [flipAmount, setFlipAmount] = useState(false);
let [multiplierEnabled, setMultiplierEnabled] = useState(false);
let { accountId, onImported } = options;
Expand Down Expand Up @@ -836,7 +843,7 @@ export default function ImportTransactions({ modalProps, options }) {
trans,
splitMode,
inOutMode,
outText,
outValue,
flipAmount,
multiplierAmount,
);
Expand Down Expand Up @@ -965,7 +972,7 @@ export default function ImportTransactions({ modalProps, options }) {
fieldMappings={fieldMappings}
splitMode={splitMode}
inOutMode={inOutMode}
outText={outText}
outValue={outValue}
flipAmount={flipAmount}
multiplierAmount={multiplierAmount}
/>
Expand Down Expand Up @@ -1129,10 +1136,10 @@ export default function ImportTransactions({ modalProps, options }) {
</CheckboxOption>
<InOutOption
inOutMode={inOutMode}
outText={outText}
outValue={outValue}
disabled={splitMode || flipAmount}
onToggle={() => setInOutMode(!inOutMode)}
onChangeText={setOutText}
onChangeText={setOutValue}
/>
</>
)}
Expand Down

0 comments on commit 53de427

Please sign in to comment.