Skip to content

Commit 8d414bb

Browse files
Merge pull request #1417 from aliraza556/fix/stake-fields-frontend-backend-mapping
Fix [Edit Bounty]: staking fields mapping between frontend and backend
2 parents 8d2b541 + 9c6c0d0 commit 8d414bb

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

src/people/main/FocusView.tsx

+16
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,14 @@ function FocusedView(props: FocusViewProps) {
352352
? moment(wanted?.estimated_completion_date)
353353
: '';
354354

355+
if (wanted.is_stakable !== undefined) {
356+
initialValues.isStakable = wanted.is_stakable;
357+
}
358+
359+
if (wanted.stake_min !== undefined) {
360+
initialValues.stakeMin = wanted.stake_min.toString();
361+
}
362+
355363
if (wanted.type) {
356364
const thisDynamicSchema = dynamicSchemasByType[wanted.type];
357365
const newValues = thisDynamicSchema.map((s: any) => {
@@ -379,6 +387,14 @@ function FocusedView(props: FocusViewProps) {
379387
return {
380388
[s.name]: wanted['feature_uuid'] || feature_uuid || ''
381389
};
390+
} else if (s.name === 'isStakable') {
391+
return {
392+
[s.name]: initialValues.isStakable
393+
};
394+
} else if (s.name === 'stakeMin') {
395+
return {
396+
[s.name]: initialValues.stakeMin
397+
};
382398
}
383399
return {
384400
[s.name]: wanted[s.name]

src/store/interface.ts

+4
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ export interface PersonBounty {
123123
text_snippet_id?: string;
124124
access_restriction?: string;
125125
unlock_code?: string;
126+
is_stakable?: boolean;
127+
stake_min?: number;
128+
max_stakers?: number;
129+
current_stakers?: number;
126130
}
127131

128132
export type WorkspaceTransactionType = 'deposit' | 'payment' | 'withdraw' | 'failed' | 'pending';

src/store/main.ts

+12
Original file line numberDiff line numberDiff line change
@@ -1753,6 +1753,18 @@ export class MainStore {
17531753
body.coding_languages = languages;
17541754
}
17551755

1756+
if (body.isStakable !== undefined) {
1757+
body.is_stakable = body.isStakable;
1758+
delete body.isStakable;
1759+
}
1760+
1761+
if (body.stakeMin !== undefined) {
1762+
body.stake_min = parseInt(body.stakeMin, 10) || 0;
1763+
delete body.stakeMin;
1764+
}
1765+
1766+
body.max_stakers = body.max_stakers || 1;
1767+
17561768
// eslint-disable-next-line no-useless-catch
17571769
try {
17581770
const request = `gobounties?token=${info?.tribe_jwt}`;

0 commit comments

Comments
 (0)