Skip to content

Equity perc test#2

Open
Adarsh9977 wants to merge 5 commits intomainfrom
equity-perc-test
Open

Equity perc test#2
Adarsh9977 wants to merge 5 commits intomainfrom
equity-perc-test

Conversation

@Adarsh9977
Copy link
Owner

@Adarsh9977 Adarsh9977 commented Aug 4, 2025

Summary by cubic

Changed equity percentage fields from integers to decimals across the backend, frontend, and database to support fractional equity splits.

  • Migration
    • Updated database columns, validation, and all related code to use decimal values for equity percentages.
    • Adjusted input components and tests to handle decimal equity values.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic analysis

3 issues found across 22 files • Review in cubic

React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.

role: z.string().nullable(),
payRateInSubunits: z.number().nullable(),
equityPercentage: z.number(),
equityPercentage: z.string(),
Copy link

Choose a reason for hiding this comment

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

Validating this field as z.string() rejects numeric JSON values that the backend may still return, risking runtime validation failures; support both string and number instead.

Prompt for AI agents
Address the following comment on frontend/models/user.ts at line 79:

<comment>Validating this field as z.string() rejects numeric JSON values that the backend may still return, risking runtime validation failures; support both string and number instead.</comment>

<file context>
@@ -76,7 +76,7 @@ export const currentUserSchema = z.object({
         payRateType: z.enum([&quot;hourly&quot;, &quot;project_based&quot;]),
         role: z.string().nullable(),
         payRateInSubunits: z.number().nullable(),
-        equityPercentage: z.number(),
+        equityPercentage: z.string(),
       })
       .optional(),
</file context>
Suggested change
equityPercentage: z.string(),
equityPercentage: z.union([z.string(), z.number()]),

<div
style={{ width: `${100 - contractor.equityPercentage}%` }}
style={{
width: `${100 - (typeof contractor.equityPercentage === "number" ? contractor.equityPercentage : 0)}%`,
Copy link

Choose a reason for hiding this comment

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

Second bar defaults to 0 % whenever equityPercentage is not a number, but the first bar still uses the raw value. For numeric strings like "50.00" the bars will render 50 % + 100 % = 150 %, breaking the layout.

Prompt for AI agents
Address the following comment on frontend/app/(dashboard)/people/[id]/page.tsx at line 465:

<comment>Second bar defaults to 0 % whenever equityPercentage is not a number, but the first bar still uses the raw value. For numeric strings like &quot;50.00&quot; the bars will render 50 % + 100 % = 150 %, breaking the layout.</comment>

<file context>
@@ -458,21 +461,37 @@ const DetailsTab = ({
                   className=&quot;flex flex-col justify-center bg-blue-600 whitespace-nowrap&quot;
                 &gt;&lt;/div&gt;
                 &lt;div
-                  style={{ width: `${100 - contractor.equityPercentage}%` }}
+                  style={{
+                    width: `${100 - (typeof contractor.equityPercentage === &quot;number&quot; ? contractor.equityPercentage : 0)}%`,
+                  }}
                   className=&quot;flex flex-col justify-center&quot;
</file context>
Suggested change
width: `${100 - (typeof contractor.equityPercentage === "number" ? contractor.equityPercentage : 0)}%`,
width: `${100 - Number(contractor.equityPercentage ?? 0)}%`,

const processValue = useCallback(
(val: number) => {
const clampedValue = Math.min(max, Math.max(min, val));
const roundedValue = Math.round(clampedValue / step) * step;
Copy link

Choose a reason for hiding this comment

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

Division by step is performed without verifying that step is a positive, non-zero number; passing 0 or a negative step would produce Infinity/NaN and break the component (Based on your team’s feedback about validating arithmetic inputs).

Prompt for AI agents
Address the following comment on frontend/components/RangeInput.tsx at line 57:

<comment>Division by step is performed without verifying that step is a positive, non-zero number; passing 0 or a negative step would produce Infinity/NaN and break the component (Based on your team’s feedback about validating arithmetic inputs).</comment>

<file context>
@@ -28,99 +32,225 @@ const RangeInput = ({
 }) =&gt; {
   const uid = React.useId();
   const componentId = id ?? uid;
+  const inputRef = useRef&lt;HTMLInputElement&gt;(null);
 
   const [sliderValue, setSliderValue] = useState&lt;number[]&gt;([value]);
-  const [inputValue, setInputValue] = useState&lt;string&gt;(value.toString());
+  const [inputValue, setInputValue] = useState&lt;string&gt;(&quot;&quot;);
+  const [isInputFocused, setIsInputFocused] = useState(false);
</file context>

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