{"version":3,"sources":["webpack:///./scripts/components/myAwardsTable.js","webpack:///./scripts/helpers/ajaxTable.js"],"names":["component","setupAwardsEligibleTable","eligibleAwards","firstAwardFormatted","moment","DateIssued","format","upcomingAwardHtml","filter","award","map","item","Description","getUpcomingAward","join","$upcomingAwardsTable","find","html","momentModule","window","$myAwardsTable","$","length","userStateManager","getUserProfileData","data","isNullUndefinedEmpty","ProfileInfo","apiProblemOccured","parent","nextAll","remove","displayErrorMessage","Awards","fullListing","awardsData","AjaxTable","slice","css","display","EligibleAwards","$el","headers","this","$thead","$tbody","render","arrRow","value","headerRow","rows","getRow","error"],"mappings":"qTAKO,IAAMA,EAAS,e,EAAA,G,EAAA,yBAAG,uBA+CZC,EA/CY,uFA+CZA,EA/CY,SA+CaC,GAa9B,IAAMC,EAAsBC,OAAOF,EAAe,GAAGG,YAAYC,OAAO,cAKpEC,EAJkBL,EAAeM,QAAO,SAACC,GACzC,OAAON,IAAwBC,OAAOK,EAAMJ,YAAYC,OAAO,iBAG3BI,KAAI,SAACC,GAAD,OAd5C,SAA0BA,GACtB,8CAEDA,EAAKC,YAFJ,gCAGDR,OAAOO,EAAKN,YAAYC,OAAO,cAH9B,gCAakDO,CAAiBF,MAAOG,KAAK,IAEnFC,EAAqBC,KAAK,SAASC,KAAKV,IAnEvB,SACM,wDADN,OACfW,EADe,OAErBC,OAAOf,OAASc,EAAY,QAEtBE,EAAiBC,EAAE,oBACnBN,EAAuBM,EAAE,4BAE3BD,EAAeE,QACfC,IAAiBC,oBAAmB,SAAUC,GAC1C,IAAKC,YAAqBD,EAAKE,aAAc,CACzC,GAAIF,GAAQA,EAAKG,kBAIb,OAHAR,EAAeS,SAASC,QAAQ,gBAAgBC,SAChDhB,EAAqBgB,cACrBC,YAAoBZ,EAAeS,UAIvC,IAAKH,YAAqBD,EAAKE,YAAYM,QAAS,CAChD,IAAMC,EAAcd,EAAeK,KAAK,QAIpCU,EAAaV,EAAKE,YAAYM,OAAOvB,KAAI,SAACC,GAC1C,MAAO,CAACA,EAAKC,gBAGbsB,EACA,IAAIE,IAAUhB,EAAgBe,IAE9B,IAAIC,IAAUhB,EAAgBe,EAAWE,MAAM,EAVvC,IAaJF,EAAWb,OAbP,GAcJD,EAAE,4CAA4CiB,IAAI,CAC9CC,QAAS,WAMpBb,YAAqBD,EAAKE,YAAYa,iBACvCvC,EAAyBwB,EAAKE,YAAYa,oBAzCrC,0C,+KAAH,sD,4VCLDJ,E,WAOpB,WAAYK,EAAKhB,GAAoB,IAAdiB,EAAc,uDAAJ,GAAI,UACpCC,KAAKF,IAAMA,EACXE,KAAKlB,KAAOA,EACZkB,KAAKD,QAAUA,EACfC,KAAKC,OAASD,KAAKF,IAAIzB,KAAK,SAC5B2B,KAAKE,OAASF,KAAKF,IAAIzB,KAAK,SAC5B2B,KAAKG,S,sDAGCC,GACN,sCAEIA,EAAOrC,KAAI,SAAAsC,GACZ,OAAOA,SAAkDA,EAAM1B,OAAS,EAAjE,cAA4E0B,EAA5E,yBACLlC,KAAK,IAJV,yB,+BASQ,WACR,IACC,GAAI6B,KAAKD,QAAQpB,OAAS,EAAG,CAC5B,IAAI2B,EAAYN,KAAKD,QAAQhC,KAAI,SAAAC,GAAI,oBAAWA,EAAX,YAAwBG,KAAK,IAClE6B,KAAKC,OAAO3B,KAAKgC,GAElB,IAAIC,EAAOP,KAAKlB,KAAKf,KAAI,SAAAC,GAAI,OAAI,EAAKwC,OAAOxC,MAAOG,KAAK,IACzD6B,KAAKE,OAAO5B,KAAKiC,GAChB,MAAOE,U","file":"7.41606199b45d1669befb.js","sourcesContent":["import AjaxTable from '../helpers/ajaxTable';\nimport { displayErrorMessage } from '../helpers/displayError';\nimport { isNullUndefinedEmpty } from '../helpers/helpers';\nimport userStateManager from '../helpers/stateManager';\n\nexport const component = async () => {\n const momentModule = await import('moment-mini');\n window.moment = momentModule.default;\n\n const $myAwardsTable = $('#my-awards-table');\n const $upcomingAwardsTable = $('#my-upcoming-award-table');\n\n if ($myAwardsTable.length) {\n userStateManager.getUserProfileData(function (data) {\n if (!isNullUndefinedEmpty(data.ProfileInfo)) {\n if (data && data.apiProblemOccured) {\n $myAwardsTable.parent().nextAll('.callout-box').remove();\n $upcomingAwardsTable.remove();\n displayErrorMessage($myAwardsTable.parent());\n return;\n }\n\n if (!isNullUndefinedEmpty(data.ProfileInfo.Awards)) {\n const fullListing = $myAwardsTable.data('full');\n const max = 5;\n\n //Format data ready to map to table\n var awardsData = data.ProfileInfo.Awards.map((item) => {\n return [item.Description];\n });\n\n if (fullListing) {\n new AjaxTable($myAwardsTable, awardsData);\n } else {\n new AjaxTable($myAwardsTable, awardsData.slice(0, max));\n\n //show a button if more than max\n if (awardsData.length > max) {\n $('.button-wrapper.my-awards-button-wrapper').css({\n display: 'block',\n });\n }\n }\n }\n\n if (!isNullUndefinedEmpty(data.ProfileInfo.EligibleAwards)) {\n setupAwardsEligibleTable(data.ProfileInfo.EligibleAwards);\n }\n }\n });\n }\n\n function setupAwardsEligibleTable(eligibleAwards) {\n //Eligible Awards\n //Only renders the first item\n\n function getUpcomingAward(item) {\n return `\n\t\t\t\t\n\t\t\t\t\t${item.Description}\n\t\t\t\t\t${moment(item.DateIssued).format('DD/MM/YYYY')}\n\t\t\t\t\n\t\t\t`;\n }\n\n const firstAwardFormatted = moment(eligibleAwards[0].DateIssued).format('DD/MM/YYYY');\n var awardsOnSameDay = eligibleAwards.filter((award) => {\n return firstAwardFormatted === moment(award.DateIssued).format('DD/MM/YYYY');\n });\n\n var upcomingAwardHtml = awardsOnSameDay.map((item) => getUpcomingAward(item)).join('');\n\n $upcomingAwardsTable.find('tbody').html(upcomingAwardHtml);\n }\n};\n","export default class AjaxTable {\n /**\n * Helper class to render a table body (optional column headers) after an AJAX call.\n * @param {Object} $el jQuery element\n * @param {Array.} data Array of strings within an array of rows. Keypair data should be mapped to an array of strings first!\n\t * @param {string[]} headers (Optional) specify the headers for each column. Use if headers are dynamic and not set via view.\n */\n\tconstructor($el, data, headers = []) {\n\t\tthis.$el = $el;\n\t\tthis.data = data;\n\t\tthis.headers = headers;\n\t\tthis.$thead = this.$el.find('thead');\n\t\tthis.$tbody = this.$el.find('tbody');\n\t\tthis.render();\n\t}\n\n\tgetRow(arrRow){\n\t\treturn `\n\t\t\t\n\t\t\t\t${arrRow.map(value => {\n\t\t\t\t\treturn value !== null && typeof value !== 'undefined' && value.length > 0 ? `${value}` : `-`\n\t\t\t\t}).join('')}\n\t\t\t\n\t\t`\n }\n\n\trender() {\n\t\ttry {\n\t\t\tif (this.headers.length > 0) {\n\t\t\t\tvar headerRow = this.headers.map(item => `${item}`).join('');\n\t\t\t\tthis.$thead.html(headerRow);\n\t\t\t}\n\t\t\tvar rows = this.data.map(item => this.getRow(item)).join('');\n\t\t\tthis.$tbody.html(rows);\n\t\t} catch (error) {\n\t\t\tconsole.error('There was an issue generating an Ajax Table', error);\n\t\t}\n\t}\n}\n\n"],"sourceRoot":""}