Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
prokawsar committed Jul 14, 2024
1 parent 8aed11b commit d0c80fc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lib/utils/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ export const addHistory = async (history: CostHistoryType) => {
return error
}

export const getHistory = async (id: string): Promise<CostHistoryType | null> => {
const { data, error } = await supabase.from('history').select().eq('id', id)
if (!error) {
return data as unknown as CostHistoryType
}
return null
}

export const deleteHistory = async (id: string) => {
const response = await supabase.from('history').delete().eq('id', id)
return response
Expand Down
8 changes: 8 additions & 0 deletions src/routes/history/[id]/+page.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { getHistory } from '$lib/utils/services'

export async function load({ params }) {
const data = await getHistory(params.id)
return {
history: data ?? []
}
}
3 changes: 3 additions & 0 deletions src/routes/history/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
const data: CostHistoryType[] = $paperHistoryStore.filter(
(history) => history.id == $page.params.id
)
// export let data
// let history: CostHistoryType = data.history[0]
</script>

<svelte:head>
Expand Down

0 comments on commit d0c80fc

Please sign in to comment.