await POST calls and refetch call

This commit is contained in:
Tanguy Gérôme 2026-01-06 09:00:53 +02:00
parent 3d0e9206cd
commit dbc26163d0
Signed by: tanguy
GPG key ID: 10B2947233740B88

View file

@ -90,7 +90,7 @@ function Home() {
// ============================================ // ============================================
const addCoffeeDialogId = 'addCoffeeDialog' const addCoffeeDialogId = 'addCoffeeDialog'
async function postNewCoffee() { async function postNewCoffee() {
postNewEntry( await postNewEntry(
'coffee', 'coffee',
{ {
name: addCoffeeName, name: addCoffeeName,
@ -98,7 +98,7 @@ function Home() {
notes: addCoffeeNotes, notes: addCoffeeNotes,
} }
) )
queryClient.invalidateQueries({ queryKey: ['coffees'] }) await queryClient.refetchQueries({ queryKey: ['coffees'] })
closeDialog(addCoffeeDialogId) closeDialog(addCoffeeDialogId)
} }
function renderAddCoffeeDialog() { function renderAddCoffeeDialog() {
@ -134,14 +134,14 @@ function Home() {
// ============================================ // ============================================
const addGrinderDialogId = 'addGrinderDialog' const addGrinderDialogId = 'addGrinderDialog'
async function postNewGrinder() { async function postNewGrinder() {
postNewEntry( await postNewEntry(
'grinder', 'grinder',
{ {
name: addGrinderName, name: addGrinderName,
notes: addGrinderNotes, notes: addGrinderNotes,
} }
) )
queryClient.invalidateQueries({ queryKey: ['grinders'] }) await queryClient.refetchQueries({ queryKey: ['grinders'] })
closeDialog(addGrinderDialogId) closeDialog(addGrinderDialogId)
} }
function renderAddGrinderDialog() { function renderAddGrinderDialog() {
@ -172,14 +172,14 @@ function Home() {
// ============================================ // ============================================
const addBrewerDialogId = 'addBrewerDialog' const addBrewerDialogId = 'addBrewerDialog'
async function postNewBrewer() { async function postNewBrewer() {
postNewEntry( await postNewEntry(
'brewer', 'brewer',
{ {
name: addBrewerName, name: addBrewerName,
notes: addBrewerNotes, notes: addBrewerNotes,
} }
) )
queryClient.invalidateQueries({ queryKey: ['brewers'] }) await queryClient.refetchQueries({ queryKey: ['brewers'] })
closeDialog(addBrewerDialogId) closeDialog(addBrewerDialogId)
} }
function renderAddBrewerDialog() { function renderAddBrewerDialog() {
@ -210,7 +210,7 @@ function Home() {
// ============================================ // ============================================
const addMethodDialogId = 'addMethodDialog' const addMethodDialogId = 'addMethodDialog'
async function postNewMethod() { async function postNewMethod() {
postNewEntry( await postNewEntry(
'method', 'method',
{ {
coffeeId: addMethodCoffeeId, coffeeId: addMethodCoffeeId,
@ -225,7 +225,7 @@ function Home() {
notes: addMethodNotes, notes: addMethodNotes,
} }
) )
queryClient.invalidateQueries({ queryKey: ['methods'] }) await queryClient.refetchQueries({ queryKey: ['methods'] })
closeDialog(addMethodDialogId) closeDialog(addMethodDialogId)
} }
function renderAddMethodDialog() { function renderAddMethodDialog() {