1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-09 15:35:22 +02:00

Merge pull request #73 from sy425191/bug/country_limitation

Country limitation while signup is removed
This commit is contained in:
Josh Pigford 2024-01-15 08:52:03 -06:00 committed by GitHub
commit 886fd8ca80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 99 deletions

View file

@ -1,62 +0,0 @@
import Link from 'next/link'
import { useUserApi } from '@maybe-finance/client/shared'
import { Button } from '@maybe-finance/design-system'
import toast from 'react-hot-toast'
import { signOut } from 'next-auth/react'
export function CountryWaitlist({ country }: { country?: string }) {
const { useDelete } = useUserApi()
const deleteUser = useDelete({
onSuccess() {
toast.success(`Account deleted`)
setTimeout(() => signOut(), 500)
},
onError() {
toast.error(`Error deleting account`)
},
})
return (
<div className="w-full max-w-md mx-auto">
<h3 className="text-center">
Unfortunately we're only accepting users from the US for now
</h3>
<div className="mt-4 space-y-4 text-base text-gray-50">
<p>We hate doing this, but for now were only accepting users from the US. Why?</p>
<p>
Well besides not being able to automatically connect to your institution, our
financial advisors wouldnt be able to give you relevant localized advice and
would likely breach some regulations.
</p>
<p>
That being said, we do plan on expanding Maybe to other countries soon. So well
let you know via email once we launch Maybe in {country || 'your country'}.
</p>
</div>
<Link href="https://maybe.co" passHref>
<Button as="a" fullWidth className="mt-8">
Got it
</Button>
</Link>
<Button
variant="warn"
fullWidth
className="mt-4"
disabled={deleteUser.isLoading}
onClick={() => {
if (
// eslint-disable-next-line
confirm(
'Are you sure you want to delete your account? This cannot be undone.'
)
) {
deleteUser.mutate({})
}
}}
>
{deleteUser.isLoading ? 'Deleting account...' : 'Delete my account'}
</Button>
</div>
)
}

View file

@ -29,7 +29,6 @@ import type { StepProps } from './StepProps'
import { Switch } from '@headlessui/react'
import { BrowserUtil, useUserApi } from '@maybe-finance/client/shared'
import type { Household, MaybeGoal } from '@prisma/client'
import { CountryWaitlist } from './CountryWaitlist'
import { DateUtil, Geo } from '@maybe-finance/shared'
type FormValues = {
@ -73,7 +72,7 @@ export function Profile({ title, onNext }: StepProps) {
dob: data.dob,
household: data.household,
country: data.country,
state: data.country === 'US' ? data.state : null, // should be NULL if country is not US
state: null, // should always be null for now
maybeGoals: data.maybeGoals,
maybeGoalsDescription: data.maybeGoalsDescription,
})
@ -108,7 +107,6 @@ function ProfileForm({ title, onSubmit, defaultValues }: ProfileViewProps) {
})
const country = watch('country')
const [showCountryWaitlist, setShowCountryWaitlist] = useState(false)
useEffect(() => {
trigger()
@ -116,9 +114,7 @@ function ProfileForm({ title, onSubmit, defaultValues }: ProfileViewProps) {
const { errors } = useFormState({ control })
return showCountryWaitlist ? (
<CountryWaitlist country={Geo.countries.find((c) => c.code === country)?.name} />
) : (
return (
<div className="w-full max-w-md mx-auto">
<h3 className="text-center">{title}</h3>
<p className="mt-4 text-base text-gray-50">
@ -211,18 +207,12 @@ function ProfileForm({ title, onSubmit, defaultValues }: ProfileViewProps) {
<Question
open={currentQuestion === 'residence'}
valid={!errors.country && (!errors.state || country !== 'US')}
valid={!errors.country}
icon={RiMapPin2Line}
label="Where are you based?"
onClick={() => setCurrentQuestion('residence')}
back={() => setCurrentQuestion('household')}
next={() => {
if (country === 'US') {
setCurrentQuestion('goals')
} else {
setShowCountryWaitlist(true)
}
}}
next={() => setCurrentQuestion('goals')}
>
<div className="space-y-2">
<Controller
@ -246,29 +236,6 @@ function ProfileForm({ title, onSubmit, defaultValues }: ProfileViewProps) {
</Listbox>
)}
/>
{country === 'US' && (
<Controller
name="state"
control={control}
rules={{ required: true }}
render={({ field }) => (
<Listbox {...field}>
<Listbox.Button label="State">
{Geo.states.find((s) => s.code === field.value)?.name ||
'Select'}
</Listbox.Button>
<Listbox.Options className="max-h-[300px] custom-gray-scroll">
{Geo.states.map((state) => (
<Listbox.Option key={state.code} value={state.code}>
{state.name}
</Listbox.Option>
))}
</Listbox.Options>
</Listbox>
)}
/>
)}
</div>
<Tooltip
placement="bottom-start"