-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add randomize button and links to questions
- Loading branch information
Showing
10 changed files
with
18,161 additions
and
15,848 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
{} | ||
{ | ||
"plugins": ["prettier-plugin-tailwindcss"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
import { openDB } from 'idb'; | ||
|
||
const DB_NAME = 'drivingTestConfigDB'; | ||
const DB_VERSION = 1; | ||
const STORE_NAME = 'mainStore'; | ||
const EXCLUDED_KEY = 'excludedQuestions'; | ||
|
||
export const initDB = async () => { | ||
const db = await openDB(DB_NAME, DB_VERSION, { | ||
upgrade(db) { | ||
if (!db.objectStoreNames.contains(STORE_NAME)) { | ||
db.createObjectStore(STORE_NAME); | ||
} | ||
}, | ||
}); | ||
return db; | ||
}; | ||
|
||
export const getExcludedIds = async () => { | ||
const db = await initDB(); | ||
const excluded = await db.get(STORE_NAME, EXCLUDED_KEY); | ||
return excluded || []; | ||
}; | ||
|
||
export const updateExcludedIds = async (ids) => { | ||
const db = await initDB(); | ||
await db.put(STORE_NAME, ids, EXCLUDED_KEY); | ||
}; | ||
import { openDB } from "idb"; | ||
|
||
const DB_NAME = "drivingTestConfigDB"; | ||
const DB_VERSION = 1; | ||
const STORE_NAME = "mainStore"; | ||
const EXCLUDED_KEY = "excludedQuestions"; | ||
|
||
export const initDB = async () => { | ||
const db = await openDB(DB_NAME, DB_VERSION, { | ||
upgrade(db) { | ||
if (!db.objectStoreNames.contains(STORE_NAME)) { | ||
db.createObjectStore(STORE_NAME); | ||
} | ||
}, | ||
}); | ||
return db; | ||
}; | ||
|
||
export const getExcludedFromDB = async () => { | ||
const db = await initDB(); | ||
const excluded = await db.get(STORE_NAME, EXCLUDED_KEY); | ||
return excluded || []; | ||
}; | ||
|
||
export const updateExcludedToDB = async (ids) => { | ||
const db = await initDB(); | ||
await db.put(STORE_NAME, ids, EXCLUDED_KEY); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,29 @@ | ||
export function ExcludedList({ excludedIds, data }) { | ||
return ( | ||
<div> | ||
<h2 className="font-bold text-xl">Excluded Questions</h2> | ||
{excludedIds.length > 0 ? ( | ||
<ul> | ||
{excludedIds.map((id) => ( | ||
<li key={id}> | ||
#{id} {data[id].question} | ||
</li> | ||
))} | ||
</ul> | ||
) : ( | ||
<p>No excluded questions yet.</p> | ||
)} | ||
</div> | ||
); | ||
} | ||
import { Link } from "@chakra-ui/react"; | ||
|
||
export function ExcludedList({ excludedIds, data }) { | ||
return ( | ||
<div className="flex w-full flex-col items-center px-6"> | ||
<h1 className="text-xl font-bold md:text-3xl">Excluded Questions</h1> | ||
{excludedIds.length > 0 && ( | ||
<ul className="flex max-w-full flex-col items-start gap-2 overflow-hidden text-ellipsis pt-3 md:max-w-screen-md md:pt-6"> | ||
{excludedIds.map((id) => ( | ||
<li | ||
key={id} | ||
className="max-w-full overflow-hidden text-ellipsis text-nowrap md:max-w-screen-md" | ||
> | ||
<Link | ||
mx={2} | ||
fontWeight="normal" | ||
color="teal.500" | ||
href={`/?q=${id}`} | ||
> | ||
#{id} - {data[id - 1].question} | ||
</Link> | ||
</li> | ||
))} | ||
</ul> | ||
)} | ||
{excludedIds.length === 0 && <p>No excluded questions yet.</p>} | ||
</div> | ||
); | ||
} |
Oops, something went wrong.