Skip to content

changes in request steps - #202

Merged
RISHAB-AWASTHI merged 1 commit into
mainfrom
rishab
Feb 4, 2026
Merged

changes in request steps#202
RISHAB-AWASTHI merged 1 commit into
mainfrom
rishab

Conversation

@RISHAB-AWASTHI

@RISHAB-AWASTHI RISHAB-AWASTHI commented Feb 4, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Added amount field to new request creation form to specify request costs
    • Amount now displays as a currency badge in request details header alongside linked equipment
    • Form layout updated to accommodate the new amount field
  • Removed Features

    • Removed tenant information section from request workflow

@coderabbitai

coderabbitai Bot commented Feb 4, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The PR introduces an amount field across the new request form workflow, refactors form state management to use a centralized store with multiple setter helpers, removes tenant selection functionality from Step 2, and extends the ServiceRequest type to include an optional amount field.

Changes

Cohort / File(s) Summary
Amount Field Integration
src/pages/userdashboard/features/Requests/UserNewRequest.tsx, src/pages/userdashboard/features/Requests/components/UserStep1RequestForm.tsx, src/pages/userdashboard/utils/types.ts
Adds amount field support to the form workflow, including numeric input UI in Step 1, initialization from form data, and inclusion in the final submission payload. Updates ServiceRequest type to include optional amount field.
Request Details Display
src/pages/userdashboard/features/Requests/UserRequestDetails.tsx
Adds amount field to the derived request object and renders it as a currency badge in the header alongside Linked Equipment, using an inline-flex container to display both badges when amount is defined.
Store State Refactoring
src/pages/userdashboard/features/Requests/hooks/useNewRequestForm.ts, src/pages/userdashboard/features/Requests/store/requestStore.ts
Refactors form state to derive from a centralized store object via getters/setters. Introduces newRequestForm state management with comprehensive setter helpers (setAmount, setTitle, setDescription, etc.), adds reset functionality, and converts amount to number during submission. Exposes amount and setAmount in the public hook API.
Tenant Functionality Removal
src/pages/userdashboard/features/Requests/components/UserStep2PropertyTenants.tsx
Removes tenant list selection feature including TenantListItem type, related state management, toggleTenantSelection handler, and the Tenant Information UI block. Updates submission payload to exclude tenantList.

Sequence Diagram

sequenceDiagram
    participant User
    participant Step1 as UserStep1RequestForm
    participant Hook as useNewRequestForm
    participant Store as RequestStore
    participant Step3 as UserNewRequest (Submit)
    participant API as Backend API

    User->>Step1: Enter amount value
    Step1->>Step1: handleChange(amount)
    Step1->>Hook: onNext({amount, ...formData})
    Hook->>Store: setNewRequestForm({amount})
    Store->>Store: Update newRequestForm.amount
    Hook->>Hook: setAmount(amount)
    
    User->>Step3: Complete form & submit
    Step3->>Hook: useNewRequestForm()
    Hook->>Store: Read newRequestForm state
    Store-->>Hook: Return form data with amount
    Hook->>Hook: Convert amount to number
    Hook->>API: POST newRequest(payload with amount)
    API-->>Hook: Success response
    Hook->>Store: resetNewRequestForm()
    Store->>Store: Reset to defaults
    Hook-->>Step3: Navigate with success state
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A form takes shape, field by field,
Amount flows through, no more concealed,
Tenants fade as stores align,
State management logic, crystal-fine!
—Rabbit, hopping through the code

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'changes in request steps' is vague and generic, using non-descriptive language that fails to convey the specific improvements made to the request workflow. Use a more descriptive title that highlights the main changes, such as 'Add amount field to request form and refactor form state management' or 'Implement amount field and consolidate request form state into store'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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
  • Commit unit tests in branch rishab

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (1)
src/pages/userdashboard/features/Requests/hooks/useNewRequestForm.ts (1)

238-270: ⚠️ Potential issue | 🟡 Minor

Add validation to prevent NaN in amount parsing.

parseFloat on a non-numeric string (e.g., "abc") returns NaN, which would then propagate into the request payload. Although the HTML input uses type="number", defensive validation in the hook prevents data corruption from store inconsistencies or programmatic setters.

🛠️ Suggested guard
-            const newRequest: ServiceRequest & { attachmentDataUrls?: string[]; videoDataUrl?: string | null } = {
+            const parsedAmount = amount !== "" ? Number.parseFloat(amount) : undefined;
+            if (parsedAmount !== undefined && !Number.isFinite(parsedAmount)) {
+                setSubmissionError("Amount must be a valid number.");
+                setIsSubmitting(false);
+                return false;
+            }
+            const newRequest: ServiceRequest & { attachmentDataUrls?: string[]; videoDataUrl?: string | null } = {
                 ...
-                amount: amount ? parseFloat(amount) : undefined,
+                amount: parsedAmount,
                 ...
             };
🤖 Fix all issues with AI agents
In
`@src/pages/userdashboard/features/Requests/components/UserStep1RequestForm.tsx`:
- Around line 24-26: The amount field is shown as required but not validated;
update the UserStep1RequestForm component to enforce validation for the amount
field (e.g., in the form schema or validation logic used by the component) by
making 'amount' required and adding a numeric/min constraint (greater than 0)
and show a clear error message on submit; ensure the asterisk/label aligns with
this rule, and apply the same fix where 'details'/'amount' are initialized or
validated (references: the 'amount' and 'details' fields in the
UserStep1RequestForm initialization and the component's submit/validation
handlers such as any 'onSubmit'/'handleSubmit' or validation schema used around
those ranges).
🧹 Nitpick comments (2)
src/pages/userdashboard/features/Requests/store/requestStore.ts (2)

14-38: Tighten availability typing to match shared models.

Using any[] weakens type safety versus AvailabilityOption[].

♻️ Proposed type refinement
-import type { RequestFilters, ServiceRequest } from '../../../utils/types';
+import type { AvailabilityOption, RequestFilters, ServiceRequest } from '../../../utils/types';

     newRequestForm: {
         ...
-        availability: any[];
+        availability: AvailabilityOption[];
         ...
     };

176-232: Avoid duplicated default form state.

The default newRequestForm object is defined twice (initial state + reset), which risks drift.

♻️ Suggested consolidation
+const defaultNewRequestForm = {
+  currentStep: 1,
+  selectedCategory: null,
+  selectedSubCategory: null,
+  selectedProblem: null,
+  finalDetail: null,
+  selectedEquipment: null,
+  equipmentSerial: null,
+  equipmentCondition: null,
+  title: "",
+  description: "",
+  location: "Gandhi Path Rd, Jaipur, RJ 302020",
+  property: "1",
+  authorization: null,
+  authCode: "",
+  setUpDateTime: null,
+  dateDue: null,
+  materials: [],
+  availability: [{ id: 1, date: "", timeSlots: [] }],
+  priority: null,
+  attachments: [],
+  video: null,
+  pets: [],
+  amount: "",
+};
+
 export const useRequestStore = create<RequestState>((set) => ({
   ...
-  newRequestForm: {
-    ...
-  },
+  newRequestForm: { ...defaultNewRequestForm },
   ...
   resetNewRequestForm: () =>
     set({
-      newRequestForm: {
-        ...
-      }
+      newRequestForm: { ...defaultNewRequestForm }
     }),

Comment on lines +24 to 26
details: initialData?.details || '',
amount: initialData?.amount || ''
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Amount is marked required but not validated.

Either remove the asterisk or enforce required/min constraints to avoid inconsistent UX.

🛠️ Suggested validation alignment
-                <label className="block text-sm font-bold text-gray-700 mb-2">Amount*</label>
+                <label className="block text-sm font-bold text-gray-700 mb-2">Amount</label>
                 <input
                     type="number"
                     value={formData.amount}
                     onChange={(e) => handleChange('amount', e.target.value)}
                     placeholder="Enter amount (e.g. 500)"
                     className="w-full px-4 py-3 bg-white rounded-md border-none outline-none placeholder-gray-400"
+                    min="0"
+                    step="0.01"
                 />

Also applies to: 42-44, 330-340

🤖 Prompt for AI Agents
In
`@src/pages/userdashboard/features/Requests/components/UserStep1RequestForm.tsx`
around lines 24 - 26, The amount field is shown as required but not validated;
update the UserStep1RequestForm component to enforce validation for the amount
field (e.g., in the form schema or validation logic used by the component) by
making 'amount' required and adding a numeric/min constraint (greater than 0)
and show a clear error message on submit; ensure the asterisk/label aligns with
this rule, and apply the same fix where 'details'/'amount' are initialized or
validated (references: the 'amount' and 'details' fields in the
UserStep1RequestForm initialization and the component's submit/validation
handlers such as any 'onSubmit'/'handleSubmit' or validation schema used around
those ranges).

@RISHAB-AWASTHI
RISHAB-AWASTHI merged commit 8b8046f into main Feb 4, 2026
1 check passed
@coderabbitai coderabbitai Bot mentioned this pull request Mar 17, 2026
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.

1 participant