diff --git a/studio/pages/project/[ref]/auth/settings-new-all.tsx b/studio/pages/project/[ref]/auth/settings-new-all.tsx deleted file mode 100644 index 1420dff35e1..00000000000 --- a/studio/pages/project/[ref]/auth/settings-new-all.tsx +++ /dev/null @@ -1,1109 +0,0 @@ -import { - Button, - Collapsible, - Form, - IconArrowRight, - IconCheck, - IconChevronUp, - IconGlobe, - IconTrash, - IconX, - Input, - InputNumber, - Modal, - Tabs, - Toggle, -} from '@supabase/ui' -import { AuthLayout } from 'components/layouts' -import AutoSchemaForm from 'components/interfaces/Auth/AutoSchemaForm' -import { withAuth } from 'hooks' -import { observer } from 'mobx-react-lite' -import React, { useReducer, useState } from 'react' -import AuthFormSchema from './AuthFormSchema.json' - -// import GoogleIcon './../../../static/icons/google-icon.svg' - -const DocsButton = () => { - return ( - - ) -} - -const CardForm = () => { - // panel - const Panel = ({ - children, - header, - footer, - }: { - children: React.ReactNode - header?: React.ReactNode - footer?: React.ReactNode - }) => ( -
- {header && ( -
- {header} -
- )} -
{children}
- {footer} -
- ) - - const Section = ({ - children, - header, - }: { - children: React.ReactNode - header?: React.ReactNode - }) => ( -
- {header} - {children} -
- ) - - return ( - <> - -
{ - setTimeout(() => { - alert(JSON.stringify(values, null, 2)) - setSubmitting(false) - }, 400) - }} - validate={(values: Values) => { - const errors: any = {} - if (!values.jwt_expiry) { - errors.jwt_expiry = 'This is required' - } - if (values.jwt_expiry > 604800) { - errors.jwt_expiry = - 'The maxiumum allowed is 604,800 seconds. Use a smaller number of seconds.' - } - return errors - }} - > - {({ isSubmitting, handleReset }: any) => ( - -
-
- - -
- - } - > -
User Signups} - > - -
-
-
User Sessions} - > - -
-
- )} -
- - ) -} - -// type to do later.. -let initialState: any = {} - -AuthFormSchema.map((provider) => { - initialState[`${provider.name.toLowerCase()}-active`] = provider.name == 'Email' ? true : false - initialState[`${provider.name.toLowerCase()}-app-id`] = '' - initialState[`${provider.name.toLowerCase()}-id-key`] = '' -}) - -console.log('form initialState', initialState) - -function providersReducer(state: any, action: any) { - switch (action.type) { - case 'update': - return Object.assign(state, action.values) - // case 'decrement': - // return { count: state.count - 1 } - default: - throw new Error() - } -} - -const AuthForm = () => { - const [providersFormState, dispatchProvidersForm] = useReducer(providersReducer, initialState) - - console.log('providersFormState from useState', providersFormState) - - // panel - const Panel = ({ - children, - header, - footer, - }: { - children: React.ReactNode - header?: React.ReactNode - footer?: React.ReactNode - }) => ( -
- {header && ( -
- {header} -
- )} -
{children}
- {footer} -
- ) - - const Section = ({ - children, - header, - }: { - children: React.ReactNode - header?: React.ReactNode - }) => ( -
- {header} - {children} -
- ) - - const CollapsibleContainer = ({ - children, - header, - }: { - children: React.ReactNode - header?: React.ReactNode - }) => { - return ( -
- {children} -
- ) - } - - type formObj = { - type: string - name: string - label: string - description: string - } - - interface Provider { - name: string - icon: string - form: formObj[] - } - - const ProviderForm = ({ provider }: { provider: Provider }) => { - const [open, setOpen] = useState(false) - const [active, setActive] = useState( - providersFormState[`${provider.name.toLowerCase()}-active`] - ) - - console.log('panel active state', active) - - return ( - // - - - - -
{ - const errors: any = {} - - console.log('validation values', values) - - const input_active = `${provider.name.toLowerCase()}-active` - const input_app_id = `${provider.name.toLowerCase()}-app-id` - const input_id_key = `${provider.name.toLowerCase()}-id-key` - - if (values[input_app_id] && values[input_app_id].length < 10) - errors[input_app_id] = 'App ID must be at least 10 characters long' - if (values[input_app_id] && values[input_id_key].length < 10) - errors[input_id_key] = 'Secret must be at least 10 characters long' - - if (values[input_active]) { - if (!values[input_app_id]) - errors[input_app_id] = - 'You need to input an application ID if you want to enable this provider.' - if (!values[input_id_key]) - errors[input_id_key] = - 'You need to input an application secret if you want to enable this provider.' - } - - return errors - }} - onSubmit={(values: any, { setSubmitting }: any) => { - setTimeout(() => { - // alert(JSON.stringify(values, null, 2)) - dispatchProvidersForm({ type: 'update', values: values }) - setActive(values[`${provider.name.toLowerCase()}-active`]) - setSubmitting(false) - setOpen(false) - }, 400) - }} - > - {({ isSubmitting, handleReset }: any) => ( - -
-
- -
- {provider.form.map((x) => { - return ( - - ) - })} -
-
- - -
-
-
-
- )} -
-
- //
- ) - } - - return ( -
-
- {AuthFormSchema.map((provider: Provider) => { - return - })} -
-
- ) -} - -// type to do later.. -let domainInitialState: any = ['https://summersmuir.com', 'http://localhost:3000'] - -// AuthFormSchema.map((provider) => { -// domainInitialState[`${provider.name.toLowerCase()}-active`] = -// provider.name == 'Email' ? true : false -// domainInitialState[`${provider.name.toLowerCase()}-app-id`] = '' -// domainInitialState[`${provider.name.toLowerCase()}-id-key`] = '' -// }) - -console.log('form domainInitialState', domainInitialState) - -// function domainsReducer(state, action) { -// switch (action.type) { -// case 'update': -// let _state = [] -// _state.push(...state) -// _state.push(action.values.domain) -// console.log('new state', _state) -// return _state -// // case 'remove': -// // _state.push(...state) -// // _state = _state.filter((e: any) => e !== action.values) -// // console.log('new state', _state) -// // return _state -// // case 'decrement': -// // return { count: state.count - 1 } -// default: -// throw new Error() -// } -// } - -function domainsReducer(state, action) { - let _state = [] - switch (action.type) { - case 'update': - _state.push(...state) - _state.push(action.values.domain) - console.log('new state', _state) - return _state - case 'remove': - _state.push(...state) - _state = _state.filter((e: any) => e !== action.values) - console.log('new state', _state) - return _state - // case 'decrement': - // return { count: state.count - 1 } - default: - throw new Error() - } -} - -const DomainsForm = () => { - const [domainsFormState, dispatchDomainsForm] = useReducer(domainsReducer, domainInitialState) - - const [deleteOpen, setDeleteOpen] = useState(false) - const [deleteLoading, setDeleteLoading] = useState(false) - const [selectedDomain, setSelected] = useState('') - - console.log('domainsFormState from useState', domainsFormState) - - type formObj = { - type: string - name: string - label: string - description: string - } - - interface Provider { - name: string - icon: string - form: formObj[] - } - - const DomainsForm = () => { - // const [active, setActive] = useState( - // domainsFormState[`${provider.name.toLowerCase()}-active`] - // ) - const [open, setOpen] = useState(false) - - // console.log('panel active state', active) - - return ( - <> -
-
-

Authorised domains

-

- Turn payment methods on and off in one click – no engineering time required. -

-

- Use our guide to check which payment methods are compatible with your integration. -

-
- - setOpen(!open)} - header={ -
-
-

Add a new domain

-
-
- } - contentStyle={{ padding: 0 }} - hideFooter - > -
{ - console.log('submitting domain') - setTimeout(() => { - setSubmitting(false) - dispatchDomainsForm({ type: 'update', values: values }) - setOpen(false) - }, 400) - }} - validate={(values) => { - const errors: any = {} - if (!values.domain) { - errors.domain = 'A domain is required' - } else if ( - !/^((https?|ftp|smtp):\/\/)?(www.)?[a-z0-9]+\.[a-z]+(\/[a-zA-Z0-9#]+\/?)*$/i.test( - values.domain - ) - ) { - errors.domain = 'Not a valid URL. Please use http:// or https://' - } - return errors - }} - > - {({ isSubmitting, errors, touched }: any) => { - // console.log('errors in form', errors) - // console.log('touched in form', touched) - return ( -
-
-

- This will add a domain to a list of allowed domains that can interact with - your Authenticaton services for this project. -

-
-
-
- -
-
-
- -
-
- ) - }} -
-
-
- - ) - } - - console.log('RENDER DOMAINS') - - return ( -
- -
- {domainsFormState.map((domain) => { - return ( - <> -
-
- - - - {domain} -
- -
- - ) - })} -
- setDeleteOpen(!open)} - header={ -
-
-

Remove domain

-
-
- } - contentStyle={{ padding: 0 }} - hideFooter - > -
-
-

- Are you sure you want to remove{' '} - {selectedDomain}? -

-

- This domain will no longer work with your Authentication configuration. -

-
-
-
- - -
-
-
-
- ) -} - -const SmtpForm = () => { - const [active, setActive] = useState(true) - - // panel - const Panel = ({ - children, - header, - footer, - }: { - children: React.ReactNode - header?: React.ReactNode - footer?: React.ReactNode - }) => ( -
- {header && ( -
- {header} -
- )} -
{children}
- {footer} -
- ) - - const Section = ({ - children, - header, - }: { - children: React.ReactNode - header?: React.ReactNode - }) => ( -
- {header &&
{header}
} - {children} -
- ) - - return ( - <> -
{ - setTimeout(() => { - alert(JSON.stringify(values, null, 2)) - setSubmitting(false) - }, 400) - }} - validate={(values: Values) => { - const errors: any = {} - if (!values.jwt_expiry) { - errors.jwt_expiry = 'This is required' - } - if (values.jwt_expiry > 604800) { - errors.jwt_expiry = - 'The maxiumum allowed is 604,800 seconds. Use a smaller number of seconds.' - } - return errors - }} - > - {({ isSubmitting, handleReset, values }: any) => ( - -
-
- - -
- - } - > - {/*
- Enable SMTP - - } - > */} - setActive(!active)} - // checked={active} - name="enable_smtp" - className="col-span-8 mx-8" - label="Enable Custom SMTP" - layout="flex" - descriptionText="If this is disabled, new users will not be able to sign up to your application." - /> - {/*
*/} -
-
- -

- These settings can be found in your SMTP provider config -

- - } - > -
- - - - - -
-
- {values.enable_smtp && ( -
- -
- )} -
- )} -
- - ) -} - -const TemplatesForm = () => { - const [active, setActive] = useState(true) - - // panel - const Panel = ({ - children, - header, - footer, - }: { - children: React.ReactNode - header?: React.ReactNode - footer?: React.ReactNode - }) => ( -
- {header && ( -
- {header} -
- )} -
{children}
- {footer} -
- ) - - const Section = ({ - children, - header, - }: { - children: React.ReactNode - header?: React.ReactNode - }) => ( -
- {header &&
{header}
} - {children} -
- ) - - return ( - <> -
{ - setTimeout(() => { - alert(JSON.stringify(values, null, 2)) - setSubmitting(false) - }, 400) - }} - validate={(values: Values) => { - const errors: any = {} - if (!values.jwt_expiry) { - errors.jwt_expiry = 'This is required' - } - if (values.jwt_expiry > 604800) { - errors.jwt_expiry = - 'The maxiumum allowed is 604,800 seconds. Use a smaller number of seconds.' - } - return errors - }} - > - {({ isSubmitting, handleReset, values }: any) => ( - <> -
- - - - - - - -
- -
-
- - -
- - } - > - {/*
- Enable SMTP - - } - > */} - {/* setActive(!active)} - // checked={active} - name="enable_smtp" - className="col-span-8 mx-8" - label="Enable Custom SMTP" - layout="flex" - descriptionText="If this is disabled, new users will not be able to sign up to your application." - /> */} - {/*
*/} - {/*
*/} -
-

Confirm Signup

-

- When a user signs up using an email address and password, you can send them a - confirmation email to verify their registered email address. Learn more -

- - } - > -
- - - - - Confirm your signup - -

Follow this link to confirm your user:

-

Confirm your mail

- `} - /> -
-
- {values.enable_smtp && ( -
- -
- )} -
- - )} -
- - ) -} - -const Auth = () => { - return ( - -
- -
-
- ) -} - -export function WholeForm() { - return ( -
-
-
-

Sign-in method

-
-
-
-

General settings

-

- Turn payment methods on and off in one click – no engineering time required. -

-

- Use our guide to check which payment methods are compatible with your integration. -

- -
-
-

Providers

-

- Turn payment methods on and off in one click – no engineering time required. -

-

- Use our guide to check which payment methods are compatible with your integration. -

- -
- - -
-
- ) -} - -export default withAuth(observer(Auth))