Skip to content

Commit d30bec0

Browse files
committed
Improve program onboarding
1 parent d9a1e66 commit d30bec0

4 files changed

Lines changed: 61 additions & 4 deletions

File tree

apps/web/.env.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ UNSPLASH_ACCESS_KEY=
9595
STORAGE_ACCESS_KEY_ID=
9696
STORAGE_SECRET_ACCESS_KEY=
9797
STORAGE_ENDPOINT=
98-
STORAGE_BASE_URL=
9998

10099
# Used for internal monitoring & paging
101100
# You can remove this by removing `DUB_SLACK_HOOK_CRON` and `DUB_SLACK_HOOK_LINKS` from the codebase

apps/web/lib/actions/partners/create-program.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,15 @@ export const createProgram = async ({
4444

4545
await getDomainOrThrow({ workspace, domain });
4646

47-
const programFolder = await prisma.folder.create({
48-
data: {
47+
const programFolder = await prisma.folder.upsert({
48+
where: {
49+
name_projectId: {
50+
name: "Partner Links",
51+
projectId: workspace.id,
52+
},
53+
},
54+
update: {},
55+
create: {
4956
id: createId({ prefix: "fold_" }),
5057
name: "Partner Links",
5158
projectId: workspace.id,
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { prisma } from "@dub/prisma";
2+
import { R2_URL } from "@dub/utils";
3+
import "dotenv-flow/config";
4+
import { storage } from "../../lib/storage";
5+
6+
async function main() {
7+
const program = await prisma.program.update({
8+
where: {
9+
id: "prog_1JSF1XA6SP6KFW5F15FY3HCMG",
10+
},
11+
data: {
12+
defaultRewardId: null,
13+
},
14+
});
15+
16+
if (program.defaultFolderId) {
17+
const deletedFolder = await prisma.folder.delete({
18+
where: {
19+
id: program.defaultFolderId,
20+
},
21+
});
22+
23+
console.log("Deleted folder", deletedFolder);
24+
}
25+
26+
const deletedRewards = await prisma.reward.deleteMany({
27+
where: {
28+
programId: program.id,
29+
},
30+
});
31+
32+
console.log("Deleted rewards", deletedRewards);
33+
34+
if (program.logo) {
35+
const deletedLogo = await storage.delete(
36+
program.logo.replace(`${R2_URL}/`, ""),
37+
);
38+
39+
console.log("Deleted logo", deletedLogo);
40+
}
41+
42+
const deletedProgram = await prisma.program.delete({
43+
where: {
44+
id: program.id,
45+
},
46+
});
47+
48+
console.log("Deleted program", deletedProgram);
49+
}
50+
51+
main();

packages/utils/src/constants/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ export const ACME_PROGRAM_ID = "prog_CYCu7IMAapjkRpTnr8F1azjN";
7474
export const LEGAL_WORKSPACE_ID = "clrflia0j0000vs7sqfhz9c7q";
7575
export const LEGAL_USER_ID = "clqei1lgc0000vsnzi01pbf47";
7676

77-
export const R2_URL = process.env.STORAGE_BASE_URL as string;
77+
export const R2_URL = "https://dubassets.com";

0 commit comments

Comments
 (0)