@@ -25,20 +25,18 @@ import type { Route } from "./+types/setup._index"
2525
2626const completeSetup = createAction ( {
2727 schema : z . object ( {
28+ file : z . string ( ) ,
29+ export : z . string ( ) ,
2830 dbname : z . string ( ) ,
2931 dburl : z . string ( ) ,
30- entrypoint : z . string ( ) ,
31- export : z . string ( ) ,
3232 } ) ,
3333 async handler ( ctx , { request } ) {
3434 const session = await sessionStore . getSession ( request . headers . get ( "Cookie" ) )
35- const projects = session . get ( "projects" )
3635 session . set ( "projects" , {
37- ...projects ,
3836 [ process . cwd ( ) ] : {
39- entrypoint : ctx . input . entrypoint ,
37+ file : ctx . input . file ,
4038 export : ctx . input . export ,
41- dburl : ctx . input . dburl ,
39+ dbname : ctx . input . dbname ,
4240 dbs : { [ ctx . input . dbname ] : ctx . input . dburl } ,
4341 } ,
4442 } )
@@ -57,8 +55,7 @@ export async function action(args: Route.ActionArgs) {
5755export async function loader ( { request } : Route . LoaderArgs ) {
5856 const cwd = process . cwd ( )
5957 const session = await sessionStore . getSession ( request . headers . get ( "Cookie" ) )
60- const projects = session . get ( "projects" )
61- const project = projects ? projects [ cwd ] : undefined
58+ const project = await context . entrypoint . getProject ( session . get ( "projects" ) )
6259 if ( project ) throw redirect ( "/" )
6360
6461 const files = await context . entrypoint . getFiles ( )
@@ -106,7 +103,7 @@ function ConnectSchema(props: { tree: DirTree; suggestions: string[] }) {
106103 setDraftProject ( {
107104 step : 2 ,
108105 project : {
109- entrypoint : value . file ,
106+ file : value . file ,
110107 export : value . identifier ,
111108 } ,
112109 } )
@@ -119,7 +116,7 @@ function ConnectSchema(props: { tree: DirTree; suggestions: string[] }) {
119116 return (
120117 < form onSubmit = { handleSubmit } className = "grid gap-4" >
121118 < p className = "text-xs" >
122- Select the file containing the monarch database export
119+ Select file containing a monarch database export
123120 </ p >
124121
125122 < SchemaSelector
@@ -148,7 +145,7 @@ function ConnectDatabase() {
148145 step : 3 ,
149146 project : {
150147 ...draft . project ,
151- dburl ,
148+ dbname ,
152149 dbs : { [ dbname ] : dburl } ,
153150 } ,
154151 } )
@@ -168,16 +165,20 @@ function ConnectDatabase() {
168165 < input type = "hidden" name = "_action" value = "connectDatabase" />
169166 < div className = "grid gap-1" >
170167 < label className = "text-xs font-medium" > Database name</ label >
171- < Input type = "text" name = "dbname" placeholder = "Database name" />
168+ < Input
169+ type = "text"
170+ name = "dbname"
171+ placeholder = "Enter database name"
172+ defaultValue = "Default"
173+ />
172174 </ div >
173175 < div className = "grid gap-1" >
174- < label className = "text-xs font-medium" > Connection string </ label >
175- < Input type = "url" name = "dburl" placeholder = "Database URL" />
176+ < label className = "text-xs font-medium" > Database URL </ label >
177+ < Input type = "url" name = "dburl" placeholder = "Enter database URL" />
176178 </ div >
177179
178180 < p className = "text-xs text-muted-foreground" >
179- You can add multiple database connections (dev and prod) and switch
180- between them.
181+ You can add multiple database connections and switch between them.
181182 </ p >
182183
183184 < div className = "mt-4 flex justify-between gap-4" >
@@ -199,12 +200,11 @@ function CompleteSetup({
199200 const fetcher = useFetcher < typeof action > ( )
200201
201202 const submitAction = async ( ) => {
202- const dbname = Object . keys ( draft . project . dbs ) [ 0 ] !
203203 const data = {
204- dbname,
205- dburl : draft . project . dburl ,
206- entrypoint : draft . project . entrypoint ,
204+ file : draft . project . file ,
207205 export : draft . project . export ,
206+ dbname : draft . project . dbname ,
207+ dburl : draft . project . dbs [ draft . project . dbname ] ! ,
208208 } satisfies InferActionInput < typeof completeSetup >
209209 await fetcher . submit (
210210 {
0 commit comments