Skip to content

Commit

Permalink
fix: fix update record
Browse files Browse the repository at this point in the history
  • Loading branch information
nichenqin committed Dec 19, 2023
1 parent d906738 commit 561357e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions apps/frontend/src/lib/record/UpdateRecord.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@
},
})
$: if ($record) {
form.set($record.valuesJSON)
$tainted = undefined
}
onMount(() => {
$tainted = undefined
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
}
async function fetchRecord(recordId: string) {
const record = await trpc().record.get.utils.fetch({ id: recordId, tableId: $table.id.value })
const r = record ? RecordFactory.fromQuery(record, schema) : undefined
currentRecord.set(r?.into())
const r = record ? RecordFactory.fromQuery(record, schema).unwrap() : undefined
currentRecord.set(r)
}
$: if (!$currentRecordId) {
currentRecord.set(undefined)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const load: PageLoad = async (event) => {
const fields = view.getOrderedFields(coreTable.schema.nonSystemFields)

const recordId = event.url.searchParams.get('r')
console.log(event)

const record = recordId ? await trpc().record.get.utils.fetch({ tableId, id: recordId }) : undefined
const coreRecord = record ? RecordFactory.fromQuery(record, coreTable.schema.toIdMap()).unwrap() : undefined
Expand Down
9 changes: 9 additions & 0 deletions apps/frontend/src/routes/(share)/s/v/[viewId]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { currentRecord, currentRecordId, getTable } from '$lib/store/table'
import { page } from '$app/stores'
import { RecordFactory } from '@undb/core'
import { trpc } from '$lib/trpc/client'
const table = getTable()
$: schema = $table.schema.toIdMap()
Expand All @@ -14,6 +15,14 @@
$: if (!$currentRecordId) {
currentRecord.set(undefined)
}
async function fetchRecord(recordId: string) {
const record = await trpc().record.get.utils.fetch({ id: recordId, tableId: $table.id.value })
const r = record ? RecordFactory.fromQuery(record, schema).unwrap() : undefined
currentRecord.set(r)
}
$: if ($currentRecordId) {
fetchRecord($currentRecordId)
}
</script>

<div class="flex flex-col h-screen">
Expand Down

0 comments on commit 561357e

Please sign in to comment.