Skip to content
This repository has been archived by the owner on Jan 2, 2022. It is now read-only.

Commit

Permalink
fix: active task popup title
Browse files Browse the repository at this point in the history
WDY-288
  • Loading branch information
jcmnunes committed Jun 11, 2020
1 parent c498578 commit c6bea7f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
11 changes: 6 additions & 5 deletions frontend/src/features/day/Board/Board.error.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { useHistory } from 'react-router';
import styled from 'styled-components/macro';
import { Button, Icon } from '@binarycapsule/ui-capsules';
import { AxiosError } from 'axios';
Expand Down Expand Up @@ -39,6 +40,8 @@ interface Props {

// TODO ➜ Improve error handling
export const BoardError: React.FC<Props> = ({ error }) => {
const history = useHistory();

const status = error?.response?.status;

return (
Expand All @@ -52,11 +55,9 @@ export const BoardError: React.FC<Props> = ({ error }) => {
{status === 404 ? 'Day not found' : 'Oops, something went wrong...'}
</ErrorText>

{status !== 404 && (
<Button appearance="minimal" iconBefore="refresh" onClick={document.location.reload}>
Refresh the page
</Button>
)}
<Button appearance="minimal" iconBefore="refresh" onClick={() => history.push('/day')}>
Refresh the page
</Button>
</StyledBoardError>
);
};
9 changes: 8 additions & 1 deletion frontend/src/features/day/api/useUpdateTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const useUpdateTask = () => {
queryCache.cancelQueries('activeTask');

const previousDay = queryCache.getQueryData(['day', dayId]) as DayDto;
const previousActiveTask = queryCache.getQueryData('activeTask');
const previousActiveTask = queryCache.getQueryData('activeTask') as ActiveTaskDto;
const scopes = queryCache.getQueryData('scopes') as ScopeDto[];

queryCache.setQueryData<DayDto | undefined>(['day', dayId], currentDay => {
Expand Down Expand Up @@ -68,6 +68,13 @@ export const useUpdateTask = () => {
queryCache.setQueryData('activeTask', emptyActiveTask);
}

if (payload.title) {
queryCache.setQueryData('activeTask', {
...previousActiveTask,
title: payload.title,
});
}

return produce(currentDay, draftState => {
const scope =
// eslint-disable-next-line no-nested-ternary
Expand Down

0 comments on commit c6bea7f

Please # to comment.