{!noteOpen && (
@@ -189,7 +190,7 @@ export function DateSheet({ open, onOpenChange, value, onChange, repeat }: DateS
@@ -200,6 +201,9 @@ export function DateSheet({ open, onOpenChange, value, onChange, repeat }: DateS
)
}
+const pressedRepeatClassName =
+ 'aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:font-semibold aria-pressed:text-primary-foreground aria-pressed:hover:bg-primary aria-pressed:active:bg-primary'
+
function startOfMonth(isoDate: string): string {
return `${isoDate.slice(0, 7)}-01`
}
diff --git a/frontend/src/features/add/EditExpensePage.test.tsx b/frontend/src/features/add/EditExpensePage.test.tsx
index d674383..cc320d8 100644
--- a/frontend/src/features/add/EditExpensePage.test.tsx
+++ b/frontend/src/features/add/EditExpensePage.test.tsx
@@ -112,6 +112,8 @@ describe('EditExpensePage', () => {
)
await userEvent.click(within(sheet).getByRole('button', { name: 'Every 2 weeks' }))
expect(screen.getByText('The next one copies them.')).toBeInTheDocument()
+ await userEvent.click(within(sheet).getByRole('button', { name: 'Yesterday' }))
+ expect(sheet).toBeInTheDocument()
await userEvent.click(within(sheet).getByRole('button', { name: 'Done' }))
await userEvent.click(screen.getByRole('button', { name: 'Save changes' }))
diff --git a/frontend/src/features/add/EditExpensePage.tsx b/frontend/src/features/add/EditExpensePage.tsx
index 58afd45..91f9a48 100644
--- a/frontend/src/features/add/EditExpensePage.tsx
+++ b/frontend/src/features/add/EditExpensePage.tsx
@@ -2,7 +2,7 @@ import { useState } from 'react'
import { useLingui } from '@lingui/react/macro'
import { useParams } from 'react-router'
import { parseIdParam } from '@/lib/parseIdParam'
-import { calendarDayKey } from '@/lib/dates'
+import { continuesRepeat } from '@/lib/repeat'
import { useMe } from '@/api/auth'
import { useExpense } from '@/api/expenses'
import type { ExpenseResponse, MeResponse } from '@/api/types'
@@ -76,7 +76,6 @@ function EditExpenseForm({
const [draft, setDraft] = useState(initialDraft)
const guard = useLeaveGuard(draftChanged(draft, initialDraft), fallback)
const series = expense.series
- const continuesRepeat = series?.isLatest === true && expense.repeat?.active === true
// The server's next date only holds while the date and the repeat stay as loaded.
const scheduleKept =
draft.occurredOn === initialDraft.occurredOn && draft.repeat === initialDraft.repeat
@@ -94,8 +93,8 @@ function EditExpenseForm({
expenseId: expense.id,
canRepeat: series === null || series.isLatest,
nextCopy:
- continuesRepeat && draft.repeat !== 'off'
- ? { on: scheduleKept && nextOn ? calendarDayKey(nextOn) : null }
+ continuesRepeat(expense) && draft.repeat !== 'off'
+ ? { on: scheduleKept && nextOn ? nextOn : null }
: null,
}}
onSaved={guard.leaveAfterSave}
diff --git a/frontend/src/features/add/expenseDraft.ts b/frontend/src/features/add/expenseDraft.ts
index 21b1fa1..47c9870 100644
--- a/frontend/src/features/add/expenseDraft.ts
+++ b/frontend/src/features/add/expenseDraft.ts
@@ -13,7 +13,7 @@ import { expenseCategories } from '@/lib/categories'
import { calendarDayKey } from '@/lib/dates'
import { trimDecimal } from '@/lib/decimal'
import { peopleOtherThan } from '@/lib/person'
-import { choiceOf, repeatOf, type RepeatChoice } from '@/lib/repeat'
+import { choiceOf, continuesRepeat, repeatOf, type RepeatChoice } from '@/lib/repeat'
import { checkSplit, defaultSplit, splitDebts, type SplitDraft } from './splitModel'
/** The Add expense form, as typed. The user is always in it and isn't listed in `others`. */
@@ -78,7 +78,7 @@ export function draftFromExpense(expense: ExpenseResponse, meId: number): Expens
categoryPicked: true,
amount: expense.amount,
occurredOn: calendarDayKey(expense.occurredOn),
- repeat: expense.series?.isLatest && expense.repeat?.active ? choiceOf(expense.repeat) : 'off',
+ repeat: continuesRepeat(expense) ? choiceOf(expense.repeat) : 'off',
note: expense.description ?? '',
split: {
payerId: expense.payee.id,
@@ -221,7 +221,6 @@ export function buildExpenseRequest(draft: ExpenseDraft, meId: number): BuildRes
splitType: draft.split.type,
category: draft.category,
description: draft.note.trim() === '' ? null : draft.note.trim(),
- // Always sent: an omitted repeat stops it.
repeat: repeatOf(draft.repeat),
}
const parsed = expenseRequestSchema.safeParse(candidate)
diff --git a/frontend/src/features/detail/ExpenseDetailPage.tsx b/frontend/src/features/detail/ExpenseDetailPage.tsx
index 2f5d6cb..2012db3 100644
--- a/frontend/src/features/detail/ExpenseDetailPage.tsx
+++ b/frontend/src/features/detail/ExpenseDetailPage.tsx
@@ -10,8 +10,8 @@ import type { ExpenseResponse } from '@/api/types'
import { CategoryTile } from '@/components/CategoryTile'
import { PersonAvatar } from '@/components/PersonAvatar'
import { categoryLabel } from '@/lib/categories'
-import { calendarDayKey, formatShortDate } from '@/lib/dates'
-import { partOfRepeatLabel, repeatsLabel, repeatStopsLabel } from '@/lib/repeat'
+import { formatShortDate } from '@/lib/dates'
+import { continuesRepeat, partOfRepeatLabel, repeatsLabel, repeatStopsLabel } from '@/lib/repeat'
import { balanceTextClassName, formatMoney } from '@/lib/money'
import { cn } from '@/lib/utils'
import { ItemError, ItemLoading, ItemNotFound } from '@/components/ItemStates'
@@ -35,7 +35,7 @@ export function ExpenseDetailPage() {
) : (
-
+
)
}
@@ -66,11 +66,11 @@ function ExpenseDetailScreen({ id }: { id: number }) {
confirmTitle={t`Delete “${expenseTitle}”?`}
confirmDescription={deleteWarning(otherParticipantNames(expense, me.id))}
confirmNote={
- expense.series?.isLatest && expense.repeat?.active ? (
-
+ continuesRepeat(expense) && expense.repeat ? (
+
{repeatStopsLabel(expense.repeat)}
-
+
) : undefined
}
deletion={deletion}
@@ -188,11 +188,12 @@ function RepeatLine({ expense }: { expense: ExpenseResponse }) {
return null
}
- const nextOn = formatShortDate(calendarDayKey(repeat.nextOn))
+ const label = repeatsLabel(repeat)
+ const nextOn = formatShortDate(repeat.nextOn)
return (
- {repeatsLabel(repeat)} · {t`next on ${nextOn}`}
+ {t`${label} · next on ${nextOn}`}
)
}
@@ -200,7 +201,7 @@ function RepeatLine({ expense }: { expense: ExpenseResponse }) {
function OlderRepeatLink({ label, latestId }: { label: string; latestId: number }) {
const { t } = useLingui()
const latest = useExpense(latestId).data
- const latestOn = latest ? formatShortDate(calendarDayKey(latest.occurredOn)) : null
+ const latestOn = latest ? formatShortDate(latest.occurredOn) : null
return (
- {latestOn === null ? label : `${label} · ${t`latest ${latestOn}`}`}
+ {latestOn === null ? label : t`${label} · latest ${latestOn}`}
)
diff --git a/frontend/src/lib/repeat.ts b/frontend/src/lib/repeat.ts
index e018c11..b341f31 100644
--- a/frontend/src/lib/repeat.ts
+++ b/frontend/src/lib/repeat.ts
@@ -1,5 +1,5 @@
import { t } from '@lingui/core/macro'
-import type { Repeat } from '@/api/types'
+import type { ExpenseResponse, Repeat } from '@/api/types'
export type RepeatChoice = 'off' | 'weekly' | 'biweekly' | 'monthly' | 'yearly'
@@ -12,6 +12,11 @@ const repeats: Record
, Repeat> = {
yearly: { unit: 'year', every: 1 },
}
+/** The latest expense of a repeat that is still running: the next one copies it. */
+export function continuesRepeat(expense: ExpenseResponse): boolean {
+ return expense.series?.isLatest === true && expense.repeat?.active === true
+}
+
export function repeatOf(choice: RepeatChoice): Repeat | null {
return choice === 'off' ? null : repeats[choice]
}
@@ -27,7 +32,6 @@ export function choiceOf(repeat: Repeat | null): RepeatChoice {
return match ?? 'off'
}
-/** The chip label: "Off", "Weekly", "Every 2 weeks", "Monthly", "Yearly". */
export function repeatChoiceLabel(choice: RepeatChoice): string {
switch (choice) {
case 'off':
@@ -43,7 +47,7 @@ export function repeatChoiceLabel(choice: RepeatChoice): string {
}
}
-/** On the latest expense: "Repeats monthly". */
+/** On the latest expense. */
export function repeatsLabel(repeat: Repeat): string {
switch (choiceOf(repeat)) {
case 'weekly':
@@ -57,7 +61,7 @@ export function repeatsLabel(repeat: Repeat): string {
}
}
-/** On an older expense: "Part of a monthly repeat". */
+/** On an older expense. */
export function partOfRepeatLabel(repeat: Repeat): string {
switch (choiceOf(repeat)) {
case 'weekly':
diff --git a/frontend/src/locales/en.po b/frontend/src/locales/en.po
index 5d67088..e3d68f1 100644
--- a/frontend/src/locales/en.po
+++ b/frontend/src/locales/en.po
@@ -27,6 +27,10 @@ msgstr "{assignedPercent}% of 100%"
msgid "{date} · {subline}"
msgstr "{date} · {subline}"
+#: src/features/add/DateNoteFields.tsx
+msgid "{dateLabel} · {frequency}"
+msgstr "{dateLabel} · {frequency}"
+
#: src/features/detail/commentTime.ts
msgid "{day}, {time}"
msgstr "{day}, {time}"
@@ -63,6 +67,14 @@ msgstr "{each} each"
msgid "{futureDate} is in the future. It still counts towards your balances straight away."
msgstr "{futureDate} is in the future. It still counts towards your balances straight away."
+#: src/features/detail/ExpenseDetailPage.tsx
+msgid "{label} · latest {latestOn}"
+msgstr "{label} · latest {latestOn}"
+
+#: src/features/detail/ExpenseDetailPage.tsx
+msgid "{label} · next on {nextOn}"
+msgstr "{label} · next on {nextOn}"
+
#: src/features/add/DateSheet.tsx
msgid "{longDate}, today"
msgstr "{longDate}, today"
@@ -820,10 +832,6 @@ msgstr "Keep editing"
msgid "Keep the title under 255 characters"
msgstr "Keep the title under 255 characters"
-#: src/features/detail/ExpenseDetailPage.tsx
-msgid "latest {latestOn}"
-msgstr "latest {latestOn}"
-
#: src/features/profile/EditNamePage.tsx
msgid "Leave empty to show your email."
msgstr "Leave empty to show your email."
@@ -919,10 +927,6 @@ msgstr "New to Settle? <0>Create an account0>"
msgid "Next month"
msgstr "Next month"
-#: src/features/detail/ExpenseDetailPage.tsx
-msgid "next on {nextOn}"
-msgstr "next on {nextOn}"
-
#: src/features/contacts/AddContactPage.tsx
#: src/features/contacts/EditContactPage.tsx
msgid "Nickname <0>(optional)0>"
diff --git a/frontend/src/locales/pl.po b/frontend/src/locales/pl.po
index 4b50300..e5a46a6 100644
--- a/frontend/src/locales/pl.po
+++ b/frontend/src/locales/pl.po
@@ -27,6 +27,10 @@ msgstr "{assignedPercent}% ze 100%"
msgid "{date} · {subline}"
msgstr "{date} · {subline}"
+#: src/features/add/DateNoteFields.tsx
+msgid "{dateLabel} · {frequency}"
+msgstr "{dateLabel} · {frequency}"
+
#: src/features/detail/commentTime.ts
msgid "{day}, {time}"
msgstr "{day}, {time}"
@@ -63,6 +67,14 @@ msgstr "Po {each}"
msgid "{futureDate} is in the future. It still counts towards your balances straight away."
msgstr "{futureDate} to data z przyszłości. Mimo to od razu wlicza się do sald."
+#: src/features/detail/ExpenseDetailPage.tsx
+msgid "{label} · latest {latestOn}"
+msgstr "{label} · ostatni {latestOn}"
+
+#: src/features/detail/ExpenseDetailPage.tsx
+msgid "{label} · next on {nextOn}"
+msgstr "{label} · następny {nextOn}"
+
#: src/features/add/DateSheet.tsx
msgid "{longDate}, today"
msgstr "{longDate}, dzisiaj"
@@ -820,10 +832,6 @@ msgstr "Edytuj dalej"
msgid "Keep the title under 255 characters"
msgstr "Tytuł musi mieć mniej niż 255 znaków"
-#: src/features/detail/ExpenseDetailPage.tsx
-msgid "latest {latestOn}"
-msgstr "ostatni {latestOn}"
-
#: src/features/profile/EditNamePage.tsx
msgid "Leave empty to show your email."
msgstr "Zostaw puste, aby pokazywać adres e-mail."
@@ -919,10 +927,6 @@ msgstr "Pierwszy raz w Settle? <0>Załóż konto0>"
msgid "Next month"
msgstr "Następny miesiąc"
-#: src/features/detail/ExpenseDetailPage.tsx
-msgid "next on {nextOn}"
-msgstr "następny {nextOn}"
-
#: src/features/contacts/AddContactPage.tsx
#: src/features/contacts/EditContactPage.tsx
msgid "Nickname <0>(optional)0>"
From 880c42253edb4d82a95c98b30d2082c095e52ac7 Mon Sep 17 00:00:00 2001
From: Ame <37273244+ame180@users.noreply.github.com>
Date: Fri, 27 Nov 2026 20:14:02 +0100
Subject: [PATCH 3/3] chore: trim restating comments in the repeat UI
---
frontend/src/api/types.ts | 5 -----
frontend/src/components/ConfirmSheet.tsx | 1 -
frontend/src/features/add/DateNoteFields.tsx | 1 -
frontend/src/features/add/ExpenseForm.tsx | 2 --
frontend/src/lib/repeat.ts | 5 -----
5 files changed, 14 deletions(-)
diff --git a/frontend/src/api/types.ts b/frontend/src/api/types.ts
index e52c4c7..27a54ef 100644
--- a/frontend/src/api/types.ts
+++ b/frontend/src/api/types.ts
@@ -58,7 +58,6 @@ export type ExpenseDebtRequest = {
export type RepeatUnit = 'week' | 'month' | 'year'
-/** Weekly, every 2 weeks, monthly or yearly: the only combinations the API accepts for now. */
export type Repeat = {
unit: RepeatUnit
every: number
@@ -73,7 +72,6 @@ export type ExpenseRequest = {
splitType?: SplitType
category?: ExpenseCategory
description?: string | null
- /** null or omitted: no repeat (on the latest, that stops it). Only the latest in a repeat may set it. */
repeat?: Repeat | null
}
@@ -94,13 +92,11 @@ export type ExpenseResponse = {
splitType: SplitType
category: ExpenseCategory
debts: ExpenseDebtResponse[]
- /** Set on every expense in a repeat, the latest or an older one, active or stopped. */
repeat: RepeatResponse | null
series: SeriesResponse | null
}
export type RepeatResponse = Repeat & {
- /** Null once the repeat has stopped. */
nextOn: string | null
active: boolean
}
@@ -162,7 +158,6 @@ export type ActivityItem = {
/** Transfers only. */
payer: PersonRef | null
category: ExpenseCategory | null
- /** The expense is part of a repeat, active or stopped. */
recurring: boolean
}
diff --git a/frontend/src/components/ConfirmSheet.tsx b/frontend/src/components/ConfirmSheet.tsx
index 63315aa..a555300 100644
--- a/frontend/src/components/ConfirmSheet.tsx
+++ b/frontend/src/components/ConfirmSheet.tsx
@@ -19,7 +19,6 @@ type ConfirmSheetProps = {
onOpenChange: (open: boolean) => void
title: string
description: string
- /** Inline content ending the description, such as what else the action stops. */
note?: ReactNode
/** The destructive action: "Delete expense", "Discard". */
confirmLabel: string
diff --git a/frontend/src/features/add/DateNoteFields.tsx b/frontend/src/features/add/DateNoteFields.tsx
index 7f4149b..2474dca 100644
--- a/frontend/src/features/add/DateNoteFields.tsx
+++ b/frontend/src/features/add/DateNoteFields.tsx
@@ -13,7 +13,6 @@ type DateNoteFieldsProps = {
idPrefix: string
occurredOn: string
onDateChange: (occurredOn: string) => void
- /** Offered in the date sheet when given. */
repeat?: { value: RepeatChoice; onChange: (repeat: RepeatChoice) => void }
dateError?: string
note: string
diff --git a/frontend/src/features/add/ExpenseForm.tsx b/frontend/src/features/add/ExpenseForm.tsx
index 7e55a63..6dc0591 100644
--- a/frontend/src/features/add/ExpenseForm.tsx
+++ b/frontend/src/features/add/ExpenseForm.tsx
@@ -57,9 +57,7 @@ type ExpenseFormProps = {
| {
kind: 'edit'
expenseId: number
- /** False on an older expense of a repeat: only the latest can change it. */
canRepeat: boolean
- /** Editing the latest of an active repeat: the next one copies the changes. */
nextCopy: { on: string | null } | null
}
initialFocus?: 'people' | 'title'
diff --git a/frontend/src/lib/repeat.ts b/frontend/src/lib/repeat.ts
index b341f31..3f0cf5b 100644
--- a/frontend/src/lib/repeat.ts
+++ b/frontend/src/lib/repeat.ts
@@ -12,7 +12,6 @@ const repeats: Record, Repeat> = {
yearly: { unit: 'year', every: 1 },
}
-/** The latest expense of a repeat that is still running: the next one copies it. */
export function continuesRepeat(expense: ExpenseResponse): boolean {
return expense.series?.isLatest === true && expense.repeat?.active === true
}
@@ -21,7 +20,6 @@ export function repeatOf(choice: RepeatChoice): Repeat | null {
return choice === 'off' ? null : repeats[choice]
}
-/** Anything the picker can't show reads as off. */
export function choiceOf(repeat: Repeat | null): RepeatChoice {
if (repeat === null) {
return 'off'
@@ -47,7 +45,6 @@ export function repeatChoiceLabel(choice: RepeatChoice): string {
}
}
-/** On the latest expense. */
export function repeatsLabel(repeat: Repeat): string {
switch (choiceOf(repeat)) {
case 'weekly':
@@ -61,7 +58,6 @@ export function repeatsLabel(repeat: Repeat): string {
}
}
-/** On an older expense. */
export function partOfRepeatLabel(repeat: Repeat): string {
switch (choiceOf(repeat)) {
case 'weekly':
@@ -75,7 +71,6 @@ export function partOfRepeatLabel(repeat: Repeat): string {
}
}
-/** In the delete sheet of the latest expense. */
export function repeatStopsLabel(repeat: Repeat): string {
switch (choiceOf(repeat)) {
case 'weekly':