Skip to content

Commit 6a120ed

Browse files
authored
Merge pull request #3644 from Northeastern-Electric-Racing/#3628-Confetti-When-Moving-Task-To-Done
#3628 Added confetti when moving tasks to done
2 parents 9570f46 + 6d86c68 commit 6a120ed

3 files changed

Lines changed: 38 additions & 3 deletions

File tree

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
},
6868
"dependencies": {
6969
"@types/multer": "^1.4.12",
70+
"canvas-confetti": "^1.9.3",
7071
"mitt": "^3.0.1",
7172
"react-hook-form-persist": "^3.0.0",
7273
"recharts": "^2.15.3",
@@ -77,6 +78,7 @@
7778
"@babel/plugin-transform-object-assign": "^7.18.6",
7879
"@babel/preset-react": "^7.18.6",
7980
"@babel/preset-typescript": "^7.18.6",
81+
"@types/canvas-confetti": "^1.9.0",
8082
"@types/jest": "^29.5.14",
8183
"@types/node": "20.0.0",
8284
"@typescript-eslint/eslint-plugin": "8.20.0",

src/frontend/src/pages/ProjectDetailPage/ProjectViewContainer/TaskList/v2/TaskListContent.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { getTasksByStatus, statuses, TasksByStatus } from '.';
66
import { useSetTaskStatus } from '../../../../../hooks/tasks.hooks';
77
import { useToast } from '../../../../../hooks/toasts.hooks';
88
import { TaskColumn } from './TaskColumn';
9+
import confetti from 'canvas-confetti';
910

1011
interface TaskListProps {
1112
project: Project;
@@ -79,8 +80,24 @@ export const TaskListContent = ({ project }: TaskListProps) => {
7980
);
8081

8182
//trigger the mutation to persist the changes
82-
setTaskStatus({ taskId: sourcePost.taskId, status: destinationStatus }).catch((error) => {
83-
toast.error(error.message);
83+
try {
84+
await setTaskStatus({ taskId: sourcePost.taskId, status: destinationStatus });
85+
const confettiPositions = [0, 0.15, 0.3, 0.45, 0.6, 0.75, 0.9];
86+
if (destinationStatus === 'DONE' && sourceStatus !== 'DONE') {
87+
confettiPositions.forEach((xPos) => {
88+
confetti({
89+
origin: { y: -0.5, x: xPos },
90+
angle: 270,
91+
gravity: 1.5,
92+
startVelocity: 35,
93+
spread: 70,
94+
particleCount: 25
95+
});
96+
});
97+
}
98+
} catch (error) {
99+
if (error instanceof Error) toast.error(error.message);
100+
//revert optimistic updates
84101
setTasksByStatus(
85102
updateTaskStatusLocal(
86103
sourcePost,
@@ -89,7 +106,7 @@ export const TaskListContent = ({ project }: TaskListProps) => {
89106
tasksByStatus
90107
)
91108
);
92-
});
109+
}
93110
};
94111

95112
return (

yarn.lock

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4733,6 +4733,13 @@ __metadata:
47334733
languageName: node
47344734
linkType: hard
47354735

4736+
"@types/canvas-confetti@npm:^1.9.0":
4737+
version: 1.9.0
4738+
resolution: "@types/canvas-confetti@npm:1.9.0"
4739+
checksum: 56227a362cead21ab76b0870e07e0cc2d26c800f5bc0fc109e4a3eca1a4d4dd317e1292163246d389827b7f30ce9e6eca3915681f3c80ed1e46491018f48a266
4740+
languageName: node
4741+
linkType: hard
4742+
47364743
"@types/chai@npm:^5.2.2":
47374744
version: 5.2.2
47384745
resolution: "@types/chai@npm:5.2.2"
@@ -7354,6 +7361,13 @@ __metadata:
73547361
languageName: node
73557362
linkType: hard
73567363

7364+
"canvas-confetti@npm:^1.9.3":
7365+
version: 1.9.3
7366+
resolution: "canvas-confetti@npm:1.9.3"
7367+
checksum: db044a9c9ca0e58eafd115f7dfc2f9ecc377be34d8a5dd75901dae0dafd4fb0b75fbbf8edd48bbefad2468653c5838348f0e768b79727a924259a9ada343ea30
7368+
languageName: node
7369+
linkType: hard
7370+
73577371
"canvas@npm:^3.0.0-rc2":
73587372
version: 3.1.2
73597373
resolution: "canvas@npm:3.1.2"
@@ -10738,11 +10752,13 @@ __metadata:
1073810752
"@babel/plugin-transform-object-assign": ^7.18.6
1073910753
"@babel/preset-react": ^7.18.6
1074010754
"@babel/preset-typescript": ^7.18.6
10755+
"@types/canvas-confetti": ^1.9.0
1074110756
"@types/jest": ^29.5.14
1074210757
"@types/multer": ^1.4.12
1074310758
"@types/node": 20.0.0
1074410759
"@typescript-eslint/eslint-plugin": 8.20.0
1074510760
"@typescript-eslint/parser": 8.20.0
10761+
canvas-confetti: ^1.9.3
1074610762
concurrently: ^9.1.0
1074710763
eslint: ^7.0.0
1074810764
eslint-config-prettier: ^10.0.1

0 commit comments

Comments
 (0)