Skip to content

Commit

Permalink
fix: read notes
Browse files Browse the repository at this point in the history
- add tailwind css purge plugin
- subscriptions that are not available will not show up anymore
- made 10 year subs be clearer that they do not renew
- initial work added to count subs on scripters dashboards (can probably use dev tools to see them already if you know how)
  • Loading branch information
Torwent committed Jan 10, 2024
1 parent 00ee682 commit c8d2f35
Show file tree
Hide file tree
Showing 6 changed files with 271 additions and 140 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"tslib": "^2.6.2",
"typescript": "^5.3.3",
"vite": "^4.5.1",
"vite-plugin-tailwind-purgecss": "^0.2.0",
"vitest": "^0.25.8",
"zod": "^3.22.4"
},
Expand Down
46 changes: 46 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 52 additions & 5 deletions src/routes/dashboard/[slug]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,32 @@ export const load = async ({ parent, data, depends, url, params: { slug } }) =>
const scriptsForm = data.scriptsForm
const newScriptForm = data.newScriptForm

async function getSubscriptions(product: string) {
const {
data,
count,
error: err
} = await supabaseClient
.schema("profiles")
.from("subscription")
.select("id, price, cancel", { count: "estimated" })
.eq("product", product)

if (err) {
console.error(err)
throw error(
500,
`Server error, this is probably not an issue on your end! - SELECT product failed
Error code: ${err.code}
Error hint: ${err.hint}
Error details: ${err.details}
Error hint: ${err.message}`
)
}

return { data, count }
}

async function getPrices() {
const { data, error: err } = await supabaseClient
.schema("scripts")
Expand Down Expand Up @@ -66,17 +92,38 @@ export const load = async ({ parent, data, depends, url, params: { slug } }) =>
)
}

const result = data.map((product) => {
return {
const result: {
id: string
user_id: string
name: string
username: string
bundle: string | null
script: string | null
active: boolean
subs: {
id: string
price: string
cancel: boolean
}[]
subCount: number
}[] = []

for (let i = 0; i < data.length; i++) {
const product = data[i]
const subs = await getSubscriptions(product.id)
result.push({
id: product.id,
user_id: product.user_id,
name: product.name,
username: product.bundles?.username ?? product.scripts?.protected.username ?? "",
bundle: product.bundle,
script: product.script,
active: product.active
}
})
active: product.active,
subs: subs.data,
subCount: subs.count ?? 0
})
}

return result
}

Expand Down
Loading

0 comments on commit c8d2f35

Please sign in to comment.