|
| 1 | +import type { Component } from "solid-js"; |
| 2 | +import { SymbolButton } from "../domains/ui/components/symbol-button"; |
| 3 | +import { ValibotImportButton } from "../domains/database/components/valibot-import-button/valibot-import-button"; |
| 4 | +import { css } from "@emotion/css"; |
| 5 | +import { useDatabases } from "../domains/database/compositions/use-databases"; |
| 6 | + |
| 7 | +const sCode = css({ |
| 8 | + whiteSpace: "pre", |
| 9 | +}); |
| 10 | + |
| 11 | +interface RecoveryProps { |
| 12 | + error: Error; |
| 13 | +} |
| 14 | + |
| 15 | +export const Recovery: Component<RecoveryProps> = (props) => { |
| 16 | + const databases = useDatabases(); |
| 17 | + |
| 18 | + return ( |
| 19 | + <> |
| 20 | + <h1>Something went wrong.</h1> |
| 21 | + |
| 22 | + <details> |
| 23 | + <summary> |
| 24 | + <span>Error: {props.error.toString()}</span> |
| 25 | + </summary> |
| 26 | + <code class={sCode}>{JSON.stringify(props.error, undefined, 2)}</code> |
| 27 | + </details> |
| 28 | + |
| 29 | + <p>Most probably the database is corrupted. Try to recover by following these steps.</p> |
| 30 | + <dl> |
| 31 | + <dt>Step 1</dt> |
| 32 | + <dd> |
| 33 | + <p>Export your database.</p> |
| 34 | + {/*This component must be changed when rebasing release on dev*/} |
| 35 | + <SymbolButton symbol="📤" onClick={databases.download}> |
| 36 | + Export |
| 37 | + </SymbolButton> |
| 38 | + </dd> |
| 39 | + <dt>Step 2</dt> |
| 40 | + <dd> |
| 41 | + <p>Import the database you just exported to get some hints about faulty attempt(s).</p> |
| 42 | + <p> |
| 43 | + <ValibotImportButton symbol="📥" onClick={databases.restore}> |
| 44 | + Import |
| 45 | + </ValibotImportButton> |
| 46 | + </p> |
| 47 | + </dd> |
| 48 | + <dt>Step 3</dt> |
| 49 | + <dd> |
| 50 | + <p> |
| 51 | + Open the JSON file with a code or text editor, and remove the faulty attempt(s). Then import again your |
| 52 | + database. |
| 53 | + </p> |
| 54 | + <p> |
| 55 | + <ValibotImportButton symbol="📥" onClick={databases.restore}> |
| 56 | + Import |
| 57 | + </ValibotImportButton> |
| 58 | + </p> |
| 59 | + </dd> |
| 60 | + |
| 61 | + <dt>Step 4</dt> |
| 62 | + <dd> |
| 63 | + <p> |
| 64 | + The import was successful? Just{" "} |
| 65 | + <a |
| 66 | + href={location.href} |
| 67 | + onClick={() => { |
| 68 | + location.reload(); |
| 69 | + }} |
| 70 | + > |
| 71 | + reload |
| 72 | + </a>{" "} |
| 73 | + the page. |
| 74 | + </p> |
| 75 | + <p> |
| 76 | + This is too technical and you got lost? You can find me (@Lukino) on{" "} |
| 77 | + <a target="_blank" href="https://discord.gg/6gDAPxvqh7"> |
| 78 | + Mario Kart World Time Trials |
| 79 | + </a>{" "} |
| 80 | + discord. I would be happy to help you. |
| 81 | + </p> |
| 82 | + </dd> |
| 83 | + </dl> |
| 84 | + </> |
| 85 | + ); |
| 86 | +}; |
0 commit comments