Skip to content

Commit

Permalink
feature: confeti al pujar apunts jajajaj
Browse files Browse the repository at this point in the history
  • Loading branch information
PauMatas committed Mar 16, 2024
1 parent f963efd commit 480862c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"papaparse": "^5.4.1",
"postcss": "8.4.23",
"react": "^18.2.0",
"react-canvas-confetti": "^2.0.7",
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
"react-hook-form": "^7.50.1",
Expand Down
6 changes: 5 additions & 1 deletion src/components/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useMutation } from "@tanstack/react-query"
import axios from "axios"
import { useRouter } from "next/navigation"
import { toast } from "@/hooks/use-toast"
import { useEffect } from "react"
import { useEffect, useState } from "react"
import { Button } from "@/components/ui/Button"
import {
Form,
Expand All @@ -23,6 +23,7 @@ import { Checkbox } from "@/components/ui/checkbox"
import { ApuntsPostCreationRequest } from "@/lib/validators/post"
import { uploadFiles } from "@/lib/uploadthing"
import { GCED_START } from "@/config"
import Fireworks from "react-canvas-confetti/dist/presets/fireworks"

const formSchema = z.object({
pdf: z.any(),
Expand Down Expand Up @@ -56,6 +57,7 @@ export function ProfileForm({
semester?: number
}) {
const router = useRouter()
const [isVisible, setIsVisible] = useState(false)

const { mutate: createApuntsPost } = useMutation({
mutationFn: async ({
Expand Down Expand Up @@ -99,6 +101,7 @@ export function ProfileForm({
}
},
onSuccess: (subjectAcronym) => {
setIsVisible(true)
router.push(`/${subjectAcronym}`)
router.refresh()

Expand Down Expand Up @@ -446,6 +449,7 @@ export function ProfileForm({
<Button type="submit" isLoading={form.formState.isSubmitting}>
Submit
</Button>
{isVisible && <Fireworks autorun={{ speed: 0.5 }} />}
</form>
</Form>
)
Expand Down
18 changes: 18 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,11 @@
"@tanstack/query-core" "4.29.11"
use-sync-external-store "^1.2.0"

"@types/canvas-confetti@^1.6.4":
version "1.6.4"
resolved "https://registry.yarnpkg.com/@types/canvas-confetti/-/canvas-confetti-1.6.4.tgz#620fd8d78b335d6a4046c0f73236d6988b37552a"
integrity sha512-fNyZ/Fdw/Y92X0vv7B+BD6ysHL4xVU5dJcgzgxLdGbn8O3PezZNIJpml44lKM0nsGur+o/6+NZbZeNTt00U1uA==

"@types/editorjs__header@^2.6.0":
version "2.6.0"
resolved "https://registry.npmjs.org/@types/editorjs__header/-/editorjs__header-2.6.0.tgz"
Expand Down Expand Up @@ -1656,6 +1661,11 @@ caniuse-lite@^1.0.30001464, caniuse-lite@^1.0.30001489, caniuse-lite@^1.0.300015
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001585.tgz"
integrity sha512-yr2BWR1yLXQ8fMpdS/4ZZXpseBgE7o4g41x3a6AJOqZuOi+iE/WdJYAuZ6Y95i4Ohd2Y+9MzIWRR+uGABH4s3Q==

canvas-confetti@^1.9.2:
version "1.9.2"
resolved "https://registry.yarnpkg.com/canvas-confetti/-/canvas-confetti-1.9.2.tgz#c9f74098c7fdf66dd9d1aab5d381061cf74e48f0"
integrity sha512-6Xi7aHHzKwxZsem4mCKoqP6YwUG3HamaHHAlz1hTNQPCqXhARFpSXnkC9TWlahHY5CG6hSL5XexNjxK8irVErg==

canvas@^2.11.2:
version "2.11.2"
resolved "https://registry.npmjs.org/canvas/-/canvas-2.11.2.tgz"
Expand Down Expand Up @@ -4183,6 +4193,14 @@ rc@^1.2.7:
minimist "^1.2.0"
strip-json-comments "~2.0.1"

react-canvas-confetti@^2.0.7:
version "2.0.7"
resolved "https://registry.yarnpkg.com/react-canvas-confetti/-/react-canvas-confetti-2.0.7.tgz#0499e7815b50f6a7731fd01729e07c30faa300f3"
integrity sha512-DIj44O35TPAwJkUSIZqWdVsgAMHtVf8h7YNmnr3jF3bn5mG+d7Rh9gEcRmdJfYgRzh6K+MAGujwUoIqQyLnMJw==
dependencies:
"@types/canvas-confetti" "^1.6.4"
canvas-confetti "^1.9.2"

react-dom@^18.2.0:
version "18.2.0"
resolved "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz"
Expand Down

0 comments on commit 480862c

Please sign in to comment.