Created
June 23, 2020 19:29
-
-
Save developerfred/6b3e4ec5ccfc28a5da22d15cc49d5938 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * generates object with all the data submitted during | |
| * bounty creation | |
| * @param {object} form | |
| */ | |
| const transformBountyData = form => { | |
| let data = {}; | |
| let disabled = $(form).find(':input:disabled').removeAttr('disabled'); | |
| $.each($(form).serializeArray(), function() { | |
| if (data[this.name]) { | |
| data[this.name] += ',' + this.value; | |
| } else { | |
| data[this.name] = this.value; | |
| } | |
| }); | |
| disabled.attr('disabled', 'disabled'); | |
| loading_button($('.js-submit')); | |
| const tokenAddress = data.denomination; | |
| const token = tokenAddressToDetails(tokenAddress); | |
| const reservedFor = $('.username-search').select2('data')[0]; | |
| const releaseAfter = $('#releaseAfter').children('option:selected').val(); | |
| const inviteContributors = $('#invite-contributors.js-select2').select2('data').map((user) => { | |
| return user.profile__id; | |
| }); | |
| const metadata = { | |
| issueTitle: data.title, | |
| issueDescription: data.description, | |
| issueKeywords: data.keywords ? data.keywords : '', | |
| githubUsername: data.githubUsername, | |
| notificationEmail: data.notificationEmail, | |
| fullName: data.fullName, | |
| experienceLevel: data.experience_level, | |
| projectLength: data.project_length, | |
| bountyType: data.bounty_type, | |
| estimatedHours: data.hours, | |
| fundingOrganisation: data.fundingOrganisation, | |
| eventTag: data.specialEvent ? (data.eventTag || '') : '', | |
| is_featured: data.featuredBounty, | |
| repo_type: 'public', | |
| featuring_date: data.featuredBounty && ((new Date().getTime() / 1000) | 0) || 0, | |
| reservedFor: reservedFor ? reservedFor.text : '', | |
| releaseAfter: releaseAfter !== 'Release To Public After' ? releaseAfter : '', | |
| tokenName: token['name'], | |
| invite: inviteContributors, | |
| bounty_categories: data.bounty_categories, | |
| activity: data.activity | |
| }; | |
| data.metadata = metadata; | |
| return data; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment