-
Notifications
You must be signed in to change notification settings - Fork 1
Consolidate /create and /templates #306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,38 @@ | ||
| import { type FC, useEffect, useRef } from 'react' | ||
| import { useCreate } from './useCreate' | ||
| import { TemplateStep } from './TemplateStep' | ||
| import { MetadataStep } from './MetadataStep' | ||
| import { AgentStep } from './AgentStep' | ||
| import { BuildStep } from './BuildStep' | ||
| import { PaymentStep } from './PaymentStep' | ||
| import { BootstrapStep } from './BootstrapStep' | ||
| import { getTemplateById } from './templates' | ||
| import { useLocation } from 'react-router-dom' | ||
| import { Layout } from '@oasisprotocol/ui-library/src/components/ui/layout' | ||
| import { Button } from '@oasisprotocol/ui-library/src/components/ui/button' | ||
| import { Separator } from '@oasisprotocol/ui-library/src/components/ui/separator' | ||
| import { ArrowRight } from 'lucide-react' | ||
| import { Link } from 'react-router-dom' | ||
| import { useAccount } from 'wagmi' | ||
| import { trackEvent } from 'fathom-client' | ||
| import { Header } from '../Layout/Header' | ||
| import { Footer } from '../Layout/Footer' | ||
| import { TemplatesList } from '../TemplatesList' | ||
| import { RainbowKitConnectButton } from '../RainbowKitConnectButton' | ||
| import { useCreate } from '../../pages/CreateApp/useCreate' | ||
| import { TemplateStep } from '../../pages/CreateApp/TemplateStep' | ||
| import { MetadataStep } from '../../pages/CreateApp/MetadataStep' | ||
| import { AgentStep } from '../../pages/CreateApp/AgentStep' | ||
| import { BuildStep } from '../../pages/CreateApp/BuildStep' | ||
| import { PaymentStep } from '../../pages/CreateApp/PaymentStep' | ||
| import { BootstrapStep } from '../../pages/CreateApp/BootstrapStep' | ||
| import { getTemplateById } from '../../pages/CreateApp/templates' | ||
|
|
||
| interface TemplateFlowProps { | ||
| mode?: 'browse' | 'create' | ||
| } | ||
|
|
||
| export const TemplateFlow: FC<TemplateFlowProps> = ({ mode }) => { | ||
| const location = useLocation() | ||
| const { isConnected } = useAccount() | ||
|
|
||
| const flowMode = mode || (location.pathname.startsWith('/create') ? 'create' : 'browse') | ||
|
|
||
| export const Create: FC = () => { | ||
| const { currentStep, setCurrentStep, appData, setAppDataForm } = useCreate() | ||
| const trackedEvents = useRef<Set<number>>(new Set()) | ||
|
|
||
| const steps = [ | ||
| { component: TemplateStep }, | ||
| { component: MetadataStep }, | ||
|
|
@@ -19,12 +41,13 @@ export const Create: FC = () => { | |
| { component: PaymentStep }, | ||
| { component: BootstrapStep }, | ||
| ] | ||
|
|
||
| const selectedTemplate = getTemplateById(appData?.template) | ||
| const trackedEvents = useRef<Set<number>>(new Set()) | ||
|
|
||
| useEffect(() => { | ||
| if (flowMode !== 'create') return | ||
|
|
||
| if (currentStep === 1 && !trackedEvents.current.has(1)) { | ||
| // Filter out just visiting create app page, hence step=1 | ||
| trackEvent(`Create app flow/1/start/${appData?.template}`) | ||
| trackedEvents.current.add(1) | ||
| } else if (currentStep === 2 && !trackedEvents.current.has(2)) { | ||
|
|
@@ -37,7 +60,7 @@ export const Create: FC = () => { | |
| trackEvent(`Create app flow/4/payment/${appData?.template}`) | ||
| trackedEvents.current.add(4) | ||
| } | ||
| }, [currentStep, appData?.template]) | ||
| }, [flowMode, currentStep, appData?.template]) | ||
|
|
||
| const handleNext = () => { | ||
| if (currentStep < steps.length - 1) { | ||
|
|
@@ -51,6 +74,48 @@ export const Create: FC = () => { | |
| } | ||
| } | ||
|
|
||
| if (flowMode === 'browse') { | ||
| return ( | ||
| <div className="[&>*]:md:max-h-none [&>*]:md:h-auto"> | ||
| <Layout headerContent={<Header />} footerContent={<Footer />}> | ||
| <div className="mx-auto px-8 py-12"> | ||
| <div className="mb-10"> | ||
| <h1 className="text-2xl font-white font-bold text-center mb-8"> | ||
| Create your app from a template | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. having a different page title above TemplatesList |
||
| </h1> | ||
| <div className="text-center"> | ||
| <RainbowKitConnectButton> | ||
| {({ openConnectModal }) => { | ||
| return isConnected ? ( | ||
| <Button size="lg" asChild> | ||
| <Link to="/create"> | ||
| Get started | ||
| <ArrowRight /> | ||
|
Comment on lines
+88
to
+93
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what I meant was: when user is on path /create: if wallet is not connected, show connect button + TemplatesList. If wallet is connected then show step 0 (TemplatesList). Delete /templates path. Delete "Get started" button |
||
| </Link> | ||
| </Button> | ||
| ) : ( | ||
| <Button | ||
| onClick={() => { | ||
| openConnectModal() | ||
| }} | ||
| className="max-md:w-full" | ||
| > | ||
| Connect Wallet | ||
| <ArrowRight /> | ||
| </Button> | ||
| ) | ||
| }} | ||
| </RainbowKitConnectButton> | ||
| </div> | ||
| </div> | ||
| <Separator className="my-8" /> | ||
| <TemplatesList /> | ||
| </div> | ||
| </Layout> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| return ( | ||
| <div className="[&>*]:md:max-h-none [&>*]:md:h-auto"> | ||
| {currentStep === 0 && <TemplateStep handleNext={handleNext} setAppDataForm={setAppDataForm} />} | ||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah handling sideeffects here is annoying