Skip to content

Commit

Permalink
Updated based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-jeremy committed Apr 4, 2024
1 parent dfb61b0 commit 2ae6d8c
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ type AccountItemProps = {
embedded?: boolean;
};

// eslint-disable-next-line import/no-unused-modules
export function AccountItem({
function AccountItem({
item,
className,
highlighted,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,7 @@ type CategoryItemProps = {
embedded?: boolean;
};

// eslint-disable-next-line import/no-unused-modules
export function CategoryItem({
function CategoryItem({
item,
className,
style,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,7 @@ type PayeeItemProps = {
embedded?: boolean;
};

// eslint-disable-next-line import/no-unused-modules
export function PayeeItem({
function PayeeItem({
item,
className,
highlighted,
Expand Down
44 changes: 37 additions & 7 deletions packages/desktop-client/src/components/modals/AccountMenuModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-strict-ignore
import React, { useState } from 'react';

import { useLiveQuery } from 'loot-core/src/client/query-hooks';
Expand All @@ -17,6 +16,11 @@ import { type CommonModalProps } from '../Modals';
import { Notes } from '../Notes';
import { Tooltip } from '../tooltips';

type NoteEntity = {
id: string;
note: string;
};

type AccountMenuModalProps = {
modalProps: CommonModalProps;
accountId: string;
Expand All @@ -39,17 +43,21 @@ export function AccountMenuModal({
const accounts = useAccounts();
const account = accounts.find(c => c.id === accountId);
const data = useLiveQuery(
() => q('notes').filter({ id: account.id }).select('*'),
[account.id],
);
() => q('notes').filter({ id: account?.id }).select('*'),
[account?.id],
) as NoteEntity[] | null;
const originalNotes = data && data.length > 0 ? data[0].note : null;

const _onClose = () => {
modalProps?.onClose();
onClose?.();
};

const onRename = newName => {
const onRename = (newName: string) => {
if (!account) {
return;
}

if (newName !== account.name) {
onSave?.({
...account,
Expand All @@ -59,6 +67,10 @@ export function AccountMenuModal({
};

const _onEditNotes = () => {
if (!account) {
return;
}

onEditNotes?.(account.id);
};

Expand All @@ -70,6 +82,10 @@ export function AccountMenuModal({
flexBasis: '100%',
};

if (!account) {
return null;
}

return (
<Modal
title={account.name}
Expand Down Expand Up @@ -109,7 +125,11 @@ export function AccountMenuModal({
}}
>
<Notes
notes={originalNotes?.length > 0 ? originalNotes : 'No notes'}
notes={
originalNotes && originalNotes.length > 0
? originalNotes
: 'No notes'
}
editable={false}
focused={false}
getStyle={() => ({
Expand Down Expand Up @@ -152,7 +172,17 @@ export function AccountMenuModal({
);
}

function AdditionalAccountMenu({ account, onClose, onReopen }) {
type AdditionalAccountMenuProps = {
account: AccountEntity;
onClose?: (accountId: string) => void;
onReopen?: (accountId: string) => void;
};

function AdditionalAccountMenu({
account,
onClose,
onReopen,
}: AdditionalAccountMenuProps) {
const [menuOpen, setMenuOpen] = useState(false);
const itemStyle: CSSProperties = {
...styles.mediumText,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function CoverModal({

const category = categories.find(c => c.id === categoryId);

if (category == null) {
if (!category) {
return null;
}

Expand Down
3 changes: 1 addition & 2 deletions packages/loot-core/src/server/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,7 @@ handlers['must-category-transfer'] = async function ({ id }) {

handlers['payee-create'] = mutator(async function ({ name }) {
return withUndo(async () => {
const id = await db.insertPayee({ name });
return id;
return db.insertPayee({ name });
});
});

Expand Down
2 changes: 1 addition & 1 deletion upcoming-release-notes/2472.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ category: Enhancements
authors: [joel-jeremy]
---

Mobile menu modals.
Add more modals in mobile for account, scheduled transactions, budget summary, and balance actions.

0 comments on commit 2ae6d8c

Please sign in to comment.