Skip to content

Commit 5471ef5

Browse files
committed
[PRAC/cont] Correct "custom" server logic
Chang order/generation of obj prop/FIO fields (as in a modal window). Worth noting: - it's to have the same order everywhere. core: B-3 / JS-BL
1 parent 7a1e193 commit 5471ef5

File tree

1 file changed

+3
-3
lines changed
  • core-courses/3-js-basic-level/practicum-js-basic-level/sb-crm-server

1 file changed

+3
-3
lines changed

core-courses/3-js-basic-level/practicum-js-basic-level/sb-crm-server/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ function makeClientFromData(data) {
5454

5555
// составляем объект, где есть только необходимые поля
5656
const client = {
57-
name: asString(data.name),
5857
surname: asString(data.surname),
58+
name: asString(data.name),
5959
patronymic: asString(data.patronymic),
6060
contacts: Array.isArray(data.contacts)
6161
? data.contacts.map((contact) => ({
@@ -66,9 +66,9 @@ function makeClientFromData(data) {
6666
};
6767

6868
// проверяем, все ли данные корректные и заполняем объект ошибок, которые нужно отдать клиенту
69-
if (!client.name) errors.push({ field: "name", message: "Не указано имя!" });
7069
if (!client.surname)
7170
errors.push({ field: "surname", message: "Не указана фамилия!" });
71+
if (!client.name) errors.push({ field: "name", message: "Не указано имя!" });
7272
if (client.contacts.some((contact) => !contact.type || !contact.value))
7373
errors.push({
7474
field: "contacts",
@@ -92,8 +92,8 @@ function getClientList(params = {}) {
9292
const search = params.search.trim().toLowerCase();
9393
return clients.filter((client) =>
9494
[
95-
client.name,
9695
client.surname,
96+
client.name,
9797
client.patronymic,
9898
...client.contacts.map(({ value }) => value),
9999
].some((str) => str.toLowerCase().includes(search))

0 commit comments

Comments
 (0)