Skip to content

Commit

Permalink
Fix open link url
Browse files Browse the repository at this point in the history
  • Loading branch information
elie222 committed Nov 5, 2024
1 parent 9063b51 commit 87ace89
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
4 changes: 2 additions & 2 deletions apps/web/app/(app)/smart-categories/Uncategorized.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function Uncategorized({
);

const session = useSession();
const userId = session.data?.user.id || "";
const userEmail = session.data?.user?.email || "";

return (
<LoadingContent loading={!senderAddresses && isLoading}>
Expand Down Expand Up @@ -158,7 +158,7 @@ export function Uncategorized({
<SendersTable
senders={senders}
categories={categories}
userId={userId}
userEmail={userEmail}
/>
{hasMore && (
<Button
Expand Down
38 changes: 23 additions & 15 deletions apps/web/components/GroupedTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ const COLUMNS = 4;
type EmailGroup = {
address: string;
category: Pick<Category, "id" | "name" | "description"> | null;
meta?: {
width?: string;
};
meta?: { width?: string };
};

export function GroupedTable({
Expand All @@ -60,7 +58,7 @@ export function GroupedTable({
categories: Pick<Category, "id" | "name" | "description">[];
}) {
const session = useSession();
const userId = session.data?.user.id || "";
const userEmail = session.data?.user?.email || "";

const groupedEmails = useMemo(() => {
const grouped = groupBy(
Expand Down Expand Up @@ -109,7 +107,7 @@ export function GroupedTable({
accessorKey: "address",
cell: ({ row }) => (
<Link
href={getGmailSearchUrl(row.original.address, userId)}
href={getGmailSearchUrl(row.original.address, userEmail)}
target="_blank"
className="hover:underline"
>
Expand Down Expand Up @@ -160,7 +158,7 @@ export function GroupedTable({
),
},
],
[categories, userId],
[categories, userEmail],
);

const table = useReactTable({
Expand Down Expand Up @@ -208,7 +206,11 @@ export function GroupedTable({
onEditCategory={onEditCategory}
/>
{isCategoryExpanded && (
<SenderRows table={table} senders={senders} userId={userId} />
<SenderRows
table={table}
senders={senders}
userEmail={userEmail}
/>
)}
</Fragment>
);
Expand All @@ -235,11 +237,11 @@ export function GroupedTable({
export function SendersTable({
senders,
categories,
userId,
userEmail,
}: {
senders: EmailGroup[];
categories: Pick<Category, "id" | "name">[];
userId: string;
userEmail: string;
}) {
const columns: ColumnDef<EmailGroup>[] = useMemo(
() => [
Expand Down Expand Up @@ -304,7 +306,7 @@ export function SendersTable({
return (
<Table>
<TableBody>
<SenderRows table={table} senders={senders} userId={userId} />
<SenderRows table={table} senders={senders} userEmail={userEmail} />
</TableBody>
</Table>
);
Expand Down Expand Up @@ -360,11 +362,11 @@ function GroupRow({
function SenderRows({
table,
senders,
userId,
userEmail,
}: {
table: ReturnType<typeof useReactTable<EmailGroup>>;
senders: EmailGroup[];
userId: string;
userEmail: string;
}) {
if (!senders.length) {
return (
Expand Down Expand Up @@ -397,14 +399,20 @@ function SenderRows({
))}
</TableRow>
{row.getIsExpanded() && (
<ExpandedRows sender={row.original.address} userId={userId} />
<ExpandedRows sender={row.original.address} userEmail={userEmail} />
)}
</Fragment>
);
});
}

function ExpandedRows({ sender, userId }: { sender: string; userId: string }) {
function ExpandedRows({
sender,
userEmail,
}: {
sender: string;
userEmail: string;
}) {
const { data, isLoading, error } = useThreads({
fromEmail: sender,
limit: 5,
Expand Down Expand Up @@ -444,7 +452,7 @@ function ExpandedRows({ sender, userId }: { sender: string; userId: string }) {
<TableCell className="py-3" />
<TableCell className="py-3">
<Link
href={getGmailUrl(thread.id, userId)}
href={getGmailUrl(thread.id, userEmail)}
target="_blank"
className="hover:underline"
>
Expand Down

1 comment on commit 87ace89

@vercel
Copy link

@vercel vercel bot commented on 87ace89 Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.