From 63e95207bb9fbd43d83593e837b4b441b61382d0 Mon Sep 17 00:00:00 2001 From: samuelssan <85943933+samuelssan28ic@users.noreply.github.com> Date: Sat, 19 Jun 2021 18:38:27 -0300 Subject: [PATCH 1/2] desenvolvendo issue #63 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rota de criação/atualização de código de associação Fix bug na entidade de profissional --- .../src/controllers/ProfessionalController.ts | 28 +++++++++++++++ backend/src/entities/Professional.ts | 3 -- backend/src/routes.ts | 5 +++ backend/src/services/ProfessionalService.ts | 34 +++++++++++++++++++ 4 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 backend/src/controllers/ProfessionalController.ts create mode 100644 backend/src/services/ProfessionalService.ts diff --git a/backend/src/controllers/ProfessionalController.ts b/backend/src/controllers/ProfessionalController.ts new file mode 100644 index 0000000..70be68a --- /dev/null +++ b/backend/src/controllers/ProfessionalController.ts @@ -0,0 +1,28 @@ +import {Request,Response} from 'express' +import { ProfessionalService } from '../services/ProfessionalService'; + +class ProfessionalController{ + + async update_association_code(request:Request,response:Response):Promise{ + try { + const {professional_id,new_association_code} = request.params; + + const provessionalService = new ProfessionalService(); + + const updateSucess = await provessionalService.updateAssociationCode(professional_id,new_association_code); + + return response.json({sucess:updateSucess}) + + } catch (error) { + return response.status(400).json({ erro:error }) + } + + } + + + + + +} + +export {ProfessionalController} \ No newline at end of file diff --git a/backend/src/entities/Professional.ts b/backend/src/entities/Professional.ts index 3849193..0a1c71f 100644 --- a/backend/src/entities/Professional.ts +++ b/backend/src/entities/Professional.ts @@ -10,9 +10,6 @@ import { Client } from './Client'; @Column() name:string; - @Column() - email:string; - @Column() speciality:string; diff --git a/backend/src/routes.ts b/backend/src/routes.ts index bc1ce65..c7ff4c6 100644 --- a/backend/src/routes.ts +++ b/backend/src/routes.ts @@ -1,8 +1,10 @@ import {Router} from 'express'; import { EmotionalReactionController } from './controllers/EmotionalRecordController'; +import { ProfessionalController } from './controllers/ProfessionalController'; const routes = Router(); const emotionalReactionController = new EmotionalReactionController(); +const professionalController = new ProfessionalController(); routes.get("/reactions/:client_id",emotionalReactionController.index); @@ -10,4 +12,7 @@ routes.get("/reactions/:client_id",emotionalReactionController.index); routes.delete("/reactions/:client_id/:emotional_reaction_id",emotionalReactionController.destroy); +routes.put("/update/:professional_id/:new_association_code",professionalController.update_association_code); + + export {routes} \ No newline at end of file diff --git a/backend/src/services/ProfessionalService.ts b/backend/src/services/ProfessionalService.ts new file mode 100644 index 0000000..aee4783 --- /dev/null +++ b/backend/src/services/ProfessionalService.ts @@ -0,0 +1,34 @@ +import { getRepository, Repository } from 'typeorm'; +import { Professional } from '../entities/Professional'; + +class ProfessionalService{ + private professionalRepository:Repository; + + constructor(){ + this.professionalRepository = getRepository(Professional); + } + + async updateAssociationCode(professional_id:string,new_code:string):Promise{ + const professional = await this.professionalRepository.findOneOrFail({ where:{id:professional_id} }); + const professional_with_code_repeated = await this.professionalRepository.findOne({ where:{association_code:new_code} }); + + if(professional_with_code_repeated){ + professional_with_code_repeated.association_code = ""; + this.professionalRepository.save(professional_with_code_repeated); + } + + professional.association_code = new_code; + + this.professionalRepository.save(professional) + + return true; + } + + + + + +} + +export {ProfessionalService} + From 83fcfba6fe0b11cf84c7352383894fddd3368c44 Mon Sep 17 00:00:00 2001 From: samuelssan <85943933+samuelssan28ic@users.noreply.github.com> Date: Sat, 19 Jun 2021 18:39:08 -0300 Subject: [PATCH 2/2] desenvolvendo issue #59 --- frontend/src/views/RecordsList/index.tsx | 17 ++-- frontend/yarn.lock | 119 +++++++++++++++++++++-- 2 files changed, 122 insertions(+), 14 deletions(-) diff --git a/frontend/src/views/RecordsList/index.tsx b/frontend/src/views/RecordsList/index.tsx index 5bb1966..2583383 100644 --- a/frontend/src/views/RecordsList/index.tsx +++ b/frontend/src/views/RecordsList/index.tsx @@ -63,18 +63,21 @@ export default function RecordsList() { }, []) - function handleDelete(){ - //fazer requisicao para deletar then + async function handleDelete(){ + + await api.delete(`/reactions/${client_id}/${idCurrent}`) + .then(()=>{ + const filteredRecord = records?.filter((record) => record.id != idCurrent ); + setRecords(filteredRecord); + setIdCurrent(""); + setModalIsVisible(false) + }) - const filteredRecord = records?.filter((record) => record.id != idCurrent ); - setRecords(filteredRecord); - setIdCurrent(""); - setModalIsVisible(false) } function onPressDelete(id:string){ setIdCurrent(id); - setModalIsVisible(true) + setModalIsVisible(true); } function onPressCard(){ diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 6594b0f..5e3d90c 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -256,6 +256,11 @@ resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.13.0.tgz#806526ce125aed03373bc416a828321e3a6a33af" integrity sha512-ZPafIPSwzUlAoWT8DKs1W2VyF2gOWthGd5NGFMsBcMMol+ZhK+EQY/e6V96poa6PA/Bh+C9plWN0hXO1uB8AfQ== +"@babel/helper-plugin-utils@^7.14.5": + version "7.14.5" + resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.14.5.tgz#5ac822ce97eec46741ab70a517971e443a70c5a9" + integrity sha512-/37qQCE3K0vvZKwoK4XU/irIJQdIfCJuhU5eKnNxpFDsOkgFaUAwbv+RYw6eYgsC0E4hS7r5KqGULUogqui0fQ== + "@babel/helper-remap-async-to-generator@^7.13.0": version "7.13.0" resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.13.0.tgz#376a760d9f7b4b2077a9dd05aa9c3927cadb2209" @@ -843,6 +848,13 @@ dependencies: "@babel/helper-plugin-utils" "^7.12.13" +"@babel/plugin-transform-object-assign@^7.10.4": + version "7.14.5" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-assign/-/plugin-transform-object-assign-7.14.5.tgz#62537d54b6d85de04f4df48bfdba2eebff17b760" + integrity sha512-lvhjk4UN9xJJYB1mI5KC0/o1D5EcJXdbhVe+4fSk08D6ZN+iuAIs7LJC+71h8av9Ew4+uRq9452v9R93SFmQlQ== + dependencies: + "@babel/helper-plugin-utils" "^7.14.5" + "@babel/plugin-transform-object-super@^7.0.0", "@babel/plugin-transform-object-super@^7.12.13": version "7.12.13" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.12.13.tgz#b4416a2d63b8f7be314f3d349bd55a9c1b5171f7" @@ -1251,6 +1263,13 @@ exec-sh "^0.3.2" minimist "^1.2.0" +"@egjs/hammerjs@^2.0.17": + version "2.0.17" + resolved "https://registry.yarnpkg.com/@egjs/hammerjs/-/hammerjs-2.0.17.tgz#5dc02af75a6a06e4c2db0202cae38c9263895124" + integrity sha512-XQsZgjm2EcVUiZQf11UBJQfmZeEmOW8DpI1gsFeln6w0ae0ii4dMQEQ0kjl6DspdWX1aGY1/loyXnP0JS06e/A== + dependencies: + "@types/hammerjs" "^2.0.36" + "@emotion/is-prop-valid@^0.8.8": version "0.8.8" resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-0.8.8.tgz#db28b1c4368a259b60a97311d6a952d4fd01ac1a" @@ -1832,6 +1851,11 @@ dependencies: deep-assign "^3.0.0" +"@react-native-community/checkbox@^0.5.8": + version "0.5.8" + resolved "https://registry.yarnpkg.com/@react-native-community/checkbox/-/checkbox-0.5.8.tgz#a1b50635fd76a07fb53eb4a98120347cb6e75da4" + integrity sha512-2ppw40sSqBKSPz75l8rDCvpcvQb/78MtvB5BDtovsJE1kXoUJP4eVLuyLo+LfYdSK9qLD4Llt4bIulr1SI9UIQ== + "@react-native-community/cli-debugger-ui@^4.13.1": version "4.13.1" resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-4.13.1.tgz#07de6d4dab80ec49231de1f1fbf658b4ad39b32c" @@ -1952,6 +1976,11 @@ sudo-prompt "^9.0.0" wcwidth "^1.0.1" +"@react-native-community/masked-view@^0.1.11": + version "0.1.11" + resolved "https://registry.yarnpkg.com/@react-native-community/masked-view/-/masked-view-0.1.11.tgz#2f4c6e10bee0786abff4604e39a37ded6f3980ce" + integrity sha512-rQfMIGSR/1r/SyN87+VD8xHHzDYeHaJq6elOSCAD+0iLagXkSI2pfA0LmSXP21uw5i3em7GkkRjfJ8wpqWXZNw== + "@react-navigation/core@^5.15.3": version "5.15.3" resolved "https://registry.yarnpkg.com/@react-navigation/core/-/core-5.15.3.tgz#dce7090bf3ea0d302993d742c706825e495b812e" @@ -1984,6 +2013,19 @@ dependencies: nanoid "^3.1.15" +"@react-navigation/stack@^5.14.5": + version "5.14.5" + resolved "https://registry.yarnpkg.com/@react-navigation/stack/-/stack-5.14.5.tgz#dc615cd7d270ba79e3330dcb50c2819d0e1f3850" + integrity sha512-hpdn1SS0tc3/3atkV2Q2y++n5B4e0rUcCj4W43PODMu72yX2m0LkKAAcpkPDCWAvwnLLIoLAEl5BEifZigl/6A== + dependencies: + color "^3.1.3" + react-native-iphone-x-helper "^1.3.0" + +"@types/hammerjs@^2.0.36": + version "2.0.39" + resolved "https://registry.yarnpkg.com/@types/hammerjs/-/hammerjs-2.0.39.tgz#4be64bbacf3813c79c0dab895c6b0fdc7d5e513f" + integrity sha512-lYR2Y/tV2ujpk/WyUc7S0VLI0a9hrtVIN9EwnrNo5oSEJI2cK2/XrgwOQmXLL3eTulOESvh9qP6si9+DWM9cOA== + "@types/hoist-non-react-statics@*", "@types/hoist-non-react-statics@^3.3.0": version "3.3.1" resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz#1124aafe5118cb591977aeb1ceaaed1070eb039f" @@ -2832,7 +2874,7 @@ color-support@^1.1.3: resolved "https://registry.yarnpkg.com/color-support/-/color-support-1.1.3.tgz#93834379a1cc9a0c61f82f52f0d04322251bd5a2" integrity sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg== -color@^3.1.2: +color@^3.1.2, color@^3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/color/-/color-3.1.3.tgz#ca67fb4e7b97d611dcde39eceed422067d91596e" integrity sha512-xgXAcTHa2HeFCGLE9Xs/R82hujGtu9Jd9x4NW3T34+OMs7VoPsjwzRczKHvTAHeJwWFwX5j15+MgAppE8ztObQ== @@ -2978,6 +3020,13 @@ create-react-class@^15.6.2: loose-envify "^1.3.1" object-assign "^4.1.1" +cross-fetch@^3.0.4: + version "3.1.4" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.4.tgz#9723f3a3a247bf8b89039f3a380a9244e8fa2f39" + integrity sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ== + dependencies: + node-fetch "2.6.1" + cross-spawn@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" @@ -3477,6 +3526,19 @@ fbjs@^1.0.0: setimmediate "^1.0.5" ua-parser-js "^0.7.18" +fbjs@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-3.0.0.tgz#0907067fb3f57a78f45d95f1eacffcacd623c165" + integrity sha512-dJd4PiDOFuhe7vk4F80Mba83Vr2QuK86FoxtgPmzBqEJahncp+13YCmfoa53KHCo6OnlXLG7eeMWPfB5CrpVKg== + dependencies: + cross-fetch "^3.0.4" + fbjs-css-vars "^1.0.0" + loose-envify "^1.0.0" + object-assign "^4.1.0" + promise "^7.1.1" + setimmediate "^1.0.5" + ua-parser-js "^0.7.18" + figures@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" @@ -4806,6 +4868,11 @@ mkdirp@^0.5.1: dependencies: minimist "^1.2.5" +mockdate@^3.0.2: + version "3.0.5" + resolved "https://registry.yarnpkg.com/mockdate/-/mockdate-3.0.5.tgz#789be686deb3149e7df2b663d2bc4392bc3284fb" + integrity sha512-iniQP4rj1FhBdBYS/+eQv7j1tadJ9lJtdzgOpvsOHng/GbcDh2Fhdeq+ZRldrPYdXvCyfFUmFeEwEGXZB5I/AQ== + ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -4868,6 +4935,11 @@ nocache@^2.1.0: resolved "https://registry.yarnpkg.com/nocache/-/nocache-2.1.0.tgz#120c9ffec43b5729b1d5de88cd71aa75a0ba491f" integrity sha512-0L9FvHG3nfnnmaEQPjT9xhfN4ISk0A8/2j4M37Np4mcDesJjHgEUfgPhdCyZuFI954tjokaIj/A3NdpFNdEh4Q== +node-fetch@2.6.1, node-fetch@^2.2.0, node-fetch@^2.6.0: + version "2.6.1" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" + integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== + node-fetch@^1.0.1: version "1.7.3" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef" @@ -4876,11 +4948,6 @@ node-fetch@^1.0.1: encoding "^0.1.11" is-stream "^1.0.1" -node-fetch@^2.2.0, node-fetch@^2.6.0: - version "2.6.1" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" - integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== - node-int64@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" @@ -5387,7 +5454,18 @@ react-is@^17.0.1: resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== -react-native-iphone-x-helper@^1.3.1: +react-native-gesture-handler@^1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-1.10.3.tgz#942bbf2963bbf49fa79593600ee9d7b5dab3cfc0" + integrity sha512-cBGMi1IEsIVMgoox4RvMx7V2r6bNKw0uR1Mu1o7NbuHS6BRSVLq0dP34l2ecnPlC+jpWd3le6Yg1nrdCjby2Mw== + dependencies: + "@egjs/hammerjs" "^2.0.17" + fbjs "^3.0.0" + hoist-non-react-statics "^3.3.0" + invariant "^2.2.4" + prop-types "^15.7.2" + +react-native-iphone-x-helper@^1.3.0, react-native-iphone-x-helper@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/react-native-iphone-x-helper/-/react-native-iphone-x-helper-1.3.1.tgz#20c603e9a0e765fd6f97396638bdeb0e5a60b010" integrity sha512-HOf0jzRnq2/aFUcdCJ9w9JGzN3gdEg0zFE4FyYlp4jtidqU03D5X7ZegGKfT1EWteR0gPBGp9ye5T5FvSWi9Yg== @@ -5401,11 +5479,28 @@ react-native-paper@^4.9.1: color "^3.1.2" react-native-iphone-x-helper "^1.3.1" +react-native-reanimated@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-2.2.0.tgz#a6412c56b4e591d1f00fac949f62d0c72c357c78" + integrity sha512-lOJDd+5w1gY6DHGXG2jD1dsjzQmXQ2699HUc3IztvI2WP4zUT+UAA+zSG+5JiBS5DUnTL8YhhkmUQmr1KNGO5w== + dependencies: + "@babel/plugin-transform-object-assign" "^7.10.4" + fbjs "^3.0.0" + mockdate "^3.0.2" + string-hash-64 "^1.0.3" + react-native-safe-area-context@3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-3.2.0.tgz#06113c6b208f982d68ab5c3cebd199ca93db6941" integrity sha512-k2Nty4PwSnrg9HwrYeeE+EYqViYJoOFwEy9LxL5RIRfoqxAq/uQXNGwpUg2/u4gnKpBbEPa9eRh15KKMe/VHkA== +react-native-screens@^3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/react-native-screens/-/react-native-screens-3.4.0.tgz#91deeac7630db9f3984053e2ab146d71bba7af4e" + integrity sha512-cg+q9MRnVdeOcJyvJtqffoXLur/C2wHA/7IO2+FAipzTlgHbbM1mTuSM7qG+SeiQjoIs4mHOEf7A0ziPKW04sA== + dependencies: + warn-once "^0.1.0" + react-native-vector-icons@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/react-native-vector-icons/-/react-native-vector-icons-8.1.0.tgz#e8ee2b17bc4d9f636da1c6f67feee8e2a850c3d8" @@ -6025,6 +6120,11 @@ strict-uri-encode@^2.0.0: resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546" integrity sha1-ucczDHBChi9rFC3CdLvMWGbONUY= +string-hash-64@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/string-hash-64/-/string-hash-64-1.0.3.tgz#0deb56df58678640db5c479ccbbb597aaa0de322" + integrity sha512-D5OKWKvDhyVWWn2x5Y9b+37NUllks34q1dCDhk/vYcso9fmhs+Tl3KR/gE4v5UNj2UA35cnX4KdVVGkG1deKqw== + string-width@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" @@ -6403,6 +6503,11 @@ walker@^1.0.7, walker@~1.0.5: dependencies: makeerror "1.0.x" +warn-once@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/warn-once/-/warn-once-0.1.0.tgz#4f58d89b84f968d0389176aa99e0cf0f14ffd4c8" + integrity sha512-recZTSvuaH/On5ZU5ywq66y99lImWqzP93+AiUo9LUwG8gXHW+LJjhOd6REJHm7qb0niYqrEQJvbHSQfuJtTqA== + wcwidth@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8"