Skip to content

Commit

Permalink
refactor(Site): ♻️ Remove typo error
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoval committed Dec 5, 2023
1 parent 09fbd22 commit 7389df2
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 74 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@tanstack/react-query": "^5.12.2",
"axios": "^1.6.2",
"date-fns": "^2.30.0",
"framer-motion": "^10.16.12",
"framer-motion": "^10.16.14",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.11",
Expand All @@ -60,14 +60,14 @@
"@testing-library/react": "^14.1.2",
"@testing-library/user-event": "^14.5.1",
"@types/jest": "^29.5.10",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"circular-dependency-plugin": "^5.2.2",
"commitizen": "^4.3.0",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.8.1",
"css-minimizer-webpack-plugin": "^5.0.1",
"cypress": "^13.6.0",
"cypress": "^13.6.1",
"cz-git": "^1.7.1",
"eslint": "^8.55.0",
"eslint-config-prettier": "^9.1.0",
Expand Down
33 changes: 21 additions & 12 deletions src/pages/Sites/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,27 @@ const SitesController = {
return { sourceSiteId, destinationSiteId, ...link };
});

// Map <source site Id: destination site Id> to assign to each site the sited Ids connected with him (destinations)
const linksExtendedMap = linksExtended
.filter(({ linkCost }) => linkCost !== undefined)
.reduce(
function (acc, { sourceSiteId, destinationSiteId, linkCost }) {
(acc[sourceSiteId] = acc[sourceSiteId] || []).push({ targetId: destinationSiteId, linkCost });

return acc;
},
{} as Record<string, { targetId: string; linkCost: number }[]>
);
console.log('linkCost', linksExtended);
// Map <source site Id: destination site Id> to assign to each site the sited Ids linked with him (destinations)
// the source is the site who created the link
// we track and keep only the link with the cost != undefined
const linksExtendedMap = linksExtended.reduce(
function (acc, { sourceSiteId, destinationSiteId, linkCost }) {
const existingLink = (acc[sourceSiteId] || []).find((link) => link.targetId === destinationSiteId);

if (
!existingLink ||
(existingLink.linkCost !== undefined && linkCost !== undefined && linkCost > existingLink.linkCost)
) {
acc[sourceSiteId] = acc[sourceSiteId] || [];
acc[sourceSiteId].push({ targetId: destinationSiteId, linkCost });
} else if (existingLink && existingLink.linkCost === undefined) {
existingLink.linkCost = linkCost;
}

return acc;
},
{} as Record<string, { targetId: string; linkCost: number }[]>
);

return sites.map((site) => ({
...site,
Expand Down
116 changes: 58 additions & 58 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2086,32 +2086,32 @@
dependencies:
"@types/node" "*"

"@typescript-eslint/eslint-plugin@^6.13.1":
version "6.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.13.1.tgz#f98bd887bf95551203c917e734d113bf8d527a0c"
integrity sha512-5bQDGkXaxD46bPvQt08BUz9YSaO4S0fB1LB5JHQuXTfkGPI3+UUeS387C/e9jRie5GqT8u5kFTrMvAjtX4O5kA==
"@typescript-eslint/eslint-plugin@^6.13.2":
version "6.13.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.13.2.tgz#2e03506c5362a65e43cb132c37c9ce2d3cb51470"
integrity sha512-3+9OGAWHhk4O1LlcwLBONbdXsAhLjyCFogJY/cWy2lxdVJ2JrcTF2pTGMaLl2AE7U1l31n8Py4a8bx5DLf/0dQ==
dependencies:
"@eslint-community/regexpp" "^4.5.1"
"@typescript-eslint/scope-manager" "6.13.1"
"@typescript-eslint/type-utils" "6.13.1"
"@typescript-eslint/utils" "6.13.1"
"@typescript-eslint/visitor-keys" "6.13.1"
"@typescript-eslint/scope-manager" "6.13.2"
"@typescript-eslint/type-utils" "6.13.2"
"@typescript-eslint/utils" "6.13.2"
"@typescript-eslint/visitor-keys" "6.13.2"
debug "^4.3.4"
graphemer "^1.4.0"
ignore "^5.2.4"
natural-compare "^1.4.0"
semver "^7.5.4"
ts-api-utils "^1.0.1"

"@typescript-eslint/parser@^6.13.1":
version "6.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-6.13.1.tgz#29d6d4e5fab4669e58bc15f6904b67da65567487"
integrity sha512-fs2XOhWCzRhqMmQf0eicLa/CWSaYss2feXsy7xBD/pLyWke/jCIVc2s1ikEAtSW7ina1HNhv7kONoEfVNEcdDQ==
"@typescript-eslint/parser@^6.13.2":
version "6.13.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-6.13.2.tgz#390b79cc9a57a5f904d197a201cc4b6bc4f9afb9"
integrity sha512-MUkcC+7Wt/QOGeVlM8aGGJZy1XV5YKjTpq9jK6r6/iLsGXhBVaGP5N0UYvFsu9BFlSpwY9kMretzdBH01rkRXg==
dependencies:
"@typescript-eslint/scope-manager" "6.13.1"
"@typescript-eslint/types" "6.13.1"
"@typescript-eslint/typescript-estree" "6.13.1"
"@typescript-eslint/visitor-keys" "6.13.1"
"@typescript-eslint/scope-manager" "6.13.2"
"@typescript-eslint/types" "6.13.2"
"@typescript-eslint/typescript-estree" "6.13.2"
"@typescript-eslint/visitor-keys" "6.13.2"
debug "^4.3.4"

"@typescript-eslint/[email protected]":
Expand All @@ -2122,21 +2122,21 @@
"@typescript-eslint/types" "5.57.1"
"@typescript-eslint/visitor-keys" "5.57.1"

"@typescript-eslint/[email protected].1":
version "6.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.13.1.tgz#58c7c37c6a957d3d9f59bc4f64c2888e0cac1d70"
integrity sha512-BW0kJ7ceiKi56GbT2KKzZzN+nDxzQK2DS6x0PiSMPjciPgd/JRQGMibyaN2cPt2cAvuoH0oNvn2fwonHI+4QUQ==
"@typescript-eslint/[email protected].2":
version "6.13.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.13.2.tgz#5fa4e4adace028dafac212c770640b94e7b61052"
integrity sha512-CXQA0xo7z6x13FeDYCgBkjWzNqzBn8RXaE3QVQVIUm74fWJLkJkaHmHdKStrxQllGh6Q4eUGyNpMe0b1hMkXFA==
dependencies:
"@typescript-eslint/types" "6.13.1"
"@typescript-eslint/visitor-keys" "6.13.1"
"@typescript-eslint/types" "6.13.2"
"@typescript-eslint/visitor-keys" "6.13.2"

"@typescript-eslint/[email protected].1":
version "6.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.13.1.tgz#e6e5885e387841cae9c38fc0638fd8b7561973d6"
integrity sha512-A2qPlgpxx2v//3meMqQyB1qqTg1h1dJvzca7TugM3Yc2USDY+fsRBiojAEo92HO7f5hW5mjAUF6qobOPzlBCBQ==
"@typescript-eslint/[email protected].2":
version "6.13.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.13.2.tgz#ebec2da14a6bb7122e0fd31eea72a382c39c6102"
integrity sha512-Qr6ssS1GFongzH2qfnWKkAQmMUyZSyOr0W54nZNU1MDfo+U4Mv3XveeLZzadc/yq8iYhQZHYT+eoXJqnACM1tw==
dependencies:
"@typescript-eslint/typescript-estree" "6.13.1"
"@typescript-eslint/utils" "6.13.1"
"@typescript-eslint/typescript-estree" "6.13.2"
"@typescript-eslint/utils" "6.13.2"
debug "^4.3.4"
ts-api-utils "^1.0.1"

Expand All @@ -2145,10 +2145,10 @@
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.57.1.tgz#d9989c7a9025897ea6f0550b7036027f69e8a603"
integrity sha512-bSs4LOgyV3bJ08F5RDqO2KXqg3WAdwHCu06zOqcQ6vqbTJizyBhuh1o1ImC69X4bV2g1OJxbH71PJqiO7Y1RuA==

"@typescript-eslint/[email protected].1":
version "6.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.13.1.tgz#b56f26130e7eb8fa1e429c75fb969cae6ad7bb5c"
integrity sha512-gjeEskSmiEKKFIbnhDXUyiqVma1gRCQNbVZ1C8q7Zjcxh3WZMbzWVfGE9rHfWd1msQtPS0BVD9Jz9jded44eKg==
"@typescript-eslint/[email protected].2":
version "6.13.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.13.2.tgz#c044aac24c2f6cefb8e921e397acad5417dd0ae6"
integrity sha512-7sxbQ+EMRubQc3wTfTsycgYpSujyVbI1xw+3UMRUcrhSy+pN09y/lWzeKDbvhoqcRbHdc+APLs/PWYi/cisLPg==

"@typescript-eslint/[email protected]":
version "5.57.1"
Expand All @@ -2163,30 +2163,30 @@
semver "^7.3.7"
tsutils "^3.21.0"

"@typescript-eslint/[email protected].1":
version "6.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.13.1.tgz#d01dda78d2487434d1c503853fa00291c566efa4"
integrity sha512-sBLQsvOC0Q7LGcUHO5qpG1HxRgePbT6wwqOiGLpR8uOJvPJbfs0mW3jPA3ujsDvfiVwVlWUDESNXv44KtINkUQ==
"@typescript-eslint/[email protected].2":
version "6.13.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.13.2.tgz#ae556ee154c1acf025b48d37c3ef95a1d55da258"
integrity sha512-SuD8YLQv6WHnOEtKv8D6HZUzOub855cfPnPMKvdM/Bh1plv1f7Q/0iFUDLKKlxHcEstQnaUU4QZskgQq74t+3w==
dependencies:
"@typescript-eslint/types" "6.13.1"
"@typescript-eslint/visitor-keys" "6.13.1"
"@typescript-eslint/types" "6.13.2"
"@typescript-eslint/visitor-keys" "6.13.2"
debug "^4.3.4"
globby "^11.1.0"
is-glob "^4.0.3"
semver "^7.5.4"
ts-api-utils "^1.0.1"

"@typescript-eslint/[email protected].1":
version "6.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.13.1.tgz#925b3a2453a71ada914ae329b7bb7e7d96634b2f"
integrity sha512-ouPn/zVoan92JgAegesTXDB/oUp6BP1v8WpfYcqh649ejNc9Qv+B4FF2Ff626kO1xg0wWwwG48lAJ4JuesgdOw==
"@typescript-eslint/[email protected].2":
version "6.13.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.13.2.tgz#8eb89e53adc6d703a879b131e528807245486f89"
integrity sha512-b9Ptq4eAZUym4idijCRzl61oPCwwREcfDI8xGk751Vhzig5fFZR9CyzDz4Sp/nxSLBYxUPyh4QdIDqWykFhNmQ==
dependencies:
"@eslint-community/eslint-utils" "^4.4.0"
"@types/json-schema" "^7.0.12"
"@types/semver" "^7.5.0"
"@typescript-eslint/scope-manager" "6.13.1"
"@typescript-eslint/types" "6.13.1"
"@typescript-eslint/typescript-estree" "6.13.1"
"@typescript-eslint/scope-manager" "6.13.2"
"@typescript-eslint/types" "6.13.2"
"@typescript-eslint/typescript-estree" "6.13.2"
semver "^7.5.4"

"@typescript-eslint/utils@^5.10.0":
Expand All @@ -2211,12 +2211,12 @@
"@typescript-eslint/types" "5.57.1"
eslint-visitor-keys "^3.3.0"

"@typescript-eslint/[email protected].1":
version "6.13.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.13.1.tgz#c4b692dcc23a4fc60685b718f10fde789d65a540"
integrity sha512-NDhQUy2tg6XGNBGDRm1XybOHSia8mcXmlbKWoQP+nm1BIIMxa55shyJfZkHpEBN62KNPLrocSM2PdPcaLgDKMQ==
"@typescript-eslint/[email protected].2":
version "6.13.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.13.2.tgz#e0a4a80cf842bb08e6127b903284166ac4a5594c"
integrity sha512-OGznFs0eAQXJsp+xSd6k/O1UbFi/K/L7WjqeRoFE7vadjAF9y0uppXhYNQNEqygjou782maGClOoZwPqF0Drlw==
dependencies:
"@typescript-eslint/types" "6.13.1"
"@typescript-eslint/types" "6.13.2"
eslint-visitor-keys "^3.4.1"

"@ungap/structured-clone@^1.2.0":
Expand Down Expand Up @@ -3683,10 +3683,10 @@ csstype@^3.0.2, csstype@^3.0.8:
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.2.tgz#1d4bf9d572f11c14031f0436e1c10bc1f571f50b"
integrity sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==

cypress@^13.6.0:
version "13.6.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.6.0.tgz#b98b7b837679012ed09c7ecee5565bf7b31d4982"
integrity sha512-quIsnFmtj4dBUEJYU4OH0H12bABJpSujvWexC24Ju1gTlKMJbeT6tTO0vh7WNfiBPPjoIXLN+OUqVtiKFs6SGw==
cypress@^13.6.1:
version "13.6.1"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.6.1.tgz#c5f714f08551666ed3ac1fa95718eabb23a416df"
integrity sha512-k1Wl5PQcA/4UoTffYKKaxA0FJKwg8yenYNYRzLt11CUR0Kln+h7Udne6mdU1cUIdXBDTVZWtmiUjzqGs7/pEpw==
dependencies:
"@cypress/request" "^3.0.0"
"@cypress/xvfb" "^1.2.4"
Expand Down Expand Up @@ -5227,10 +5227,10 @@ [email protected]:
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811"
integrity sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==

framer-motion@^10.16.12:
version "10.16.12"
resolved "https://registry.yarnpkg.com/framer-motion/-/framer-motion-10.16.12.tgz#8aca3ffa4801953dd873de422a3c1f78b2aa7bfa"
integrity sha512-w7Yzx0OzQ5Uh6uNkxaX+4TuAPuOKz3haSbjmHpdrqDpGuCJCpq6YP9Dy7JJWdZ6mJjndrg3Ao3vUwDajKNikCA==
framer-motion@^10.16.14:
version "10.16.14"
resolved "https://registry.yarnpkg.com/framer-motion/-/framer-motion-10.16.14.tgz#77099f7e8d949dc68f9aea1497eda06f2454e6b2"
integrity sha512-poovsXtR7doXRfjqVjUai82Zl2z5yMUFKtYWHnQK+xsDVPhHVUJEU+Kr2kqEnUV4gry+LcRdrDzcMI7OdJlDMg==
dependencies:
tslib "^2.4.0"
optionalDependencies:
Expand Down

0 comments on commit 7389df2

Please sign in to comment.