The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Merge branch 'feat/invite-external-users' of https://github.com/supabase/supabase into feat/invite-external-users
Jonathan Summers-Muircb28cd7fa457
diff --cc studio/pages/join/index.tsxindex 315f250381d,f39a5f0f066..c16000f9778--- a/studio/pages/join/index.tsx+++ b/studio/pages/join/index.tsx@@@ -8,7 -8,7 +8,7 @@@ import { API_URL } from 'lib/constantsimport { get, post, delete_ } from 'lib/common/fetch'import { useEffect } from 'react'--interface TokenInfo {++interface TokenInfoI {organization_name: string | undefinedtoken_does_not_exist: booleanemail_match: boolean@@@ -17,12 -17,12 +17,14 @@@invite_id: number}++type TokenInfo = TokenInfoI | undefined++const User = () => {const router = useRouter()const { slug, token } = router.queryconst { ui } = useStore()const [isSubmitting, setIsSubmitting] = useState(false)-- const [tokenValidationInfo, setTokenValidationInfo] = useState<TokenInfo>()++ const [tokenValidationInfo, setTokenValidationInfo] = useState<TokenInfo>(undefined)const [tokenInfoLoaded, setTokenInfoLoaded] = useState(false)const {token_does_not_exist,@@@ -33,30 -33,26 +35,21 @@@invite_id,} = tokenValidationInfo || {}- console.log(slug, token)- console.log('tokenValidationInfo', tokenValidationInfo)- console.log('tokenInfoLoaded', tokenInfoLoaded)-useEffect(() => {-- let cancel = false--async function fetchTokenInfo() {-- const response = await get(`${API_URL}/organizations/${slug}/members/join?token=${token}`, {})-- if (!cancel) {++ try {++ const response = await get(`${API_URL}/organizations/${slug}/members/join?token=${token}`)setTokenValidationInfo(response)setTokenInfoLoaded(true)++ } catch (error) {++ console.error(error)}}-- if (router.query.token) {-- console.log('i have a tokens')++ if (router.query.token && !tokenInfoLoaded) {fetchTokenInfo()}---- return () => {-- cancel = true-- }-- }, [])++ }, [router.query])async function handleJoinOrganization() {setIsSubmitting(true)@@@ -93,38 -89,37 +86,29 @@@}return (- <div className="bg-scale-100 flex h-full min-h-screen w-full flex-col place-items-center items-center justify-center gap-8 px-5">- {/* <Link- <div className="bg-secondary flex h-full min-h-screen w-full flex-col place-items-center items-center justify-center px-3">- <Link-- passHref-- href={`/?next=${encodeURIComponent(- `/join/?token=${router.query.token}&slug=${router.query.slug}`- `/join?token=${router.query.token}&slug=${router.query.slug}`-- )}`}- >- <Button as="a">Sign in / Sign up</Button>- </Link> */}- <Link href="/">- <a className="flex items-center justify-center gap-4">- <img- src="/img/supabase-logo.svg"- alt="Supabase"- className="block h-[24px] cursor-pointer rounded"- />- {/* <h3 className="text-scale-1200">Supabase</h3> */}- </a>- </Link>-++ <div className="bg-scale-200 flex h-full min-h-screen w-full flex-col place-items-center items-center justify-center gap-8 px-5">+ <div+ className="- bg-scale-200 border-scale-300 mx-auto max-w-md- rounded-md border text-center shadow"++ bg-scale-300 border-scale-400 mx-auto max-w-md++ overflow-hidden rounded-md border text-center shadow">- <Button as="a">Sign in / Sign up</Button>- </Link>-- <div className="mx-auto mt-16 max-w-md space-y-6 rounded-md border-2 p-12 ">- <div className="space-y-4">+ <div className="space-y-4 px-6 py-6">+ <Link href="/">- <a className="flex items-center gap-4">++ <a className="flex items-center justify-center gap-4">+ <img+ src="/img/supabase-logo.svg"+ alt="Supabase"- className="block h-[30px] cursor-pointer rounded"++ className="block h-[24px] cursor-pointer rounded"+ />- <Typography.Title level={3} className="mb-0">- Supabase- </Typography.Title>++ {/* <h3 className="text-scale-1200">Supabase</h3> */}+ </a>+ </Link>-- <h2 className="text-xl">+ <p className="text-scale-900 text-sm">Join {organization_name && email_match ? organization_name : 'a new organization'}- </h2>+ </p>{!token_does_not_exist ? (- <p className="text-md">+ <p className="text-scale-1200 text-xl">You have been invited to join{' '}{organization_name && email_match? `${organization_name}'s organization`@@@ -136,48 -131,33 +120,75 @@@)}</div>- <div className="border-scale-300 border-t bg-amber-100">- <div className="flex flex-col gap-4 px-6 py-4">- {authorized_user && !expired_token && email_match && tokenInfoLoaded && (- <div className="flex items-center gap-2">- <Button onClick={handleJoinOrganization} loading={isSubmitting} size="small">- Join this organization- </Button>-- <Button onClick={handleDeclineJoinOrganization} size="small" type="text">- Decline- </Button>++ <div className="border-scale-400 border-t bg-amber-100">++ <div className="flex flex-col gap-4 px-6 py-6 ">+ {authorized_user && !expired_token && email_match && tokenInfoLoaded && (+ <div className="flex items-center gap-2">+ <Button+ onClick={handleJoinOrganization}+ htmlType="submit"+ loading={isSubmitting}+ size="small"+ type="primary"+ >+ Join this organization+ </Button>++ <Button+ onClick={handleDeclineJoinOrganization}+ htmlType="submit"+ size="small"+ type="warning"+ >+ Decline+ </Button>+ </div>+ )}++ {tokenInfoLoaded && (+ <div className="text-amber-1100 flex gap-4 text-base">- {token_does_not_exist ||- !email_match ||- (expired_token && <IconAlertCircle size={24} strokeWidth={2} />)}++ {(tokenInfoLoaded && token_does_not_exist) ||++ (tokenInfoLoaded && !email_match) ||++ (tokenInfoLoaded && expired_token && (++ <IconAlertCircle size={24} strokeWidth={2} />++ ))}+- {token_does_not_exist++ {tokenInfoLoaded && token_does_not_exist+ ? 'The invite token is invalid. Try copying and pasting the link from the invite email, or ask the organization owner to invite you again.'- : !email_match++ : tokenInfoLoaded && !email_match+ ? 'The email address does not match. Are you signed in with right GitHub account?'- : expired_token++ : tokenInfoLoaded && expired_token+ ? 'The invite token has expired. Please request a new one from the organization owner.'+ : ''}+ </div>+ )}++ {authorized_user && !expired_token && email_match && tokenInfoLoaded && (++ <div className="flex flex-row items-center gap-3">++ <Button onClick={handleDeclineJoinOrganization} size="small" type="text">++ Decline++ </Button>++++ <Button onClick={handleJoinOrganization} loading={isSubmitting} size="small">++ Join this organization++ </Button>++ </div>++ )}++ {!authorized_user && (++ <div>++ <Link++ passHref++ href={`/?next=${encodeURIComponent(++ `/join?token=${router.query.token}&slug=${router.query.slug}`++ )}`}++ >++ <Button size="medium" as="a" type="default">++ Sign in++ </Button>++ </Link>++ </div>++ )}</div>- )}-- {tokenInfoLoaded && (- <div className="mt-4 flex gap-4 border-t pt-4 text-sm">- {token_does_not_exist ||- !email_match ||- (expired_token && <IconAlertCircle size={24} strokeWidth={2} />)}-- {token_does_not_exist- ? 'The invite token is invalid. Try copying and pasting the link from the invite email, or ask the organization owner to invite you again.'- : !email_match- ? 'The email address does not match. Are you signed in with right GitHub account?'- : expired_token- ? 'The invite token has expired. Please request a new one from the organization owner.'- : ''}- </div>- )}+ </div></div></div>)