Skip to content

Commit 5afeca5

Browse files
committed
Fix uploadthing issue and redirects
1 parent d4a708d commit 5afeca5

9 files changed

Lines changed: 34 additions & 9 deletions

File tree

src/app/[clubname]/page.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ import Gallery from "@/components/ClubPageComponents/Gallery";
77
import OurSchedule from "@/components/ClubPageComponents/OurSchedule";
88
import { clubCodes } from "@/lib/utils";
99
import { getClubDetails } from "../actions/ClubData";
10+
import { redirect } from "next/navigation";
1011

1112
export async function generateMetadata({ params, searchParams }, parent) {
1213
const club = (await params).clubname;
13-
const clubName = (await getClubDetails(club)).name;
14+
const clubDetails = await getClubDetails(club)
15+
if(!clubDetails) redirect("/");
16+
const clubName = clubDetails.name;
1417
// console.log(await parent);
1518
return {
1619
title: `${clubName} | ${(await parent).title.absolute}`,

src/components/ClubDash/edit-form.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
import Link from "next/link";
33
import { updateClubData } from "@/app/actions/ClubActions";
44
import { useFormState } from "react-dom";
5-
import { UploadButton } from "@uploadthing/react";
5+
import { generateUploadButton } from "@uploadthing/react";
6+
const UploadButton = generateUploadButton({
7+
url: "/bost/api/uploadthing"
8+
})
69
import { useEffect, useState } from "react";
710

811
export default function Form({ clubData }) {
@@ -96,6 +99,7 @@ export default function Form({ clubData }) {
9699
<UploadButton
97100
endpoint="imageUploader"
98101
className="ut-uploading:pointer-events-none"
102+
callbackUrl
99103
appearance={{
100104
container: "w-1/4",
101105
button:"bg-primary" }}

src/components/Gallery/create-form.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
import Link from "next/link";
33
import { addImage } from "@/app/actions/GalleryActions"; // Assume this is your server action
44
import { useFormState } from "react-dom";
5-
import { UploadButton } from "@uploadthing/react";
5+
import { generateUploadButton } from "@uploadthing/react";
6+
const UploadButton = generateUploadButton({
7+
url: "/bost/api/uploadthing"
8+
})
69
import { useState } from "react";
710

811
export default function AddImageForm() {

src/components/Gallery/edit-form.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
import Link from "next/link";
33
import { updateGalleryImageURL } from "@/app/actions/GalleryActions";
44
import { useFormState } from "react-dom";
5-
import { UploadButton } from "@uploadthing/react";
5+
import { generateUploadButton } from "@uploadthing/react";
6+
const UploadButton = generateUploadButton({
7+
url: "/bost/api/uploadthing"
8+
})
69
import { useState } from "react";
710

811
export default function EditImageForm({ url,name }) {

src/components/Project/create-form.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { Button } from "@/components/ui/button";
44
import Link from "next/link";
55
import { useFormState } from "react-dom";
66
import { createProject } from "@/app/actions/ProjectActions";
7-
import { UploadButton } from "@uploadthing/react";
7+
import { generateUploadButton } from "@uploadthing/react";
8+
const UploadButton = generateUploadButton({
9+
url: "/bost/api/uploadthing"
10+
})
811

912
const developmentStatus = [
1013
{ id: 1, name: "Not Started" },

src/components/Project/edit-form.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { Button } from "@/components/ui/button";
44
import Link from "next/link";
55
import DynamicField from "@/components/ui/dynamic-input-field";
66
import { useFormState } from "react-dom";
7-
import { UploadButton } from "@uploadthing/react";
7+
import { generateUploadButton } from "@uploadthing/react";
8+
const UploadButton = generateUploadButton({
9+
url: "/bost/api/uploadthing"
10+
})
811
import { updateProject } from "@/app/actions/ProjectActions";
912

1013
const developmentStatus = [

src/components/Team/create-form.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
import Link from "next/link";
33
import { createTeamMember } from "@/app/actions/TeamActions";
44
import { useFormState } from "react-dom";
5-
import { UploadButton } from "@uploadthing/react";
5+
import { generateUploadButton } from "@uploadthing/react";
6+
const UploadButton = generateUploadButton({
7+
url: "/bost/api/uploadthing"
8+
})
69
import { useState } from "react";
710
import { Button } from "../ui/button";
811

src/components/Team/edit-form.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
import Link from "next/link";
33
import { updateTeamMember } from "@/app/actions/TeamActions";
44
import { useFormState } from "react-dom";
5-
import { UploadButton } from "@uploadthing/react";
5+
import { generateUploadButton } from "@uploadthing/react";
6+
const UploadButton = generateUploadButton({
7+
url: "/bost/api/uploadthing"
8+
})
69
import { useState } from "react";
710

811
export default function Form({ memberDetails }) {

src/middleware.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export async function middleware(request) {
66
const session = await auth();
77
const isAuthenticated = session?.user;
88
if (nextUrl.pathname.startsWith("/dashboard") && !isAuthenticated) {
9-
return NextResponse.redirect(new URL("/", request.url));
9+
return NextResponse.redirect(new URL("/bost/", request.url));
1010
}
1111
}
1212

0 commit comments

Comments
 (0)