Skip to content

Comments

[MOSIP-44414] Generate API Key for Manual Adjudication Partner#1652

Merged
mayuradesh merged 2 commits intomosip:developfrom
Rakshithasai123:MOSIP-44414
Feb 18, 2026
Merged

[MOSIP-44414] Generate API Key for Manual Adjudication Partner#1652
mayuradesh merged 2 commits intomosip:developfrom
Rakshithasai123:MOSIP-44414

Conversation

@Rakshithasai123
Copy link

@Rakshithasai123 Rakshithasai123 commented Feb 17, 2026

MOSIP-44414

Summary by CodeRabbit

  • New Features

    • Added a dedicated UI for generating API keys for manual adjudication partners, including partner/policy selection, validation, submission, and copy-on-success flow.
    • Added a new route to access the API key generation interface from the manual adjudication services page.
  • Bug Fixes / Improvements

    • Updated navigation from the services list to the new API key generation screen.
    • Added translation labels for "Manual Adjudication Partner" (EN/FR/AR).

Signed-off-by: Rakshithasai123 <rakshithasai2002@gmail.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 17, 2026

Walkthrough

Adds a new admin route and React page to generate API keys for manual-adjudication partners/policies, wires navigation from the ManualAdjudicationServices page, and adds translation keys for the new UI labels.

Changes

Cohort / File(s) Summary
Routes
pmp-ui-v2/src/AppRoutes.js
Imports and registers a new route at admin/manual-adjudication-services/generate-api-key rendering the GenerateManualAdjudicationApiKey component inside the guarded/admin layout.
API Key Generation UI
pmp-ui-v2/src/pages/admin/manualAdjudication/GenerateManualAdjudicationApiKey.js
New full-featured React component: loads approved partners, fetches policies for selected partner, manages form state and validation (apiKeyName regex), posts generation request, shows CopyIdPopUp and Confirmation, handles errors and beforeunload/blocker behavior.
Navigation
pmp-ui-v2/src/pages/admin/manualAdjudication/ManualAdjudicationServices.js
Removed unused i18n import and updated generateApiKey to navigate to the new generate-api-key route instead of a placeholder.
Translations
pmp-ui-v2/public/i18n/eng.json, pmp-ui-v2/public/i18n/fra.json, pmp-ui-v2/public/i18n/ara.json
Added partnerType translation key under manualAdjudicationServices in English, French, and Arabic translation files.

Sequence Diagram

sequenceDiagram
    participant User
    participant UI as GenerateManualAdjudicationApiKey
    participant API as Backend API
    participant Modal as CopyIdPopUp

    User->>UI: Open page
    UI->>API: GET /approved-manual-adjudication-partners
    API-->>UI: partners list

    User->>UI: Select partner
    UI->>API: GET /policies?policyGroup=<group>
    API-->>UI: policies list
    UI->>UI: populate policyGroupName & policy list

    User->>UI: Enter apiKeyName & choose policy
    UI->>UI: validate inputs

    User->>UI: Submit
    UI->>API: POST /generateManualAdjudicationApiKey {partnerId, policyId, apiKeyName}
    API-->>UI: {apiKey, metadata}

    UI->>Modal: show API key and details
    User->>Modal: copy key / confirm
    Modal-->>UI: closed
    UI->>User: show Confirmation / navigate away
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐰 I hopped in code to add a key so bright,
Dropdowns, checks, and modals in the night,
Partners, policies, one click — copy away,
A tiny carrot of features for the day! 🔑🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a new feature to generate API keys for manual adjudication partners, which is reflected across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
pmp-ui-v2/src/pages/admin/manualAdjudication/GenerateManualAdjudicationApiKey.js (1)

200-253: Inconsistent indentation in clickOnSubmit.

The function body (lines 200–253) mixes indentation levels — the request object, try/catch, and finally blocks are indented at the function's top level rather than being nested under the function. This is inconsistent with the rest of the file.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@pmp-ui-v2/src/pages/admin/manualAdjudication/GenerateManualAdjudicationApiKey.js`
around lines 200 - 253, The clickOnSubmit function's body is mis-indented;
re-indent the entire function so the request object, the try/catch/finally
blocks and all setState calls are nested inside clickOnSubmit's curly braces at
the same indentation level as the initial setShowPopup/setIsSubmitClicked lines;
specifically adjust the block containing request, the await HttpService.post
call, the if (response?.data?.response) branch (setConfirmationData,
setApiKeyId, setShowPopup), the else handleServiceErrors call, and the
catch/finally blocks to align consistently under the clickOnSubmit declaration.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@pmp-ui-v2/src/pages/admin/manualAdjudication/GenerateManualAdjudicationApiKey.js`:
- Around line 61-78: The beforeunload logic in the useEffect (functions
shouldWarnBeforeUnload and handleBeforeUnload) only checks isSubmitClicked so a
successful generation still triggers the browser prompt; update the handler to
also consider generateApiKeySuccess (i.e., skip warning when
generateApiKeySuccess is true) and add generateApiKeySuccess to the useEffect
dependency array so the listener reacts to success state changes (keep
partnerId, policyName, apiKeyName, and isSubmitClicked in the dependencies).
- Around line 383-389: The Clear Form button currently always includes "mr-3"
which breaks RTL spacing; update the className for the element with id
"generate_manual_adjudication_clear_form" (and related to
clearForm/isLoginLanguageRTL) to remove the unconditional "mr-3" and instead
apply the larger side margin conditionally—e.g. use a single conditional that
yields "mr-3" when isLoginLanguageRTL is false and "ml-3" when true—while
preserving any additional small-side spacing logic (the existing
isLoginLanguageRTL ? "mr-2" : "ml-2") only if still required.
- Around line 159-173: The onChangePartnerId handler does not clear the selected
policyId, and clearForm also omits resetting it, which allows stale policy IDs
to persist; update both onChangePartnerId and clearForm to reset the policyId
state (call the existing state setter for policyId, e.g., setPolicyId with an
empty string or null) whenever the partner changes or the form is cleared so the
form validation and submission cannot use a stale policyId.
- Line 47: Replace the hardcoded string assigned to partnerTypeLabel with a
translated value using the i18n translator (e.g., partnerTypeLabel =
t('manualAdjudication.partnerLabel')) so the read-only input uses t(...) instead
of the literal "Manual Adjudication Partner"; update the
GenerateManualAdjudicationApiKey component to import/use the translator if not
already present and add the new translation key to the i18n resource files for
all supported locales.

---

Nitpick comments:
In
`@pmp-ui-v2/src/pages/admin/manualAdjudication/GenerateManualAdjudicationApiKey.js`:
- Around line 200-253: The clickOnSubmit function's body is mis-indented;
re-indent the entire function so the request object, the try/catch/finally
blocks and all setState calls are nested inside clickOnSubmit's curly braces at
the same indentation level as the initial setShowPopup/setIsSubmitClicked lines;
specifically adjust the block containing request, the await HttpService.post
call, the if (response?.data?.response) branch (setConfirmationData,
setApiKeyId, setShowPopup), the else handleServiceErrors call, and the
catch/finally blocks to align consistently under the clickOnSubmit declaration.

Signed-off-by: Rakshithasai123 <rakshithasai2002@gmail.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pmp-ui-v2/public/i18n/fra.json (1)

660-667: ⚠️ Potential issue | 🟡 Minor

Align French wording with existing “arbitrage manuel” terminology.

The new label uses “adjudication” while other French strings (e.g., “Services d'arbitrage manuel”) use “arbitrage manuel”, which can read inconsistently in the UI. Consider harmonizing the wording across the locale.

Proposed fix
-        "partnerType": "Partenaire d’adjudication manuelle",
+        "partnerType": "Partenaire d'arbitrage manuel",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pmp-ui-v2/public/i18n/fra.json` around lines 660 - 667, The French label
inside the manualAdjudicationServices object uses “Partenaire d’adjudication
manuelle” which is inconsistent with the existing “arbitrage manuel” phrasing;
update the value for the key partnerType in the manualAdjudicationServices
object to use the same terminology, e.g., "Partenaire d'arbitrage manuel", so
wording is consistent across the locale.
🧹 Nitpick comments (1)
pmp-ui-v2/src/pages/admin/manualAdjudication/GenerateManualAdjudicationApiKey.js (1)

383-407: Enforce Enter-only activation on buttons per keyboard policy.

The current buttons will activate on Space by default. If the project policy is “Enter-only,” add a shared keydown handler to suppress Space activation.

Example adjustment
+  const blockSpaceKey = (event) => {
+    if (event.code === "Space" || event.key === " ") {
+      event.preventDefault();
+    }
+  };
...
                   <button
                     id="generate_manual_adjudication_clear_form"
                     onClick={clearForm}
+                    onKeyDown={blockSpaceKey}
                     className={`w-40 h-10 border-[`#1447B2`] ${isLoginLanguageRTL ? "ml-3 mr-2" : "mr-3 ml-2"} border rounded-md bg-white text-tory-blue text-sm font-semibold`}
                   >
...
                   <button
                     id="generate_manual_adjudication_cancel_btn"
                     onClick={clickOnCancel}
+                    onKeyDown={blockSpaceKey}
                     className={`${isLoginLanguageRTL ? "ml-2" : "mr-2"} w-11/12 md:w-40 h-10 border-[`#1447B2`] border rounded-md bg-white text-tory-blue text-sm font-semibold`}
                   >
...
                   <button
                     id="generate_manual_adjudication_submit_btn"
                     disabled={!isFormValid()}
                     onClick={clickOnSubmit}
+                    onKeyDown={blockSpaceKey}
                     className={`${isLoginLanguageRTL ? "ml-2" : "mr-2"} w-11/12 md:w-40 h-10 border-[`#1447B2`] border rounded-md text-sm font-semibold ${isFormValid() ? "bg-tory-blue text-white" : "border-[`#A5A5A5`] bg-[`#A5A5A5`] text-white cursor-not-allowed"}`}
                   >
Based on learnings: Apply the project-wide keyboard policy in the partner-management-portal repo: interactive controls should be operable using the Enter key only (not Space). This applies to switches/toggles and other interactive elements in pmp-ui-v2/src/**/*.js. Ensure ARIA and accessibility considerations are reviewed and that this behavior is consistently implemented across components.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@pmp-ui-v2/src/pages/admin/manualAdjudication/GenerateManualAdjudicationApiKey.js`
around lines 383 - 407, The buttons in GenerateManualAdjudicationApiKey.js
currently activate on Space; add a shared keydown handler (e.g.,
handleKeyDownSuppressSpace) and attach it to the three buttons (ids:
generate_manual_adjudication_clear_form,
generate_manual_adjudication_cancel_btn,
generate_manual_adjudication_submit_btn) so that when event.key === " " or
event.code === "Space" you preventDefault() and stopPropagation(), but allow
Enter to trigger normal click behavior; ensure this handler coexists with
existing onClick handlers (clearForm, clickOnCancel, clickOnSubmit) and
preserves ARIA semantics and isFormValid() disabled logic for the submit button.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@pmp-ui-v2/public/i18n/fra.json`:
- Around line 660-667: The French label inside the manualAdjudicationServices
object uses “Partenaire d’adjudication manuelle” which is inconsistent with the
existing “arbitrage manuel” phrasing; update the value for the key partnerType
in the manualAdjudicationServices object to use the same terminology, e.g.,
"Partenaire d'arbitrage manuel", so wording is consistent across the locale.

---

Nitpick comments:
In
`@pmp-ui-v2/src/pages/admin/manualAdjudication/GenerateManualAdjudicationApiKey.js`:
- Around line 383-407: The buttons in GenerateManualAdjudicationApiKey.js
currently activate on Space; add a shared keydown handler (e.g.,
handleKeyDownSuppressSpace) and attach it to the three buttons (ids:
generate_manual_adjudication_clear_form,
generate_manual_adjudication_cancel_btn,
generate_manual_adjudication_submit_btn) so that when event.key === " " or
event.code === "Space" you preventDefault() and stopPropagation(), but allow
Enter to trigger normal click behavior; ensure this handler coexists with
existing onClick handlers (clearForm, clickOnCancel, clickOnSubmit) and
preserves ARIA semantics and isFormValid() disabled logic for the submit button.

@mayuradesh mayuradesh merged commit 0978032 into mosip:develop Feb 18, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants