Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

Refactor Select usages

Andrey Okonetchnikov162c45bfceea
diff --git a/app/dashboard/components/card.tsx b/app/dashboard/components/card.tsx
index fa5f69c842..aaa7eac872 100644
--- a/app/dashboard/components/card.tsx
+++ b/app/dashboard/components/card.tsx
@@ -37,18 +37,14 @@ export const SelectProjectCard = ({
<Heading>Select a project</Heading>
<Select
name="project"
- onChange={(event) => {
- setSelectedProject(event.target.value);
- }}
+ options={projects.map((project) => project.id)}
+ onChange={setSelectedProject}
value={selectedProject}
- >
- <option value="">Create new project</option>
- {projects.map(({ id, title }) => (
- <option value={id} key={id}>
- {title}
- </option>
- ))}
- </Select>
+ placeholder="Create new project"
+ getLabel={(option) =>
+ projects.find((project) => project.id === option)?.title
+ }
+ />
{selectedProject === "" ? (
<Form method="post">
<Flex gap="1">
diff --git a/app/shared/design-system/components/select.tsx b/app/shared/design-system/components/select.tsx
index 345cad19eb..803268831d 100644
--- a/app/shared/design-system/components/select.tsx
+++ b/app/shared/design-system/components/select.tsx
@@ -144,7 +144,7 @@ export type SelectProps<T = SelectOption> = Omit<
value?: T;
onChange?: (option: T) => void;
placeholder?: string;
- getLabel?: (option: T) => string;
+ getLabel?: (option: T) => string | undefined;
};
const SelectBase = (