feat: add public share options for workflow

This commit is contained in:
BennyKok
2024-01-14 23:35:25 +08:00
parent dafc8b168b
commit 18cfbce171
22 changed files with 1327 additions and 158 deletions
+2 -24
View File
@@ -1,7 +1,8 @@
import { setInitialUserData } from "../../../lib/setInitialUserData";
import { WorkflowList } from "@/components/WorkflowList";
import { db } from "@/db/db";
import { usersTable, workflowTable, workflowVersionTable } from "@/db/schema";
import { auth, clerkClient } from "@clerk/nextjs";
import { auth } from "@clerk/nextjs";
import { and, desc, eq, isNull } from "drizzle-orm";
export default function Home() {
@@ -55,26 +56,3 @@ async function WorkflowServer() {
/>
);
}
async function setInitialUserData(userId: string) {
const user = await clerkClient.users.getUser(userId);
// incase we dont have username such as google login, fallback to first name + last name
const usernameFallback =
user.username ?? (user.firstName ?? "") + (user.lastName ?? "");
// For the display name, if it for some reason is empty, fallback to username
let nameFallback = (user.firstName ?? "") + (user.lastName ?? "");
if (nameFallback === "") {
nameFallback = usernameFallback;
}
const result = await db.insert(usersTable).values({
id: userId,
// this is used for path, make sure this is unique
username: usernameFallback,
// this is for display name, maybe different from username
name: nameFallback,
});
}