Skip to content

Commit 9c0ca54

Browse files
committed
ts
1 parent 1d2f118 commit 9c0ca54

File tree

6 files changed

+33
-18
lines changed

6 files changed

+33
-18
lines changed

apps/web/actions/folders/moveVideoToFolder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export async function moveVideoToFolder({
1818
}: {
1919
videoId: Video.VideoId;
2020
folderId: Folder.FolderId | null;
21-
spaceId: Space.SpaceIdOrOrganisationId;
21+
spaceId: Space.SpaceIdOrOrganisationId | null;
2222
}) {
2323
const user = await getCurrentUser();
2424
if (!user || !user.activeOrganizationId)

apps/web/app/(org)/dashboard/caps/components/Folder.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use client";
2-
import type { Folder } from "@cap/web-domain";
2+
import type { Folder, Space } from "@cap/web-domain";
33
import { faTrash } from "@fortawesome/free-solid-svg-icons";
44
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
55
import { Fit, Layout, useRive } from "@rive-app/react-canvas";
@@ -21,8 +21,8 @@ export type FolderDataType = {
2121
id: Folder.FolderId;
2222
color: "normal" | "blue" | "red" | "yellow";
2323
videoCount: number;
24-
spaceId?: string | null;
25-
parentId?: string | null;
24+
spaceId: Space.SpaceIdOrOrganisationId;
25+
parentId: Folder.FolderId | null;
2626
};
2727

2828
const FolderCard = ({

apps/web/app/(org)/dashboard/folder/[id]/components/BreadcrumbItem.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import type { Folder } from "@cap/web-domain";
3+
import type { Folder, Space } from "@cap/web-domain";
44
import clsx from "clsx";
55
import Link from "next/link";
66
import { useRouter } from "next/navigation";
@@ -15,6 +15,7 @@ interface BreadcrumbItemProps {
1515
id: Folder.FolderId;
1616
name: string;
1717
color: "normal" | "blue" | "red" | "yellow";
18+
spaceId: Space.SpaceIdOrOrganisationId;
1819
isLast: boolean;
1920
}
2021

@@ -23,6 +24,7 @@ export function BreadcrumbItem({
2324
name,
2425
color,
2526
isLast,
27+
spaceId,
2628
}: BreadcrumbItemProps) {
2729
const [isDragOver, setIsDragOver] = useState(false);
2830
const [isMoving, setIsMoving] = useState(false);
@@ -59,7 +61,11 @@ export function BreadcrumbItem({
5961
if (!capData.id) return;
6062

6163
setIsMoving(true);
62-
await moveVideoToFolder({ videoId: capData.id, folderId: id });
64+
await moveVideoToFolder({
65+
videoId: capData.id,
66+
folderId: id,
67+
spaceId,
68+
});
6369
router.refresh();
6470
toast.success(`"${capData.name}" moved to "${name}" folder`);
6571
} catch (error) {

apps/web/app/(org)/dashboard/folder/[id]/components/ClientMyCapsLink.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import { Avatar } from "@cap/ui";
4-
import type { Video } from "@cap/web-domain";
4+
import type { Space, Video } from "@cap/web-domain";
55
import clsx from "clsx";
66
import Image from "next/image";
77
import Link from "next/link";
@@ -12,7 +12,11 @@ import { moveVideoToFolder } from "@/actions/folders/moveVideoToFolder";
1212
import { useDashboardContext } from "../../../Contexts";
1313
import { registerDropTarget } from "./ClientCapCard";
1414

15-
export function ClientMyCapsLink() {
15+
export function ClientMyCapsLink({
16+
spaceId,
17+
}: {
18+
spaceId: Space.SpaceIdOrOrganisationId;
19+
}) {
1620
const [isDragOver, setIsDragOver] = useState(false);
1721
const [isMovingVideo, setIsMovingVideo] = useState(false);
1822
const linkRef = useRef<HTMLAnchorElement>(null);
@@ -90,11 +94,11 @@ export function ClientMyCapsLink() {
9094
await moveVideoToFolder({
9195
videoId: capData.id,
9296
folderId: null,
93-
spaceId: activeSpace?.id,
97+
spaceId,
9498
});
9599
router.refresh();
96-
if (activeSpace) {
97-
toast.success(`Moved "${capData.name}" to "${activeSpace.name}"`);
100+
if (spaceId) {
101+
toast.success(`Moved "${capData.name}" to "${spaceId}"`);
98102
} else {
99103
toast.success(`Moved "${capData.name}" to My Caps`);
100104
}
@@ -109,9 +113,7 @@ export function ClientMyCapsLink() {
109113
return (
110114
<Link
111115
ref={linkRef}
112-
href={
113-
activeSpace ? `/dashboard/spaces/${activeSpace.id}` : "/dashboard/caps"
114-
}
116+
href={spaceId ? `/dashboard/spaces/${spaceId}` : "/dashboard/caps"}
115117
className={clsx(
116118
"text-xl whitespace-nowrap flex items-center gap-1.5 transition-colors duration-200 hover:text-gray-12",
117119
isDragOver ? "text-blue-10" : "text-gray-9",

apps/web/app/(org)/dashboard/folder/[id]/page.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getCurrentUser } from "@cap/database/auth/session";
22
import { serverEnv } from "@cap/env";
3-
import { CurrentUser, type Folder } from "@cap/web-domain";
3+
import { CurrentUser, type Folder, type Space } from "@cap/web-domain";
44
import { Effect } from "effect";
55
import { notFound } from "next/navigation";
66
import {
@@ -18,7 +18,11 @@ import {
1818
} from "./components";
1919
import FolderVideosSection from "./components/FolderVideosSection";
2020

21-
const FolderPage = async ({ params }: { params: { id: Folder.FolderId } }) => {
21+
const FolderPage = async ({
22+
params,
23+
}: {
24+
params: { id: Folder.FolderId; spaceId: Space.SpaceIdOrOrganisationId };
25+
}) => {
2226
const user = await getCurrentUser();
2327
if (!user || !user.activeOrganizationId) return notFound();
2428

@@ -39,13 +43,14 @@ const FolderPage = async ({ params }: { params: { id: Folder.FolderId } }) => {
3943
</div>
4044
<div className="flex justify-between items-center mb-6 w-full">
4145
<div className="flex overflow-x-auto items-center font-medium">
42-
<ClientMyCapsLink />
46+
<ClientMyCapsLink spaceId={params.spaceId} />
4347

4448
{breadcrumb.map((folder, index) => (
4549
<div key={folder.id} className="flex items-center">
4650
<p className="mx-2 text-gray-10">/</p>
4751
<BreadcrumbItem
4852
id={folder.id}
53+
spaceId={params.spaceId}
4954
name={folder.name}
5055
color={folder.color}
5156
isLast={index === breadcrumb.length - 1}
@@ -67,6 +72,7 @@ const FolderPage = async ({ params }: { params: { id: Folder.FolderId } }) => {
6772
key={folder.id}
6873
name={folder.name}
6974
color={folder.color}
75+
spaceId={params.spaceId}
7076
id={folder.id}
7177
parentId={folder.parentId}
7278
videoCount={folder.videoCount}

apps/web/app/(org)/dashboard/spaces/[spaceId]/folder/[folderId]/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ const FolderPage = async (props: {
6464
</div>
6565
<div className="flex justify-between items-center mb-6 w-full">
6666
<div className="flex overflow-x-auto items-center font-medium">
67-
<ClientMyCapsLink />
67+
<ClientMyCapsLink spaceId={params.spaceId} />
6868
{breadcrumb.map((folder, index) => (
6969
<div key={folder.id} className="flex items-center">
7070
<p className="mx-2 text-gray-10">/</p>
7171
<BreadcrumbItem
72+
spaceId={params.spaceId}
7273
id={folder.id}
7374
name={folder.name}
7475
color={folder.color}

0 commit comments

Comments
 (0)