Skip to content

Commit

Permalink
feat: Set preselect field type on new field of object page (#6314)
Browse files Browse the repository at this point in the history
#5661

---------

Co-authored-by: Achsan <[email protected]>
Co-authored-by: Félix Malfait <[email protected]>
  • Loading branch information
3 people authored Aug 7, 2024
1 parent 9a0c967 commit f2aa67b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const useGetAvailableFieldsForKanban = () => {
navigate(
`/settings/objects/${getObjectSlug(
objectMetadataItem,
)}/new-field/step-2`,
)}/new-field/step-2?fieldType=${FieldMetadataType.Select}`,
);
} else {
navigate(`/settings/objects`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { zodResolver } from '@hookform/resolvers/zod';
import pick from 'lodash.pick';
import { useEffect, useState } from 'react';
import { FormProvider, useForm } from 'react-hook-form';
import { useNavigate, useParams } from 'react-router-dom';
import { useNavigate, useParams, useSearchParams } from 'react-router-dom';
import { H2Title, IconSettings } from 'twenty-ui';
import { z } from 'zod';

Expand Down Expand Up @@ -48,6 +48,8 @@ const StyledSettingsObjectFieldTypeSelect = styled(
export const SettingsObjectNewFieldStep2 = () => {
const navigate = useNavigate();
const { objectSlug = '' } = useParams();
const [searchParams] = useSearchParams();
const fieldType = searchParams.get('fieldType') as SettingsSupportedFieldType;
const { enqueueSnackBar } = useSnackBar();

const { findActiveObjectMetadataItemBySlug } =
Expand Down Expand Up @@ -211,6 +213,9 @@ export const SettingsObjectNewFieldStep2 = () => {
/>
<StyledSettingsObjectFieldTypeSelect
excludedFieldTypes={excludedFieldTypes}
fieldMetadataItem={{
type: fieldType,
}}
/>
<SettingsDataModelFieldSettingsFormCard
fieldMetadataItem={{
Expand Down

0 comments on commit f2aa67b

Please sign in to comment.