Skip to content

Commit

Permalink
public profile tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
xvvvyz committed Oct 30, 2024
1 parent 360476c commit 464c69f
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 84 deletions.
11 changes: 5 additions & 6 deletions app/(pages)/share/[subjectId]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ const Layout = async ({ children, params }: LayoutProps) => {
) : (
<>
<span className="text-sm leading-tight text-fg-4">
<span className="text-fg-2">llog</span>&mdash;achieve lasting
behavior
<br />
changes with your clients.
<span className="text-fg-2">llog</span>&mdash;the app for data
collection <br />
and real-time progress tracking.
</span>
<Button href="/" size="sm">
Request a demo
<Button href="/sign-up" size="sm">
Sign up
</Button>
</>
)}
Expand Down
7 changes: 6 additions & 1 deletion app/_components/event-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,12 @@ const EventForm = ({
control={form.control}
name={`inputs.${i}`}
render={({ field }) => (
<EventSelect field={field} input={input} />
<EventSelect
field={field}
input={input}
isArchived={isArchived}
isPublic={isPublic}
/>
)}
/>
)}
Expand Down
11 changes: 9 additions & 2 deletions app/_components/event-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,24 @@ interface EventSelectProps {
Pick<Database['public']['Tables']['input_options']['Row'], 'id' | 'label'>
>;
};
isArchived?: boolean;
isPublic?: boolean;
}

const EventSelect = ({ field, input }: EventSelectProps) => {
const EventSelect = ({
field,
input,
isArchived,
isPublic,
}: EventSelectProps) => {
const inputSettings = input.settings as InputSettingsJson;
const router = useRouter();

return (
<InputRoot>
<Label.Root>{input.label}</Label.Root>
<Select
isCreatable={inputSettings?.isCreatable}
isCreatable={!isArchived && !isPublic && inputSettings?.isCreatable}
isMulti={input.type === 'multi_select'}
onChange={field.onChange}
onCreateOption={async (label: string) => {
Expand Down
101 changes: 27 additions & 74 deletions app/_components/insight-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,88 +1,41 @@
'use client';

import * as Drawer from '@/_components/drawer';
import DrawerDeleteButton from '@/_components/drawer-delete-button';
import Tip from '@/_components/tip';
import deleteInsight from '@/_mutations/delete-insight';
import CheckIcon from '@heroicons/react/24/outline/CheckIcon';
import ClipboardDocumentIcon from '@heroicons/react/24/outline/ClipboardDocumentIcon';
import EllipsisVerticalIcon from '@heroicons/react/24/outline/EllipsisVerticalIcon';
import PencilIcon from '@heroicons/react/24/outline/PencilIcon';
import { useCopyToClipboard, useToggle } from '@uidotdev/usehooks';
import { useRef } from 'react';

interface InsightMenuProps {
insightId: string;
subjectId: string;
}

const InsightMenu = ({ insightId, subjectId }: InsightMenuProps) => {
const [, copyToClipboard] = useCopyToClipboard();
const [hasCopiedLink, toggleHasCopiedLink] = useToggle(false);
const linkTimeoutRef = useRef<NodeJS.Timeout>();

return (
<Drawer.Root>
<Drawer.Trigger>
<div className="group flex items-center justify-center px-1.5 text-fg-3 transition-colors hover:text-fg-2">
<div className="rounded-full p-2 transition-colors group-hover:bg-alpha-1">
<EllipsisVerticalIcon className="w-5" />
</div>
const InsightMenu = ({ insightId, subjectId }: InsightMenuProps) => (
<Drawer.Root>
<Drawer.Trigger>
<div className="group flex items-center justify-center px-1.5 text-fg-3 transition-colors hover:text-fg-2">
<div className="rounded-full p-2 transition-colors group-hover:bg-alpha-1">
<EllipsisVerticalIcon className="w-5" />
</div>
</Drawer.Trigger>
<Drawer.Portal>
<Drawer.Overlay />
<Drawer.Content>
<Drawer.Title>Insight menu</Drawer.Title>
<Drawer.Description />
<Drawer.Button
href={`/subjects/${subjectId}/insights/${insightId}/edit`}
>
<PencilIcon className="w-5 text-fg-4" />
Edit
</Drawer.Button>
<div className="relative">
<Drawer.Button
className="w-full"
onClick={async () => {
clearTimeout(linkTimeoutRef.current);

void copyToClipboard(
`${location.origin}/subjects/${subjectId}/insights/${insightId}`,
);

linkTimeoutRef.current = setTimeout(
() => toggleHasCopiedLink(false),
2000,
);

toggleHasCopiedLink(true);
}}
>
{hasCopiedLink ? (
<>
<CheckIcon className="w-5 text-fg-4" />
Copied, share it!
</>
) : (
<>
<ClipboardDocumentIcon className="w-5 text-fg-4" />
Copy link
</>
)}
</Drawer.Button>
<Tip align="end" className="absolute right-3 top-2.5">
Clients and team members have permission to view this insight.
</Tip>
</div>
<DrawerDeleteButton
confirmText="Delete insight"
onConfirm={() => deleteInsight(insightId)}
/>
</Drawer.Content>
</Drawer.Portal>
</Drawer.Root>
);
};
</div>
</Drawer.Trigger>
<Drawer.Portal>
<Drawer.Overlay />
<Drawer.Content>
<Drawer.Title>Insight menu</Drawer.Title>
<Drawer.Description />
<Drawer.Button
href={`/subjects/${subjectId}/insights/${insightId}/edit`}
>
<PencilIcon className="w-5 text-fg-4" />
Edit
</Drawer.Button>
<DrawerDeleteButton
confirmText="Delete insight"
onConfirm={() => deleteInsight(insightId)}
/>
</Drawer.Content>
</Drawer.Portal>
</Drawer.Root>
);

export default InsightMenu;
2 changes: 1 addition & 1 deletion app/_components/spinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const Spinner = ({
aria-busy
aria-label={loadingText}
className={twMerge(
'h-[0.9rem] w-[0.9rem] animate-spin rounded-full border-[1.5px]',
'h-[0.9rem] w-[0.9rem] animate-spin rounded-full border-2',
color,
'border-l-transparent',
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
create or replace function public.get_public_subject(public_subject_id uuid)
returns json
language plpgsql
security definer
as $$
begin
return (
select json_build_object(
'data', s.data,
'id', s.id,
'image_uri', s.image_uri,
'name', s.name
)
from subjects s
where s.id = public_subject_id and s.public = true
);
end;
$$;

0 comments on commit 464c69f

Please sign in to comment.