Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞Re- Fix#1365: Allow old bounties to be displayed #1375 #15

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 45 additions & 40 deletions src/people/main/FocusView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ function FocusedView(props: FocusViewProps) {
return false;
}

// close bounty popup window
function closeModal() {
if (!manualGoBackOnly) {
ui.setEditMe(false);
Expand Down Expand Up @@ -131,7 +130,7 @@ function FocusedView(props: FocusViewProps) {
if (props?.deleteExtraFunction) props?.deleteExtraFunction();
}
} catch (e) {
console.log('e', e);
console.error('Error during bounty deletion:', e);
}
setDeleting(false);
if (!isNotHttps(ui?.meInfo?.url) && props.ReCallBounties) props.ReCallBounties();
Expand Down Expand Up @@ -192,6 +191,9 @@ function FocusedView(props: FocusViewProps) {

// body.description = description;
newBody.title = newBody.one_sentence_summary;

// save repo to cookies for autofill in form
ui.setLastGithubRepo(newBody.ticket_url);
}
} catch (e) {
throw githubError;
Expand All @@ -207,7 +209,7 @@ function FocusedView(props: FocusViewProps) {
try {
newBody = await preSubmitFunctions(newBody);
} catch (e) {
console.log('e', e);
console.error('Error during preSubmitFunctions:', e);
alert(e);
return;
}
Expand All @@ -218,7 +220,7 @@ function FocusedView(props: FocusViewProps) {
}

const info = ui.meInfo as any;
if (!info) return console.log('no meInfo');
if (!info) return console.error('No meInfo');
setLoading(true);

try {
Expand Down Expand Up @@ -246,12 +248,12 @@ function FocusedView(props: FocusViewProps) {

await main.saveBounty(newBody);

// Refresh the tickets page if a user eidts from the tickets tab
// Refresh the tickets page if a user edits from the tickets tab
if (window.location.href.includes('wanted')) {
await main.getPersonCreatedBounties({}, info.pubkey);
}
} catch (e) {
console.log('e', e);
console.error('Error during bounty submission:', e);
}

if (props?.onSuccess) props.onSuccess();
Expand All @@ -268,47 +270,50 @@ function FocusedView(props: FocusViewProps) {
const personInfo = canEdit ? ui.meInfo : person;

// set initials here
if (personInfo) {
// if there is a selected index, fill in values
if (bounty && bounty.length && selectedIndex >= 0) {
const selectedBounty = bounty[0];
const wanted = selectedBounty.body;
if (personInfo && bounty && bounty.length && selectedIndex >= 0) {
const selectedBounty = bounty[0];
const wanted = selectedBounty?.body;

if (wanted) {
initialValues.estimated_completion_date = wanted?.estimated_completion_date
? moment(wanted?.estimated_completion_date)
? moment(wanted.estimated_completion_date)
: '';

if (wanted.type) {
const thisDynamicSchema = dynamicSchemasByType[wanted.type];
const newValues = thisDynamicSchema.map((s: any) => {
if (s.name === 'estimated_completion_date') {
return {
[s.name]: wanted['estimated_completion_date'] || new Date()
};
} else if (s.name === 'one_sentence_summary') {
return {
[s.name]: wanted['one_sentence_summary'] || wanted['title']
};
} else if (s.name === 'coding_languages') {
const coding_languages =
wanted['coding_languages'] && wanted['coding_languages'].length
? wanted['coding_languages'].map((lang: any) => ({ value: lang, label: lang }))
: [];

if (Array.isArray(thisDynamicSchema)) {
const newValues = thisDynamicSchema.map((s: any) => {
if (s.name === 'estimated_completion_date') {
return {
[s.name]: wanted.estimated_completion_date || new Date()
};
} else if (s.name === 'one_sentence_summary') {
return {
[s.name]: wanted.one_sentence_summary || wanted.title
};
} else if (s.name === 'coding_languages') {
const coding_languages =
wanted.coding_languages && wanted.coding_languages.length
? wanted.coding_languages.map((lang: any) => ({ value: lang, label: lang }))
: [];
return {
[s.name]: coding_languages
};
}
return {
[s.name]: coding_languages
[s.name]: wanted[s.name]
};
}
return {
[s.name]: wanted[s.name]
};
});

const valueMap = Object.assign({}, ...newValues);
initialValues = { ...initialValues, ...valueMap };
} else {
const dynamicSchema = config?.schema?.find((f: any) => f.defaultSchema);
dynamicSchema?.defaultSchema?.forEach((s: any) => {
initialValues[s.name] = wanted[s.name];
});
});

const valueMap = Object.assign({}, ...newValues);
initialValues = { ...initialValues, ...valueMap };
} else {
const dynamicSchema = config?.schema?.find((f: any) => f.defaultSchema);
dynamicSchema?.defaultSchema?.forEach((s: any) => {
initialValues[s.name] = wanted[s.name];
});
}
}
}
}
Expand Down
Loading