mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-25 14:34:19 +00:00
🧊 Renamed inner resources
variable to res
This commit is contained in:
parent
b2ad53d209
commit
1be5584de9
1 changed files with 4 additions and 4 deletions
|
@ -114,7 +114,7 @@ export default function useBackendViewset(resourcesPath, pkName,
|
||||||
const retrieveResource = useCallback(
|
const retrieveResource = useCallback(
|
||||||
async (pk) => {
|
async (pk) => {
|
||||||
const refreshedResource = await apiRetrieve(pk)
|
const refreshedResource = await apiRetrieve(pk)
|
||||||
setResources(resources => resources.map(resource => {
|
setResources(res => res.map(resource => {
|
||||||
if(resource[pkName] === pk) {
|
if(resource[pkName] === pk) {
|
||||||
return refreshedResource
|
return refreshedResource
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ export default function useBackendViewset(resourcesPath, pkName,
|
||||||
const createResource = useCallback(
|
const createResource = useCallback(
|
||||||
async (data) => {
|
async (data) => {
|
||||||
const newResource = await apiCreate(data)
|
const newResource = await apiCreate(data)
|
||||||
setResources(resources => [...resources, newResource])
|
setResources(res => [...res, newResource])
|
||||||
return newResource
|
return newResource
|
||||||
},
|
},
|
||||||
[apiCreate],
|
[apiCreate],
|
||||||
|
@ -137,7 +137,7 @@ export default function useBackendViewset(resourcesPath, pkName,
|
||||||
const editResource = useCallback(
|
const editResource = useCallback(
|
||||||
async (pk, data) => {
|
async (pk, data) => {
|
||||||
const editedResource = await apiEdit(pk, data)
|
const editedResource = await apiEdit(pk, data)
|
||||||
setResources(resources => resources.map(resource => {
|
setResources(res => res.map(resource => {
|
||||||
if(resource[pkName] === pk) {
|
if(resource[pkName] === pk) {
|
||||||
return editedResource
|
return editedResource
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ export default function useBackendViewset(resourcesPath, pkName,
|
||||||
const destroyResource = useCallback(
|
const destroyResource = useCallback(
|
||||||
async (pk) => {
|
async (pk) => {
|
||||||
await apiDestroy(pk)
|
await apiDestroy(pk)
|
||||||
setResources(resources => resources.filter(resource => resource[pkName] !== pk))
|
setResources(res => res.filter(resource => resource[pkName] !== pk))
|
||||||
return null
|
return null
|
||||||
},
|
},
|
||||||
[apiDestroy, pkName],
|
[apiDestroy, pkName],
|
||||||
|
|
Loading…
Reference in a new issue