Skip to content

Commit

Permalink
Change billing urls
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubno committed Sep 9, 2024
1 parent 11f2ad9 commit fa9093b
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 211 deletions.
2 changes: 1 addition & 1 deletion apps/web/src/app/(dashboard)/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function MainContent({ selectedItem, user, team, accessToken, currentApiKey, tea
case 'keys':
return <KeysContent currentTeam={team} />
case 'usage':
return <UsageContent currentApiKey={currentApiKey} />
return <UsageContent currentApiKey={currentApiKey} team={team} />
case 'billing':
return <BillingContent currentApiKey={currentApiKey} team={team} />
case 'team':
Expand Down
72 changes: 0 additions & 72 deletions apps/web/src/app/(docs)/docs/pricing/Promo.tsx

This file was deleted.

123 changes: 0 additions & 123 deletions apps/web/src/app/(docs)/docs/pricing/promo/route.ts

This file was deleted.

7 changes: 3 additions & 4 deletions apps/web/src/components/Dashboard/Billing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ function formatCurrency(value: number) {
return value.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
}

const invoiceUrl = `${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/invoices`
const creditsUrl = `${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/usage`

interface Invoice {
cost: number
Expand All @@ -27,7 +25,8 @@ export const BillingContent = ({ currentApiKey, team }: { currentApiKey: string
useEffect(() => {
const getInvoices = async function getInvoices() {
setInvoices([])
const res = await fetch(invoiceUrl, {
const res = await fetch(`${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/${team.id}/invoices`
, {
headers: {
'X-Team-API-Key': currentApiKey!,
},
Expand All @@ -42,7 +41,7 @@ export const BillingContent = ({ currentApiKey, team }: { currentApiKey: string
setInvoices(invoices)

setCredits(null)
const creditsRes = await fetch(creditsUrl, {
const creditsRes = await fetch( `${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/${team.id}/usage`, {
headers: {
'X-Team-API-Key': currentApiKey!,
},
Expand Down
4 changes: 1 addition & 3 deletions apps/web/src/components/Dashboard/Keys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import { useToast } from '../ui/use-toast'
import { createPagesBrowserClient } from '@supabase/auth-helpers-nextjs'
import { Team } from '@/utils/useUser'

const createApiKeyUrl = `${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/api-keys`

export const KeysContent = ({ currentTeam }: { currentTeam: Team }) => {
const supabase = createPagesBrowserClient()

Expand Down Expand Up @@ -77,7 +75,7 @@ export const KeysContent = ({ currentTeam }: { currentTeam: Team }) => {
})
}

const res = await fetch(createApiKeyUrl, {
const res = await fetch(`${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/${currentTeam.id}/api-keys`, {
method: 'POST',
headers: {
'X-Team-API-Key': currentTeam.apiKeys[0],
Expand Down
6 changes: 2 additions & 4 deletions apps/web/src/components/Dashboard/Team.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ interface TeamMember {
email: string
}

const teamUsersUrl = `${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/users`
const teamUpdateNameUrl = `${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams`

export const TeamContent = ({ team, user, teams, currentApiKey, setTeams, setCurrentTeam }: { team: Team, user: User, teams: Team[], currentApiKey: string | null, setTeams: (teams: Team[]) => void, setCurrentTeam: (team: Team) => void }) => {
const supabase = createPagesBrowserClient()
Expand All @@ -31,7 +29,7 @@ export const TeamContent = ({ team, user, teams, currentApiKey, setTeams, setCur

useEffect(() => {
const getTeamMembers = async () => {
const res = await fetch(teamUsersUrl, {
const res = await fetch(`${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/${team.id}/users`, {
headers: {
'X-Team-API-Key': currentApiKey!,
},
Expand Down Expand Up @@ -88,7 +86,7 @@ export const TeamContent = ({ team, user, teams, currentApiKey, setTeams, setCur
}

const changeTeamName = async () => {
const res = await fetch(teamUpdateNameUrl, {
const res = await fetch(`${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/${team.id}`, {
headers: {
'X-Team-API-Key': currentApiKey!,
'Content-Type': 'application/json',
Expand Down
7 changes: 3 additions & 4 deletions apps/web/src/components/Dashboard/Usage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { Card, CardContent } from '@/components/ui/card'
import LineChart from '@/components/Dashboard/Chart'
import Spinner from '@/components/Spinner'
import { toast } from '@/components/ui/use-toast'

const usageUrl = `${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/usage`
import { Team } from '@/utils/useUser'


type Usage = {
Expand All @@ -23,7 +22,7 @@ type Series = {
data: PlotData[]
}

export const UsageContent = ({ currentApiKey }: { currentApiKey: string | null }) => {
export const UsageContent = ({ currentApiKey, team }: { currentApiKey: string | null, team: Team }) => {
const [vcpuData, setVcpuData] = useState<Series[]>([])
const [vcpuHoursThisMonth, setVcpuHoursThisMonth] = useState<number | undefined>()
const [ramData, setRamData] = useState<Series[]>([])
Expand All @@ -37,7 +36,7 @@ export const UsageContent = ({ currentApiKey }: { currentApiKey: string | null }
setRamData([])
setCostUsage([])

const response = await fetch(usageUrl, {
const response = await fetch( `${process.env.NEXT_PUBLIC_BILLING_API_URL}/teams/${team.id}/usage`, {
headers: {
'X-Team-API-Key': apiKey
}
Expand Down

0 comments on commit fa9093b

Please sign in to comment.