Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Add types

Terry Sutton715e564928ff
diff --git a/package-lock.json b/package-lock.json
index e6b772542f6..4ecc99d82cc 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -32753,7 +32753,7 @@
"@supabase/react-data-grid": "^7.1.0-beta.7",
"@supabase/shared-types": "^0.1.25",
"@supabase/supabase-js": "^2.0.0-rc.2",
- "@supabase/ui": "0.37.0-alpha.80",
+ "@supabase/ui": "0.37.0-alpha.81",
"ajv": "^8.6.3",
"analytics-node": "^3.5.0",
"awesome-debounce-promise": "^2.1.0",
@@ -32784,7 +32784,7 @@
"react-beautiful-dnd": "^13.1.0",
"react-contexify": "^5.0.0",
"react-csv": "^2.0.3",
- "react-datepicker": "^4.6.0",
+ "react-datepicker": "^4.8.0",
"react-dnd": "^14.0.3",
"react-dnd-html5-backend": "^14.0.1",
"react-dom": "^17.0.2",
@@ -33095,9 +33095,9 @@
}
},
"studio/node_modules/@supabase/ui": {
- "version": "0.37.0-alpha.80",
- "resolved": "https://registry.npmjs.org/@supabase/ui/-/ui-0.37.0-alpha.80.tgz",
- "integrity": "sha512-oTBX43SipvCOmdG4UTt2yM//Meqfof4j7Fgmdi6rAn2EGpqo9xVqWxqlCLLvcbaK94Sl0i5R43zZEWz6RJoUIg==",
+ "version": "0.37.0-alpha.81",
+ "resolved": "https://registry.npmjs.org/@supabase/ui/-/ui-0.37.0-alpha.81.tgz",
+ "integrity": "sha512-CxqdikE6wGw6pGQ6b3vRA8qnvCK20VyeMyy8Z4hJ/Dg2qRfgQqbrv7qS+6A1S8pg657EzCCo0DIH75SijaU8eA==",
"dependencies": {
"@headlessui/react": "^1.0.0",
"@mertasan/tailwindcss-variables": "^2.0.1",
@@ -55118,7 +55118,7 @@
"@supabase/react-data-grid": "^7.1.0-beta.7",
"@supabase/shared-types": "^0.1.25",
"@supabase/supabase-js": "^2.0.0-rc.2",
- "@supabase/ui": "0.37.0-alpha.80",
+ "@supabase/ui": "0.37.0-alpha.81",
"@tailwindcss/typography": "^0.5.2",
"@testing-library/dom": "^8.11.1",
"@testing-library/react": "^12.1.2",
@@ -55179,7 +55179,7 @@
"react-beautiful-dnd": "^13.1.0",
"react-contexify": "^5.0.0",
"react-csv": "^2.0.3",
- "react-datepicker": "^4.6.0",
+ "react-datepicker": "^4.8.0",
"react-dnd": "^14.0.3",
"react-dnd-html5-backend": "^14.0.1",
"react-dom": "^17.0.2",
@@ -55348,9 +55348,9 @@
}
},
"@supabase/ui": {
- "version": "0.37.0-alpha.80",
- "resolved": "https://registry.npmjs.org/@supabase/ui/-/ui-0.37.0-alpha.80.tgz",
- "integrity": "sha512-oTBX43SipvCOmdG4UTt2yM//Meqfof4j7Fgmdi6rAn2EGpqo9xVqWxqlCLLvcbaK94Sl0i5R43zZEWz6RJoUIg==",
+ "version": "0.37.0-alpha.81",
+ "resolved": "https://registry.npmjs.org/@supabase/ui/-/ui-0.37.0-alpha.81.tgz",
+ "integrity": "sha512-CxqdikE6wGw6pGQ6b3vRA8qnvCK20VyeMyy8Z4hJ/Dg2qRfgQqbrv7qS+6A1S8pg657EzCCo0DIH75SijaU8eA==",
"requires": {
"@headlessui/react": "^1.0.0",
"@mertasan/tailwindcss-variables": "^2.0.1",
diff --git a/studio/components/interfaces/Organization/BillingSettings/TaxID/TaxID.tsx b/studio/components/interfaces/Organization/BillingSettings/TaxID/TaxID.tsx
index 7c2a070429f..35407e689b9 100644
--- a/studio/components/interfaces/Organization/BillingSettings/TaxID/TaxID.tsx
+++ b/studio/components/interfaces/Organization/BillingSettings/TaxID/TaxID.tsx
@@ -8,16 +8,9 @@ import { uuidv4 } from 'lib/helpers'
import { post, delete_ } from 'lib/common/fetch'
import { API_URL } from 'lib/constants'
import Panel from 'components/ui/Panel'
-import { TAX_IDS } from './TaxID.constants'
+import { StripeTaxId, TAX_IDS } from './TaxID.constants'
import NoPermission from 'components/ui/NoPermission'
-
-interface StripeTaxId {
- id: string
- type: string
- value: string
- name: string
- country?: string
-}
+import { sanitizeTaxID } from './TaxID.utils'
interface Props {
loading: boolean
@@ -86,7 +79,7 @@ const TaxID: FC<Props> = ({ loading, taxIds, onTaxIdsUpdated }) => {
}
const onRemoveTaxId = (id: string) => {
- const updatedTaxIds = taxIdValues.filter((taxId: any) => {
+ const updatedTaxIds = taxIdValues.filter((taxId: StripeTaxId) => {
return taxId.id !== id
})
setTaxIdValues(updatedTaxIds)
@@ -101,13 +94,13 @@ const TaxID: FC<Props> = ({ loading, taxIds, onTaxIdsUpdated }) => {
setIsSaving(true)
try {
const deletedIds = await Promise.all(
- taxIds.map(async (taxId: any) => {
+ taxIds.map(async (taxId: StripeTaxId) => {
return await delete_(`${API_URL}/organizations/${slug}/tax-ids`, { id: taxId.id })
})
)
const newIds = await Promise.all(
- taxIdValues.map(async (taxId: any) => {
+ taxIdValues.map(async (taxId: StripeTaxId) => {
const sanitizedID = sanitizeTaxID(taxId)
const result = await post(`${API_URL}/organizations/${slug}/tax-ids`, {
type: sanitizedID.type,
@@ -116,7 +109,6 @@ const TaxID: FC<Props> = ({ loading, taxIds, onTaxIdsUpdated }) => {
return { id: sanitizedID.id, result }
})
)
-
const taxIdsWithErrors = newIds.filter((taxId: any) => {
if (taxId.result.error) return taxId
})
@@ -141,26 +133,6 @@ const TaxID: FC<Props> = ({ loading, taxIds, onTaxIdsUpdated }) => {
}
}
- /**
- * Sanitize EU VAT ids so they get prepended with the country code
- *
- * Ex: Belgium's VAT ID should be BE0123456789 not 0123456789
- * Only EU VAT ids are affected for now
- */
- const sanitizeTaxID = (taxId: any) => {
- let newID = taxId
-
- // The first 2 letters of the country name (ex: "BE" for Belgium)
- const countryCodePrepend = taxId.name.slice(0, 2)
-
- // if the value doesn't start with the country code, prepend them
- if (taxId.type === 'eu_vat' && !taxId.value.startsWith(countryCodePrepend)) {
- newID.value = `${countryCodePrepend}${taxId.value}`
- }
-
- return newID
- }
-
return (
<div className="space-y-2">
<div>