2023-07-27 18:59:40 -04:00
|
|
|
import { ActionButton } from '../components/ActionButton'
|
2024-08-16 07:15:42 -04:00
|
|
|
import { isDesktop } from '../lib/isDesktop'
|
2023-08-08 09:06:14 +10:00
|
|
|
import { VITE_KC_SITE_BASE_URL, VITE_KC_API_BASE_URL } from '../env'
|
2023-08-28 20:31:49 -04:00
|
|
|
import { Themes, getSystemTheme } from '../lib/theme'
|
2024-08-09 02:47:25 -04:00
|
|
|
import { PATHS } from 'lib/paths'
|
2024-03-11 20:26:13 -04:00
|
|
|
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
2023-12-18 06:15:26 -05:00
|
|
|
import { APP_NAME } from 'lib/constants'
|
2023-07-27 18:59:40 -04:00
|
|
|
|
|
|
|
const SignIn = () => {
|
2023-08-29 10:48:55 -04:00
|
|
|
const {
|
|
|
|
auth: { send },
|
|
|
|
settings: {
|
|
|
|
state: {
|
2024-04-02 10:29:34 -04:00
|
|
|
context: {
|
|
|
|
app: { theme },
|
|
|
|
},
|
2023-08-29 10:48:55 -04:00
|
|
|
},
|
|
|
|
},
|
2024-03-11 20:26:13 -04:00
|
|
|
} = useSettingsAuthContext()
|
2023-08-29 10:48:55 -04:00
|
|
|
|
2024-04-02 10:29:34 -04:00
|
|
|
const getLogoTheme = () =>
|
|
|
|
theme.current === Themes.Light ||
|
|
|
|
(theme.current === Themes.System && getSystemTheme() === Themes.Light)
|
|
|
|
? '-dark'
|
|
|
|
: ''
|
|
|
|
|
2024-08-16 07:15:42 -04:00
|
|
|
const signInDesktop = async () => {
|
2023-07-27 18:59:40 -04:00
|
|
|
// We want to invoke our command to login via device auth.
|
|
|
|
try {
|
2024-08-16 07:15:42 -04:00
|
|
|
const token: string = await window.electron.login(VITE_KC_API_BASE_URL)
|
2023-08-28 20:31:49 -04:00
|
|
|
send({ type: 'Log in', token })
|
2023-07-27 18:59:40 -04:00
|
|
|
} catch (error) {
|
2024-04-02 10:29:34 -04:00
|
|
|
console.error('Error with login button', error)
|
2023-07-27 18:59:40 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2023-08-09 15:41:41 -04:00
|
|
|
<main className="body-bg h-full min-h-screen m-0 p-0 pt-24">
|
2023-07-27 18:59:40 -04:00
|
|
|
<div className="max-w-2xl mx-auto">
|
|
|
|
<div>
|
|
|
|
<img
|
2024-08-16 07:15:42 -04:00
|
|
|
src={`./zma-logomark${getLogoTheme()}.svg`}
|
2023-12-19 14:19:34 -05:00
|
|
|
alt="Zoo Modeling App"
|
2023-07-27 18:59:40 -04:00
|
|
|
className="w-48 inline-block"
|
|
|
|
/>
|
|
|
|
</div>
|
2023-08-09 15:41:41 -04:00
|
|
|
<h1 className="font-bold text-2xl mt-12 mb-6">
|
2023-12-18 06:15:26 -05:00
|
|
|
Sign in to get started with the {APP_NAME}
|
2023-07-27 18:59:40 -04:00
|
|
|
</h1>
|
|
|
|
<p className="py-4">
|
2023-12-18 06:15:26 -05:00
|
|
|
ZMA is an open-source CAD application for creating accurate 3D models
|
|
|
|
for use in manufacturing. It is built on top of KittyCAD, the design
|
|
|
|
API from Zoo. Zoo is the first software infrastructure company built
|
|
|
|
specifically for the needs of the manufacturing industry. With ZMA we
|
|
|
|
are showing how the KittyCAD API from Zoo can be used to build
|
|
|
|
entirely new kinds of software for manufacturing.
|
2023-07-27 18:59:40 -04:00
|
|
|
</p>
|
|
|
|
<p className="py-4">
|
2023-12-18 06:15:26 -05:00
|
|
|
ZMA is currently in development. If you would like to be notified when
|
|
|
|
ZMA is ready for production, please sign up for our mailing list at{' '}
|
|
|
|
<a href="https://zoo.dev">zoo.dev</a>.
|
2023-07-27 18:59:40 -04:00
|
|
|
</p>
|
2024-08-16 07:15:42 -04:00
|
|
|
{isDesktop() ? (
|
2023-07-27 18:59:40 -04:00
|
|
|
<ActionButton
|
2023-08-15 21:56:24 -04:00
|
|
|
Element="button"
|
2024-08-16 07:15:42 -04:00
|
|
|
onClick={signInDesktop}
|
2024-05-10 19:02:11 -04:00
|
|
|
iconStart={{ icon: 'arrowRight' }}
|
2023-07-27 18:59:40 -04:00
|
|
|
className="w-fit mt-4"
|
2023-11-29 05:15:04 -05:00
|
|
|
data-testid="sign-in-button"
|
2023-07-27 18:59:40 -04:00
|
|
|
>
|
|
|
|
Sign in
|
|
|
|
</ActionButton>
|
|
|
|
) : (
|
|
|
|
<ActionButton
|
|
|
|
Element="link"
|
2023-08-10 13:30:32 -04:00
|
|
|
to={`${VITE_KC_SITE_BASE_URL}${
|
2024-08-09 02:47:25 -04:00
|
|
|
PATHS.SIGN_IN
|
2023-08-10 13:30:32 -04:00
|
|
|
}?callbackUrl=${encodeURIComponent(
|
2023-07-27 18:59:40 -04:00
|
|
|
typeof window !== 'undefined' &&
|
|
|
|
window.location.href.replace('signin', '')
|
|
|
|
)}`}
|
2024-05-10 19:02:11 -04:00
|
|
|
iconStart={{ icon: 'arrowRight' }}
|
2023-08-09 15:41:41 -04:00
|
|
|
className="w-fit mt-4"
|
2023-07-27 18:59:40 -04:00
|
|
|
>
|
|
|
|
Sign in
|
|
|
|
</ActionButton>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</main>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SignIn
|