Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bosung90 committed Oct 13, 2023
1 parent a204681 commit 6a2a6bf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"firebase-admin": "^11.11.0",
"flowbite-svelte": "^0.44.17",
"luxon": "^3.4.1",
"svelte-french-toast": "^1.2.0"
"svelte-french-toast": "^1.2.0",
"tailwind-merge": "^1.14.0"
},
"devDependencies": {
"@smui/data-table": "^7.0.0-beta.15",
Expand Down
8 changes: 6 additions & 2 deletions src/lib/components/Drawer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import List, {Item, Text} from '@smui/list'
import {goto} from '$app/navigation'
import {AdminTable} from './index'
import {selectedEventId} from '$lib/store'
import {twMerge} from 'tailwind-merge'
export let events: DB.Event[]
export let ticketValue: Map<string, DB.Ticket>
</script>
Expand All @@ -16,7 +17,10 @@
<button on:click={() => goto(`/admin/dashboard?eventId=${event.id}`)}>
<Item
id="event-title"
class="flex p-2 cursor-pointer bg-gray-100 hover:bg-gray-300 ease-in-out duration-200 rounded hover:font-semibold">
class={twMerge(
'flex p-2 cursor-pointer bg-gray-100 hover:bg-gray-300 ease-in-out duration-200 rounded hover:font-semibold',
event.id === $selectedEventId && 'bg-purple-300'
)}>
<Text class="text-start">{event.title}</Text>
</Item>
</button>
Expand Down
21 changes: 12 additions & 9 deletions src/lib/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ function handleQuerySnapshot<T extends DocumentData>(

function deriveStoreFromQuery<V, T extends DocumentData>(
stores: Parameters<typeof derived>[0],
getQuery: (value: V) => Query
getQuery: (value: V) => Query | null
) {
return derived(stores, ($stores, set) =>
handleQuerySnapshot<T>(getQuery($stores), set)
) as Readable<Map<string, T>>
return derived(stores, ($stores, set) => {
const q = getQuery($stores)
q ? handleQuerySnapshot<T>(q, set) : q
}) as Readable<Map<string, T>>
}

function handleDocSnapshot<T extends DocumentData>(
Expand All @@ -61,11 +62,13 @@ export const selectedEventId = writable<string>()
export const ticketValue = deriveStoreFromQuery<string, DB.Ticket>(
selectedEventId,
($selectedEventId) =>
query(
collection(db, 'Tickets'),
where('eventId', '==', $selectedEventId),
orderBy('createdAt', 'desc')
)
$selectedEventId
? query(
collection(db, 'Tickets'),
where('eventId', '==', $selectedEventId),
orderBy('createdAt', 'desc')
)
: null
)
export const selectedTicket = {
// State
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4142,7 +4142,7 @@ svg.select.js@^3.0.1:

tailwind-merge@^1.14.0:
version "1.14.0"
resolved "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-1.14.0.tgz"
resolved "https://registry.yarnpkg.com/tailwind-merge/-/tailwind-merge-1.14.0.tgz#e677f55d864edc6794562c63f5001f45093cdb8b"
integrity sha512-3mFKyCo/MBcgyOTlrY8T7odzZFx+w+qKSMAmdFzRvqBfLlSigU6TZnlFHK0lkMwj9Bj8OYU+9yW9lmGuS0QEnQ==

tailwindcss@^3.3.3:
Expand Down

0 comments on commit 6a2a6bf

Please sign in to comment.