Skip to content

Conversation

kishangupta4514
Copy link
Contributor

@kishangupta4514 kishangupta4514 commented Jun 20, 2025

Description

In this pr, I have added the functionality of setting the mock response ratio.

Add Issue Number

Fixes #<your_issue_number>

Add Screenshots/GIFs

image

Add Known Issue

If applicable, add any known issues.

Contribution Checklist:

  • The pull request only addresses one issue or adds one feature.
  • I have linked an issue to the pull request.
  • I have linked a PR type label to the pull request.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

@kishangupta4514 kishangupta4514 self-assigned this Jun 20, 2025
@kishangupta4514 kishangupta4514 added the feature New feature requests label Jun 20, 2025
@@ -0,0 +1,291 @@
<script lang="ts">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this component to common folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines 40 to 63
function handleChange(index, event) {
const isEmpty = event.detail === "" || event.detail === null;
const activeResponse = activeResponses[index];
const responseId = activeResponse.id;

const oldValue = Number(inputValues.get(responseId) || 0);

const newNumericValue = isEmpty ? 0 : Number(event.detail);

const potentialTotal = totalPercentage - oldValue + newNumericValue;
inputValues.set(responseId, isEmpty ? null : newNumericValue);

// Recalculate total
calculateTotal();

// Handle error state
if (potentialTotal <= 100) {
exceededLimit = false;
lastModifiedIndex = null;
} else {
exceededLimit = true;
lastModifiedIndex = index;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it arrow function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines 66 to 76
function calculateTotal() {
totalPercentage = 0;

activeResponses.forEach((response) => {
const value = inputValues.get(response.id);
totalPercentage +=
value === null || value === undefined || value === ""
? 0
: Number(value);
});
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it arrow function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@Astitva877 Astitva877 merged commit 71f5a04 into sparrowapp-dev:mock-response-ratio Jun 24, 2025
0 of 4 checks passed
@punitkashyup
Copy link
Contributor

🎉 This PR is included in version 2.27.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@punitkashyup punitkashyup added the released Released feature or a bug label Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature requests released Released feature or a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants