Skip to content

Commit e287051

Browse files
authored
ui: show org name + image on share page (#1152)
* show org name + image on share page * Update page.tsx * fix * minor fixes * Update ShareHeader.tsx
1 parent 889cafb commit e287051

File tree

6 files changed

+62
-23
lines changed

6 files changed

+62
-23
lines changed

apps/web/app/(org)/dashboard/_components/Navbar/Items.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,7 @@ const NavItem = ({
492492
{name}
493493
</p>
494494
{extraText && !sidebarCollapsed && (
495-
<p className="ml-auto text-xs font-medium text-gray-11">
496-
{extraText}
497-
</p>
495+
<p className="ml-auto text-xs text-gray-11">{extraText}</p>
498496
)}
499497
</Link>
500498
</Tooltip>

apps/web/app/(org)/dashboard/caps/Caps.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ export const Caps = ({
232232
data.error === 1 ? "" : "s"
233233
}`;
234234
}
235+
router.refresh();
235236
return `Successfully deleted ${data.success} cap${
236237
data.success === 1 ? "" : "s"
237238
}`;
@@ -266,7 +267,7 @@ export const Caps = ({
266267
[data, isUploading, uploadingCapId],
267268
);
268269

269-
if (count === 0) return <EmptyCapState />;
270+
if (count === 0 && folders.length === 0) return <EmptyCapState />;
270271

271272
return (
272273
<div className="flex relative flex-col w-full h-full">

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,11 @@ const FolderCard = ({
273273
<Link
274274
prefetch={false}
275275
href={
276-
spaceId
277-
? `/dashboard/spaces/${spaceId}/folder/${id}`
278-
: `/dashboard/folder/${id}`
276+
deleteFolder.isPending
277+
? "#"
278+
: spaceId
279+
? `/dashboard/spaces/${spaceId}/folder/${id}`
280+
: `/dashboard/folder/${id}`
279281
}
280282
>
281283
<div

apps/web/app/s/[videoId]/_components/ShareHeader.tsx

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
import type { userSelectProps } from "@cap/database/auth/session";
44
import type { videos } from "@cap/database/schema";
55
import { buildEnv, NODE_ENV } from "@cap/env";
6-
import { Button } from "@cap/ui";
6+
import { Avatar, Button } from "@cap/ui";
77
import { userIsPro } from "@cap/utils";
88
import { faChevronDown, faLock } from "@fortawesome/free-solid-svg-icons";
99
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
1010
import clsx from "clsx";
1111
import { Check, Copy, Globe2 } from "lucide-react";
1212
import moment from "moment";
13+
import Image from "next/image";
1314
import { useRouter } from "next/navigation";
1415
import { useEffect, useState } from "react";
1516
import { toast } from "sonner";
@@ -29,7 +30,10 @@ export const ShareHeader = ({
2930
sharedSpaces = [],
3031
spacesData = null,
3132
}: {
32-
data: typeof videos.$inferSelect;
33+
data: typeof videos.$inferSelect & {
34+
organizationIconUrl?: string | null;
35+
organizationName?: string | null;
36+
};
3337
user: typeof userSelectProps | null;
3438
customDomain?: string | null;
3539
domainVerified?: boolean;
@@ -70,9 +74,11 @@ export const ShareHeader = ({
7074

7175
const handleBlur = async () => {
7276
setIsEditing(false);
73-
77+
const next = title.trim();
78+
if (next === "" || next === data.name) return;
7479
try {
75-
await editTitle(data.id, title);
80+
await editTitle(data.id, next);
81+
setTitle(next);
7682
toast.success("Video title updated");
7783
refresh();
7884
} catch (error) {
@@ -81,6 +87,7 @@ export const ShareHeader = ({
8187
} else {
8288
toast.error("Failed to update title - please try again.");
8389
}
90+
setTitle(data.name);
8491
}
8592
};
8693

@@ -136,7 +143,7 @@ export const ShareHeader = ({
136143

137144
const renderSharedStatus = () => {
138145
const baseClassName =
139-
"text-sm text-gray-10 transition-colors duration-200 flex items-center";
146+
"text-sm text-gray-10 justify-center lg:justify-start transition-colors duration-200 flex items-center";
140147

141148
if (isOwner) {
142149
const hasSpaceSharing =
@@ -198,17 +205,37 @@ export const ShareHeader = ({
198205
/>
199206
<div className="mt-8">
200207
<div className="flex flex-col gap-6 lg:flex-row lg:items-center lg:justify-between lg:gap-0">
201-
<div className="items-center md:flex md:justify-between md:space-x-6">
202-
<div className="mb-3 md:mb-0">
203-
<div className="flex items-center space-x-3 lg:min-w-[400px]">
208+
<div className="justify-center items-center mb-3 w-full md:flex lg:justify-between md:space-x-6 md:mb-0">
209+
<div className="flex flex-col gap-5 md:gap-10 lg:flex-row">
210+
<div className="flex flex-col flex-1 justify-center items-center w-full lg:justify-evenly">
211+
{data.organizationIconUrl ? (
212+
<Image
213+
className="rounded-full size-9"
214+
src={data.organizationIconUrl}
215+
alt="Organization icon"
216+
width={36}
217+
height={36}
218+
/>
219+
) : (
220+
<Avatar
221+
className="rounded-full size-9"
222+
name={data.organizationName ?? "Organization"}
223+
letterClass="text-sm"
224+
/>
225+
)}
226+
<p className="text-sm font-medium text-gray-12">
227+
{data.organizationName}
228+
</p>
229+
</div>
230+
<div className="flex flex-col justify-center text-center lg:text-left lg:justify-start">
204231
{isEditing ? (
205232
<input
206233
value={title}
207234
onChange={(e) => setTitle(e.target.value)}
208235
onBlur={handleBlur}
209236
onKeyDown={handleKeyDown}
210237
autoFocus
211-
className="w-full text-xl font-semibold sm:text-2xl"
238+
className="w-full text-xl sm:text-2xl"
212239
/>
213240
) : (
214241
<h1
@@ -222,16 +249,16 @@ export const ShareHeader = ({
222249
{title}
223250
</h1>
224251
)}
252+
{user && renderSharedStatus()}
253+
<p className="mt-1 text-sm text-gray-10">
254+
{moment(data.createdAt).fromNow()}
255+
</p>
225256
</div>
226-
{user && renderSharedStatus()}
227-
<p className="mt-1 text-sm text-gray-10">
228-
{moment(data.createdAt).fromNow()}
229-
</p>
230257
</div>
231258
</div>
232259
{user !== null && (
233-
<div className="flex space-x-2">
234-
<div>
260+
<div className="flex justify-center space-x-2 w-full lg:justify-end">
261+
<div className="w-fit">
235262
<div className="flex gap-2 items-center">
236263
{data.password && (
237264
<FontAwesomeIcon

apps/web/app/s/[videoId]/page.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ type VideoWithOrganization = typeof videos.$inferSelect & {
105105
hasPassword?: boolean;
106106
ownerIsPro?: boolean;
107107
orgSettings?: OrganizationSettings | null;
108+
organizationIconUrl?: string | null;
109+
organizationName?: string | null;
108110
};
109111

110112
const ALLOWED_REFERRERS = [
@@ -287,6 +289,8 @@ export default async function ShareVideoPage(props: PageProps<"/s/[videoId]">) {
287289
duration: videos.duration,
288290
fps: videos.fps,
289291
hasPassword: sql`${videos.password} IS NOT NULL`.mapWith(Boolean),
292+
organizationIconUrl: organizations.iconUrl,
293+
organizationName: organizations.name,
290294
sharedOrganization: {
291295
organizationId: sharedVideos.organizationId,
292296
},
@@ -359,6 +363,8 @@ async function AuthorizedContent({
359363
ownerIsPro?: boolean;
360364
orgSettings?: OrganizationSettings | null;
361365
videoSettings?: OrganizationSettings | null;
366+
organizationIconUrl?: string | null;
367+
organizationName?: string | null;
362368
};
363369
searchParams: { [key: string]: string | string[] | undefined };
364370
}) {
@@ -477,6 +483,8 @@ async function AuthorizedContent({
477483
sharedOrganization: {
478484
organizationId: sharedVideos.organizationId,
479485
},
486+
organizationIconUrl: organizations.iconUrl,
487+
organizationName: organizations.name,
480488
orgSettings: organizations.settings,
481489
videoSettings: videos.settings,
482490
})
@@ -678,6 +686,8 @@ async function AuthorizedContent({
678686
folderId: null,
679687
orgSettings: video.orgSettings || null,
680688
settings: video.videoSettings || null,
689+
organizationIconUrl: video.organizationIconUrl ?? undefined,
690+
organizationName: video.organizationName ?? undefined,
681691
};
682692

683693
return (

apps/web/components/forms/NewOrganization.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface NewOrganizationProps {
2525

2626
export const NewOrganization: React.FC<NewOrganizationProps> = (props) => {
2727
const formSchema = z.object({
28-
name: z.string().min(1),
28+
name: z.string().min(1).max(25),
2929
});
3030

3131
const form = useForm<z.infer<typeof formSchema>>({
@@ -77,6 +77,7 @@ export const NewOrganization: React.FC<NewOrganizationProps> = (props) => {
7777
render={({ field }) => (
7878
<FormControl>
7979
<Input
80+
maxLength={25}
8081
placeholder="Your organization name"
8182
{...field}
8283
onChange={(e) => {

0 commit comments

Comments
 (0)