Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/alexa/src/graphql/get-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const query = gql`
entries {
id
time
time_split
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/alexa/src/helpers/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getLaraConfig } from '../graphql/config'
type ReducedDay = Pick<Day, 'id' | 'status'> & { entries: Pick<Entry, 'time' | 'time_split'>[] }

const totalDayMinutes = (day: ReducedDay) =>
day.entries.reduce((acc, entry) => acc + (entry.time ? entry.time : entry.time_split!), 0)
day.entries.reduce((acc, entry) => acc + (entry.time ?? entry.time_split ?? 0), 0)

export const finishedDays = async (days: ReducedDay[]): Promise<number> => {
const config = await getLaraConfig()
Expand Down
13 changes: 9 additions & 4 deletions packages/frontend/src/components/entry-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,19 @@ const EntryInput: React.FC<EntryDisplayFieldProps> = ({
const handleSave = (newEntry: EntryInputType) => {
setEditing(false)

if (
!isValidTimeUpdate(day, newEntry.time ? newEntry.time - entry.time! : newEntry.time_split! - entry.time_split!)
) {
const previousTime = !secondary ? (entry.time ?? 0) : (entry.time_split ?? 0)
const nextTime = !secondary ? (newEntry.time ?? 0) : (newEntry.time_split ?? 0)

if (!isValidTimeUpdate(day, nextTime - previousTime)) {
addToast({ text: strings.entryStatus.changeError, type: 'error' })
return
}

if (newEntry.text === entry.text && newEntry.time === entry.time) {
const isUnchanged = !secondary
? newEntry.text === entry.text && newEntry.time === entry.time
: newEntry.text_split === entry.text_split && newEntry.time_split === entry.time_split

if (isUnchanged) {
return
}

Expand Down
11 changes: 9 additions & 2 deletions packages/frontend/src/components/suggestions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,14 @@ const Suggestions: React.FC<SuggestionProps> = ({ submitTextSuggestion, submitTi
case 'Enter':
// submit the suggestion if shift isn't pressed
if (!event.shiftKey && focusIndex > -1) {
setWaitingForBlur(suggestions[focusIndex])
event.preventDefault()
const suggestionsTextWithTime = suggestionsWithTimes[focusIndex]
if (suggestionsTextWithTime) {
setWaitingForBlur(suggestionsTextWithTime.text)
setWaitingForBlurTimeSuggestion(suggestionsTextWithTime.time)
} else {
setWaitingForBlur(suggestions[focusIndex])
}
}
break
case 'ArrowUp':
Expand Down Expand Up @@ -104,7 +111,7 @@ const Suggestions: React.FC<SuggestionProps> = ({ submitTextSuggestion, submitTi
break
}
},
[setWaitingForBlur, focusIndex, inputRef, suggestions]
[setWaitingForBlur, focusIndex, inputRef, suggestions, suggestionsWithTimes]
)

React.useEffect(() => {
Expand Down
Loading
Loading