mirror of
https://github.com/Myzel394/kleckrelay-website.git
synced 2025-06-19 07:55:25 +02:00
current stand
This commit is contained in:
parent
91e7b43a5b
commit
e426dc8cd9
@ -70,9 +70,32 @@ export default function AliasNotesForm({id, notes, queryKey}: AliasNotesFormProp
|
|||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
const {mutateAsync} = useMutation<Alias, AxiosError, UpdateAliasData>(
|
const {mutateAsync} = useMutation<
|
||||||
values => updateAlias(id, values),
|
Alias,
|
||||||
|
AxiosError,
|
||||||
|
AliasNote,
|
||||||
|
{previousAlias?: DecryptedAlias}
|
||||||
|
>(
|
||||||
|
values => {
|
||||||
|
updateAlias(id, values)
|
||||||
|
},
|
||||||
{
|
{
|
||||||
|
onMutate: async values => {
|
||||||
|
await queryClient.cancelQueries(queryKey)
|
||||||
|
|
||||||
|
const previousAlias = queryClient.getQueryData<DecryptedAlias>(queryKey)
|
||||||
|
|
||||||
|
if (previousAlias) {
|
||||||
|
;(previousAlias as any as DecryptedAlias).notes = decryptAliasNotes(
|
||||||
|
(previousAlias as any as Alias).encryptedNotes,
|
||||||
|
_decryptUsingMasterPassword,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
previousAlias,
|
||||||
|
}
|
||||||
|
},
|
||||||
onSuccess: async newAlias => {
|
onSuccess: async newAlias => {
|
||||||
;(newAlias as any as DecryptedAlias).notes = decryptAliasNotes(
|
;(newAlias as any as DecryptedAlias).notes = decryptAliasNotes(
|
||||||
newAlias.encryptedNotes,
|
newAlias.encryptedNotes,
|
||||||
@ -85,7 +108,10 @@ export default function AliasNotesForm({id, notes, queryKey}: AliasNotesFormProp
|
|||||||
|
|
||||||
queryClient.setQueryData<DecryptedAlias | Alias>(queryKey, newAlias)
|
queryClient.setQueryData<DecryptedAlias | Alias>(queryKey, newAlias)
|
||||||
},
|
},
|
||||||
onError: showError,
|
onError: error => {
|
||||||
|
showError(error)
|
||||||
|
setIsInEditMode(true)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
const initialValues = useMemo(
|
const initialValues = useMemo(
|
||||||
|
@ -71,7 +71,7 @@ export default function SelectField({
|
|||||||
|
|
||||||
formik.setFieldValue(name, value)
|
formik.setFieldValue(name, value)
|
||||||
}}
|
}}
|
||||||
disabled={formik.sSubmitting}
|
disabled={formik.isSubmitting}
|
||||||
error={Boolean(formik.touched[name] && formik.errors[name])}
|
error={Boolean(formik.touched[name] && formik.errors[name])}
|
||||||
renderValue={value =>
|
renderValue={value =>
|
||||||
value === "null" ? (
|
value === "null" ? (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user