Skip to content

Commit

Permalink
fix: default selection of incorporation type inside company settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Raju-kadel-27 committed Sep 25, 2024
1 parent 9af50c4 commit cdd00cb
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions src/components/onboarding/company-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,30 @@ export const CompanyForm = ({ type, data }: CompanyFormProps) => {

const isDirty = form.formState.isDirty;

type IncorpType = "llc" | "c-corp" | "s-corp" | "other";

const existingIncorpType = data?.company.incorporationType as IncorpType;

const humanizeIncorpType = (key: IncorpType) => {
switch (key) {
case "llc":
return "LLC - Limited Liability Company";
case "c-corp":
return "C-Corp - C Corporation";
case "s-corp":
return "S-Corp - S Corporation";
case "other":
return "Others or International";
default:
return "Unknown Incorporation Type";
}
};

const incorpTypeOpts = [
{ value: "llc", label: "LLC - Limited Liability Company" },
{ value: "c-corp", label: "C-Corp - C Corporation" },
{ value: "s-corp", label: "S-Corp - S Corporation" },
{ value: "other", label: "Others or International" },
{ value: "llc", label: humanizeIncorpType("llc") },
{ value: "c-corp", label: humanizeIncorpType("c-corp") },
{ value: "s-corp", label: humanizeIncorpType("s-corp") },
{ value: "other", label: humanizeIncorpType("other") },
];

return (
Expand Down Expand Up @@ -425,6 +444,12 @@ export const CompanyForm = ({ type, data }: CompanyFormProps) => {
{/* Used Linear-combobox instead of Select Component */}
<div>
<LinearCombobox
defaultOption={{
value: existingIncorpType ?? "",
label: existingIncorpType
? humanizeIncorpType(existingIncorpType)
: "Select type",
}}
options={incorpTypeOpts}
onValueChange={(option) => {
field.onChange(option.value);
Expand Down

0 comments on commit cdd00cb

Please sign in to comment.