WIP Доделал форму Контактов

This commit is contained in:
DwCay
2023-04-17 18:46:17 +03:00
parent 4c63092bb1
commit 2cf725e96d
5 changed files with 80 additions and 55 deletions

View File

@@ -245,19 +245,24 @@ const actions = {
.filter((el) => !allNewContacts.find((newNet) => newNet.id === el.id))
.map((el) => fetchWrapper.del(`general/contact/${el.id}/delete/`));
const request = allNewContacts
.map((network) => {
let initNetwork = initContacts.find((el) => el.id === network.id);
if (!network.id) {
.map((contact) => {
let initNetwork = initContacts.find((el) => el.id === contact.id);
if (!contact.id && contact.username && contact.kind) {
return fetchWrapper.post(`general/contact/create/`, {
person: personId,
...network,
username: contact.username,
kind: contact.kind,
});
}
if (network.id && network.username !== initNetwork.username) {
return fetchWrapper.post(`general/contact/${network.id}/update/`, {
if (
contact.id &&
contact.username &&
contact.username !== initNetwork.username
) {
return fetchWrapper.post(`general/contact/${contact.id}/update/`, {
person: personId,
username: network.username,
kind: network.kind,
username: contact.username,
kind: contact.kind,
});
}
return Promise.resolve();