Conversation
There was a problem hiding this comment.
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.
frontend/models/user.ts
Outdated
| role: z.string().nullable(), | ||
| payRateInSubunits: z.number().nullable(), | ||
| equityPercentage: z.number(), | ||
| equityPercentage: z.string(), |
There was a problem hiding this 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.
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(["hourly", "project_based"]),
role: z.string().nullable(),
payRateInSubunits: z.number().nullable(),
- equityPercentage: z.number(),
+ equityPercentage: z.string(),
})
.optional(),
</file context>
| 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)}%`, |
There was a problem hiding this 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 "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 "50.00" the bars will render 50 % + 100 % = 150 %, breaking the layout.</comment>
<file context>
@@ -458,21 +461,37 @@ const DetailsTab = ({
className="flex flex-col justify-center bg-blue-600 whitespace-nowrap"
></div>
<div
- style={{ width: `${100 - contractor.equityPercentage}%` }}
+ style={{
+ width: `${100 - (typeof contractor.equityPercentage === "number" ? contractor.equityPercentage : 0)}%`,
+ }}
className="flex flex-col justify-center"
</file context>
| width: `${100 - (typeof contractor.equityPercentage === "number" ? contractor.equityPercentage : 0)}%`, | |
| width: `${100 - Number(contractor.equityPercentage ?? 0)}%`, |
frontend/components/RangeInput.tsx
Outdated
| const processValue = useCallback( | ||
| (val: number) => { | ||
| const clampedValue = Math.min(max, Math.max(min, val)); | ||
| const roundedValue = Math.round(clampedValue / step) * step; |
There was a problem hiding this 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).
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 = ({
}) => {
const uid = React.useId();
const componentId = id ?? uid;
+ const inputRef = useRef<HTMLInputElement>(null);
const [sliderValue, setSliderValue] = useState<number[]>([value]);
- const [inputValue, setInputValue] = useState<string>(value.toString());
+ const [inputValue, setInputValue] = useState<string>("");
+ const [isInputFocused, setIsInputFocused] = useState(false);
</file context>
Summary by cubic
Changed equity percentage fields from integers to decimals across the backend, frontend, and database to support fractional equity splits.