[MOSIP-44414] Generate API Key for Manual Adjudication Partner#1652
[MOSIP-44414] Generate API Key for Manual Adjudication Partner#1652mayuradesh merged 2 commits intomosip:developfrom
Conversation
Signed-off-by: Rakshithasai123 <rakshithasai2002@gmail.com>
WalkthroughAdds 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
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
pmp-ui-v2/src/pages/admin/manualAdjudication/GenerateManualAdjudicationApiKey.js (1)
200-253: Inconsistent indentation inclickOnSubmit.The function body (lines 200–253) mixes indentation levels — the
requestobject,try/catch, andfinallyblocks 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.
pmp-ui-v2/src/pages/admin/manualAdjudication/GenerateManualAdjudicationApiKey.js
Outdated
Show resolved
Hide resolved
pmp-ui-v2/src/pages/admin/manualAdjudication/GenerateManualAdjudicationApiKey.js
Outdated
Show resolved
Hide resolved
pmp-ui-v2/src/pages/admin/manualAdjudication/GenerateManualAdjudicationApiKey.js
Show resolved
Hide resolved
pmp-ui-v2/src/pages/admin/manualAdjudication/GenerateManualAdjudicationApiKey.js
Show resolved
Hide resolved
Signed-off-by: Rakshithasai123 <rakshithasai2002@gmail.com>
There was a problem hiding this comment.
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 | 🟡 MinorAlign 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.
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.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"}`} >🤖 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.
MOSIP-44414
Summary by CodeRabbit
New Features
Bug Fixes / Improvements