ULOG #15: Utopian V2 Contribution - Adding Work Experience to User Profile
ulog·@eastmael·
0.000 HBDULOG #15: Utopian V2 Contribution - Adding Work Experience to User Profile
 This is my second contribution to Utopian V2. Although it took more time than I expected, my PR was finally merged and closed. ### Repository https://github.com/utopian-io/v2.utopian.io #### Task Request https://steemit.com/utopian-io/@gregory.latinier/utopian-v2-task-profile-module-work-experiences #### Pull Request https://github.com/utopian-io/v2.utopian.io/pull/218 #### Feature  There are two parts to this post. First is a run-through of my [commits history](https://github.com/utopian-io/v2.utopian.io/pull/218/commits) and the second is some technical explanation of the codes. #### Commits History > There's a story behind every code. The major parts in my [commits history](https://github.com/utopian-io/v2.utopian.io/pull/218/commits) were: * [1794f2f](https://github.com/utopian-io/v2.utopian.io/pull/218/commits/1794f2fcd2b34f3603c83e59e44c758d59ebcdda) - provided the skeleton - the layout - where I did my changes. * [101a243](https://github.com/utopian-io/v2.utopian.io/pull/218/commits/101a243ea110c2accd75717c7ad68224ad50038f) - added the work experience fields to the user model (to persist the user information). * [e3e52e7](https://github.com/utopian-io/v2.utopian.io/pull/218/commits/e3e52e770c342d7baefebc7f82ad96ff6dcebf29) - updated the work experience layout * [e97b2d5](https://github.com/utopian-io/v2.utopian.io/pull/218/commits/e97b2d573d6bf0fa8387e182d485b8264fdfdd58) - added the work experience API end points * [db1fb3c](https://github.com/utopian-io/v2.utopian.io/pull/218/commits/db1fb3c20a768885a00a24c8d441276479cd4122) - code refactor * [8cb2742](https://github.com/utopian-io/v2.utopian.io/pull/218/commits/8cb27427f698ef9435500e4142514fb31598dbc7) - added delete experience function * [f98fcb3](https://github.com/utopian-io/v2.utopian.io/pull/218/commits/f98fcb3a773a6904ada61cd2c510a30b97d20220) - exported strings to i18n * [4362837](https://github.com/utopian-io/v2.utopian.io/pull/218/commits/4362837044778bb0254d50f922636177346c1a88) - added validations * [f811680](https://github.com/utopian-io/v2.utopian.io/pull/218/commits/f81168081c642c25fd8b95131e708a8531b08249) - added unit tests * [8df58af](https://github.com/utopian-io/v2.utopian.io/pull/218/commits/8df58af2e33ad81fede2107ad50105a1fec56bbd) - sort experiences from most recent to oldest #### Code Changes https://github.com/utopian-io/v2.utopian.io/pull/218/files ##### 1. API ###### 1a. Main Codes * [`packages/api/modules/users/handlers.js`](https://github.com/utopian-io/v2.utopian.io/pull/218/files#diff-d6583c66110f65c2d8b692c224edbd6f) - these were the API endpoints - the methods that directly interacted with the database * [`/packages/api/modules/users/routes.js`](https://github.com/utopian-io/v2.utopian.io/pull/218/files#diff-296ff5718c5428b25ef5fbf77616dacc) - the routes that maps the above functions to URLs * [`/packages/api/modules/users/user.model.js`](https://github.com/utopian-io/v2.utopian.io/pull/218/files#diff-8cfc9557e458a102c58649686a2b0021) - the user model; change in the user model class to include work experiences information (called subdocument in mongo) * [`/packages/api/modules/users/validate.js`](https://github.com/utopian-io/v2.utopian.io/pull/218/files#diff-cc394e8abc54ccb6d71e7173d3a122ad) - as what can be inferred from the name, model validation ###### 1b. Unit Tests * [`/packages/api/test/fixtures/users.js`](https://github.com/utopian-io/v2.utopian.io/pull/218/files#diff-78a082d9fdb3e66d3acd3adf318b0789) - test data * [`/packages/api/test/modules/users/users.handlers.spec.js`](https://github.com/utopian-io/v2.utopian.io/pull/218/files#diff-ee6149cc2f02eb780239edf3de3b3a56) - the specs that test the newly added API end points ##### 2. Client * [`/packages/client/src/pages/users/profile/profile.vue`](https://github.com/utopian-io/v2.utopian.io/pull/218/files#diff-ce5c3585f3376714a1812bc0c8ff7a7c) - the main profile page; the major component where the important codes were included * [`/packages/client/src/store/users/actions.js`](https://github.com/utopian-io/v2.utopian.io/pull/218/files#diff-77c4b16544cd36d583b4d2a2b5088517) - the user actions that dispatches or calls the necessary API end points to process user information ##### 3. Internationalization * [`/packages/i18n/locales_master/en.json`](https://github.com/utopian-io/v2.utopian.io/pull/218/files#diff-0d6c63c97dfee46e060dd990ad73488f) - exported strings for internationalization #### Lessons Learned I encountered a lot of challenges in completing this task. First, was my unfamiliarity with mongo API. Although I had an idea in mind of what I wanted to happen, my unfamiliarity with mongoose resulted in code smell. Gregory cleaned that up for me by what he did in his last commit: * [a9c1067](https://github.com/utopian-io/v2.utopian.io/pull/218/commits/a9c1067c72b5a87fb17f5c994e251bc5e63c39af) He removed the `getWorkExperience` API end point and just returned the whole work experiences document to `updateWorkExperience`'s response. The key mongoose method here was `findOneAndUpdate`. The second challenge was my unfamiliarity with flex-box. Gregory just pointed me to use that to adjust the location of the plus icon. And lastly was my unfamiliarity with [vuelidate](https://monterail.github.io/vuelidate/), this resulted again in code smell and I learned again from the codes committed by Gregory. There were other changes made by Gregory in that commit. All of them were learnings for me.<br/><div class="pull-right promo"><sub><p>This post was made from https://ulogs.org</p></sub></div>
👍 steeming-hot, adimantong, steemscan, steemexpress, stmpay, bluesniper, changjia, kehuanmi, jailueroterg, allisonab, amosbastian, hebetseves, diformadoc, nicoleevdi1, zoe69, kylieg0, siwalansand, gloscincenttemp, compmilkcogpock, isabellaf, crokkon, savannaha2, espoem, jaff8, asaj, ascorphat, codingdefined, mops2e, nieloagranca, merlin7, abh12345, j-alhomestudio, steemchoose, beautifuldata, valiantheart, paulag, mcfarhat, zcool, revisesociology, teamcr, steemitdoctor, steemph.manila, annazsarinacruz, rye05, zeddjacob, st3llar, rt395, topbro, east.autovote, steemitph, alliruiz, jeandesss, bearone, lionlook, dominiqueruiz, haiyangdeperci, sechki, onex8, wendyruiz, isaganicabrales, delta523, gieaspa, imayang, xtrm111, colettemaria, joshruiz, ellerysunga, ohmyjosh, ladyselene07, pinkblush, foxniner, josebravopalomo, reyleedwalo, andreapacoy, phage93, eastmael, yehey, miniature-tiger, loshcat, greenorange, holger80, scipio, steemitri, mercadosaway, viperblckz, luc.real, blazing, vallesleoruther, curbot, someaddons, knowledges, piaristmonk, bachuslib, steembasicincome, paulnulty, clayjohn, verifyme, steemconductor, helo, steem-ua, newsrx, jjay, ryuna.siege, tdre, scienceangel, utopian-io, tombstone, jga, kaczynski, szabolcs, metehn, surpassinggoogle, goode, southparkqueen, ranielbrianulan, baboyed1000, mahmuddin, tradeownsystems, nessyquel, princekelly, davealemana, kerry234, ekjosh, berylwills, asfuriah, camilus, jims, thamrin, jefry113, mhel, karyah1001, pipo092281, harkushi, goalgetter, layanmarissa, strings, richgang, ligarayk, babaj, loydjayme25, kul0tzzz, rheyss08, julianalpanta, sissyjill, dzued, jacintoelbarouki, morbyjohn, aldiyani, zombieslayer, khloyd, akaikeru, jeanp, donjyde, faisal08, dexter24, wirdayulahya, khairuddin08, dondondamayo, smafey, penantang, parag, muksalbaihaqi, estrellamag, zohaib715, klizo, enjoyy, jecren, pauloliverpino, allaboutme, basir92, annamighty, atjehsteemit, pojgaerlan, freudy, beni96, theunlimited, queenlyka, fibrefox, belvajarandilla, muzaiyan, mercy11, masud222, hasan086, handfree42, levinvillas, chiboyzz, starzy, mcamayra, monwalker, rhei86, toyosiartdiy, jayo, mikemaphu, rechellomataro, blackelephant, arcange, elbleess, kofspades, bobtucks, ryl, antigenx, lstriker, shahaan, bittrex12, wandy01, bravofer, lykia, mayorhero, jaber-hossain70, morin89, purepinoy, bobiecayao, modernmclaire, used-lessboy, victoriakorol, new.diak, mbahtutorial, sabiondico, kaplat, gerliepepito, etaletai, techsfair, geotorb, gpwebers, kumagang, olayemzeecool, hasim5164, amarm, cheesom, matadonis, virgo27, muzzlealem, devangbuch, brewingstories, paulasands, ahmad097, ernoldlvb, alimirza0416, gnaimul, chiqui03, ahsanabdullah, akeenze13, mittalamit284, marzuki-r, christinevelasco, liquidpoopcorn, whyken, cebusteemer, jezelle, femidada, jgpro, dwightjaden, emdesan, mkmk, bitcoin.news, breezieblack, noechie1827, sampath94, vlogger56, dtube-alfa, chrisjayl, dazzy, kelvo, leeyen23, aikee, emeliveiga, akram7, mojacko, devondrjackson, pharao20, briandominise, rarcenal, galihtruff, mvoalevine, pinkyangel, lotfiuser, pipks, rishadhaque, sunnylife, advsamadhan, camillius, fadiji09, hokulor, fredoski, alex04, mutiarahmi, neilrichmond, greenville, beshooo, sharminwadud, joco0820, roheemat, jembee, kyanzieuno, daldon, noodles09, sirwayneweezy, osky, mrwang, gps7530, haji, adnanbtc, evolutionnow, kike313, paragon99, iamfo, princefizzy, phoebedoll, afefe, arrahman90, jsantos17, sazid36, gemz2inspire, mayib, tammydixon, golden-man, boyaceh, ninihorlah, cebuana, nicole24, pasokon, dantoyin, bradondamyx12345, wanderinglynelle, freitzie123, bloghound, pjmisa, pboss123, vegasgambler, syamsudduha2, polycarpedet, rikilb, muhammad.iqbal, jomar07, membee, mikeyurnero, erebuta01, mindbuilder-sc, kayegrasya, elvinjohn21, david9122, r5yn1r4, jackbawa, denkeicui, naayren, glendale05, citysitebuilders, medyomaldita, caroljayne02, lemcervantes, unika-ejes, ljpaez, moksamol, shippou95, viralfever, hrovat66, dolphinscute, eruditescholar1, benjaspa, ninjarobo, jeef-zone, lianbloog, egheprincez, steemitkyle, osakuni, bertoandes, jumpnrun, samsonite18654, joseaybar1, skyphotographer, foley, ak477, dong-a, gelique, swapsteem, crystaljonah1, saifulhuri, pes7md, jhanmervz, ckbahdon, preetisingh1993, fidel66, tomatom, loudetteiam, cradle, ilmondoditea, blessedsteemer, byash, vicmic, mrnightmare89, adebits, lemareg, maintang03, sadnesscarl, rizzybear, pandina, princezakir, alatomz, hmuajanice, dreamseller, foways, mzajoke, mrogy1, jjohnson78, nigerian-yogagal, jayboi, randomkindness, gio.vanne, scottallen, ramonjvp, idiongo, choobymaverick, rajesh1000, dktrending341, rawpostblog, antisocialian, sid000, pemburubitcoin, shahidullah832, minnowwboster, forhadh, semtroneum, alom8, naveedakhtar6283, holatati, rajaumer837, bluebella, yahman, marzukie, superstar65, pahrtenope, abrahamcera, steem-factuals, martzpro, rachelleignacio, genesis171, annnaa, alchemylgc, alexander-bobs, carolinafer, angoujkalis, jakedavis224, jeongji, ancgci, chriswilson, kirstenboic, qusain, onire19, lvpjulio, greatlord, drbtc, writeandearn, amanpathak, engineeringfeed, maticpecovnik, thienduc, kutrulaju, patchnotes, rakan-sikula, mikael19, studytext, raphaelle, tony-duke, umut1905, shiddiq, razik9708, shiddiq000, kawan-baru, shiddiqmjmr, k-syusteem, fikar22, elangzone, fadliloways, iamwhatiamnot, alien-mastermind, jayfamous, faithvarron, eightbitfiction, mirna98, stuckinacup, arisviyo, ihal0001, outerground, oclinton, cypher01, lakawero, ingpablojosue, pichat, cmbugua, wealth4good, filzaart, samdman, iswanisamion, abysoyjoy, husana, midary, sm-cards, rival, tolarnee, steemdragon, zeshanjaved, rosenderevies, rigelmarco, letzsteem, eurogee, eduardonarvaez, aehiguese, lifediaries2nd, reungkhoem, carloniere, marysent, hillaryaa, onin91, luijii, lykaypajaro, isaaceko, nanwaiwaimyint, sukro, tentalavera, cordeta, raquelita, badzkie123, orhem, gwapoaller, khat.holanda23, bgmuna, keybordjp, steeman220, jacobzeema, bumut, chinwengozi, friskykitty, bitmycoin, syawalkoki, nantzjbalayo, viralz, mwamin7, steinz, sojol527, eternalsuccess, everydaybitcoin, blaqboyikott, periods, circa,