|
1 | 1 | <script lang="ts"> |
2 | 2 | import { resolve } from '$app/paths'; |
3 | 3 | import Logo from '$lib/assets/logo.png'; |
4 | | - import type { PageProps } from './$types'; |
| 4 | + import type { ActionData, PageData } from './$types'; |
| 5 | + import { goto } from '$app/navigation'; |
5 | 6 |
|
6 | | - let { data }: PageProps = $props(); |
| 7 | + let { data, form }: { data: PageData; form: ActionData } = $props(); |
7 | 8 | </script> |
8 | 9 |
|
9 | 10 | <div class="h-screen flex flex-col gap-1"> |
|
13 | 14 | <img src={Logo} alt="Logo" class="h-full rounded-full" /> |
14 | 15 | </a> |
15 | 16 | <div class="h-full w-full flex flex-col justify-between"> |
16 | | - {data.success ? 'Project loading' : 'Error: ' + data.errorMsg} |
| 17 | + {#if !data.success} |
| 18 | + <div style="white-space:pre; color:red"> |
| 19 | + {'Error: ' + data.errorMsg} |
| 20 | + </div> |
| 21 | + {/if} |
| 22 | + {#if form?.errorMsg} |
| 23 | + <div style="white-space:pre; color:red"> |
| 24 | + {'Error: ' + form?.errorMsg} |
| 25 | + </div> |
| 26 | + {/if} |
| 27 | + {#if data.creationPanel === 'local'} |
| 28 | + <form |
| 29 | + onsubmit={(e) => { |
| 30 | + e.preventDefault(); |
| 31 | + const formData = new FormData(e.currentTarget); |
| 32 | + // eslint-disable-next-line svelte/no-navigation-without-resolve |
| 33 | + goto(`/load-project?projectPath=${formData.get('projectPath')}`); |
| 34 | + }} |
| 35 | + > |
| 36 | + <input name="projectPath" placeholder="Project path" /> |
| 37 | + <input type="submit" value="Go to project" /> |
| 38 | + </form> |
| 39 | + <form |
| 40 | + onsubmit={(e) => { |
| 41 | + e.preventDefault(); |
| 42 | + const formData = new FormData(e.currentTarget); |
| 43 | + fetch('/cli?/createProject', { |
| 44 | + method: 'POST', |
| 45 | + body: JSON.stringify({ |
| 46 | + projectPath: formData.get('projectPath'), |
| 47 | + projectName: formData.get('projectName'), |
| 48 | + packageManager: formData.get('packageManager'), |
| 49 | + language: formData.get('language'), |
| 50 | + strictTypeChecking: formData.get('strictTypeChecking') ?? false, |
| 51 | + multiplayerServer: formData.get('multiplayerServer') ?? false, |
| 52 | + skipDependencyInstallation: formData.get('skipDependencyInstallation') ?? false, |
| 53 | + dockerContainerization: formData.get('dockerContainerization') ?? false, |
| 54 | + }), |
| 55 | + }); |
| 56 | + }} |
| 57 | + > |
| 58 | + <input name="projectPath" placeholder="Project local path" /> |
| 59 | + <input name="projectName" placeholder="Project Name" /> |
| 60 | + <label for="packageManagerId">Package manager :</label> |
| 61 | + <select name="packageManager" id="packageManagerId"> |
| 62 | + <option value="npm">npm</option> |
| 63 | + <option value="yarn">yarn</option> |
| 64 | + <option value="pnpm">pnpm</option> |
| 65 | + <option value="bun">bun</option> |
| 66 | + </select> |
| 67 | + <label for="languageId">Project language :</label> |
| 68 | + <select name="language" id="languageId"> |
| 69 | + <option value="js">js</option> |
| 70 | + <option value="ts">ts</option> |
| 71 | + </select> |
| 72 | + |
| 73 | + <label for="strictTypeCheckingId">Strict Type Checking :</label> |
| 74 | + <input |
| 75 | + type="checkbox" |
| 76 | + name="strictTypeChecking" |
| 77 | + value="true" |
| 78 | + id="strictTypeCheckingId" |
| 79 | + /> |
| 80 | + <label for="multiplayerServerId">Multiplayer Server :</label> |
| 81 | + <input type="checkbox" name="multiplayerServer" value="true" id="multiplayerServerId" /> |
| 82 | + <label for="skipDependencyInstallationId">Skip Dependency Installation :</label> |
| 83 | + <input |
| 84 | + type="checkbox" |
| 85 | + name="skipDependencyInstallation" |
| 86 | + value="true" |
| 87 | + id="skipDependencyInstallationId" |
| 88 | + /> |
| 89 | + <label for="dockerContainerizationId">Docker containerization :</label> |
| 90 | + <input |
| 91 | + type="checkbox" |
| 92 | + name="dockerContainerization" |
| 93 | + value="true" |
| 94 | + id="dockerContainerizationId" |
| 95 | + /> |
| 96 | + <button type="submit" value="Create Local Project">Create Local Project</button> |
| 97 | + </form> |
| 98 | + {/if} |
17 | 99 | </div> |
18 | 100 | </div> |
19 | 101 | </header> |
|
0 commit comments