Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create EditTagPage #38240

Merged
merged 14 commits into from
Mar 19, 2024
6 changes: 3 additions & 3 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ const ONYXKEYS = {
WORKSPACE_SETTINGS_FORM: 'workspaceSettingsForm',
WORKSPACE_CATEGORY_CREATE_FORM: 'workspaceCategoryCreate',
WORKSPACE_CATEGORY_CREATE_FORM_DRAFT: 'workspaceCategoryCreateDraft',
WORKSPACE_TAG_CREATE_FORM: 'workspaceTagCreate',
WORKSPACE_TAG_CREATE_FORM_DRAFT: 'workspaceTagCreateDraft',
WORKSPACE_TAG_FORM: 'workspaceTagForm',
WORKSPACE_TAG_FORM_DRAFT: 'workspaceTagFormDraft',
WORKSPACE_SETTINGS_FORM_DRAFT: 'workspaceSettingsFormDraft',
WORKSPACE_DESCRIPTION_FORM: 'workspaceDescriptionForm',
WORKSPACE_DESCRIPTION_FORM_DRAFT: 'workspaceDescriptionFormDraft',
Expand Down Expand Up @@ -418,7 +418,7 @@ type OnyxFormValuesMapping = {
[ONYXKEYS.FORMS.ADD_DEBIT_CARD_FORM]: FormTypes.AddDebitCardForm;
[ONYXKEYS.FORMS.WORKSPACE_SETTINGS_FORM]: FormTypes.WorkspaceSettingsForm;
[ONYXKEYS.FORMS.WORKSPACE_CATEGORY_CREATE_FORM]: FormTypes.WorkspaceCategoryCreateForm;
[ONYXKEYS.FORMS.WORKSPACE_TAG_CREATE_FORM]: FormTypes.WorkspaceTagCreateForm;
[ONYXKEYS.FORMS.WORKSPACE_TAG_FORM]: FormTypes.WorkspaceTagForm;
[ONYXKEYS.FORMS.WORKSPACE_RATE_AND_UNIT_FORM]: FormTypes.WorkspaceRateAndUnitForm;
[ONYXKEYS.FORMS.CLOSE_ACCOUNT_FORM]: FormTypes.CloseAccountForm;
[ONYXKEYS.FORMS.PROFILE_SETTINGS_FORM]: FormTypes.ProfileSettingsForm;
Expand Down
4 changes: 4 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,10 @@ const ROUTES = {
route: 'settings/workspaces/:policyID/tags/edit',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/tags/edit` as const,
},
WORKSPACE_TAG_EDIT: {
route: 'workspace/:policyID/tags/:tagName/edit',
waterim marked this conversation as resolved.
Show resolved Hide resolved
getRoute: (policyID: string, tagName: string) => `workspace/${policyID}/tags/${encodeURI(tagName)}/edit` as const,
waterim marked this conversation as resolved.
Show resolved Hide resolved
},
WORKSPACE_TAXES: {
route: 'settings/workspaces/:policyID/taxes',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/taxes` as const,
Expand Down
1 change: 1 addition & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ const SCREENS = {
TAGS: 'Workspace_Tags',
TAGS_SETTINGS: 'Tags_Settings',
TAGS_EDIT: 'Tags_Edit',
TAG_EDIT: 'Tag_Edit',
TAXES: 'Workspace_Taxes',
TAG_CREATE: 'Tag_Create',
CURRENCY: 'Workspace_Profile_Currency',
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1840,6 +1840,7 @@ export default {
customTagName: 'Custom tag name',
enableTag: 'Enable tag',
addTag: 'Add tag',
editTag: 'Edit tag',
subtitle: 'Tags add more detailed ways to classify costs.',
emptyTags: {
title: "You haven't created any tags",
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1864,6 +1864,7 @@ export default {
customTagName: 'Nombre de etiqueta personalizada',
enableTag: 'Habilitar etiqueta',
addTag: 'Añadir etiqueta',
editTag: 'Editar etiqueta',
luacmartins marked this conversation as resolved.
Show resolved Hide resolved
subtitle: 'Las etiquetas añaden formas más detalladas de clasificar los costos.',
emptyTags: {
title: 'No has creado ninguna etiqueta',
Expand Down
10 changes: 10 additions & 0 deletions src/libs/API/parameters/RenamePolicyTagsParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
type RenamePolicyTagsParams = {
policyID: string;
/**
* Stringified JSON object with type of following structure:
* {[oldName: string]: string;} where value is new tag name
*/
tags: string;
};

export default RenamePolicyTagsParams;
1 change: 1 addition & 0 deletions src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,4 @@ export type {default as OpenPolicyDistanceRatesPageParams} from './OpenPolicyDis
export type {default as OpenPolicyTaxesPageParams} from './OpenPolicyTaxesPageParams';
export type {default as OpenPolicyMoreFeaturesPageParams} from './OpenPolicyMoreFeaturesPageParams';
export type {default as CreatePolicyTagsParams} from './CreatePolicyTagsParams';
export type {default as RenamePolicyTagsParams} from './RenamePolicyTagsParams';
2 changes: 2 additions & 0 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const WRITE_COMMANDS = {
SET_WORKSPACE_CATEGORIES_ENABLED: 'SetWorkspaceCategoriesEnabled',
CREATE_WORKSPACE_CATEGORIES: 'CreateWorkspaceCategories',
CREATE_POLICY_TAG: 'CreatePolicyTag',
RENAME_POLICY_TAG: 'RenamePolicyTag',
SET_WORKSPACE_REQUIRES_CATEGORY: 'SetWorkspaceRequiresCategory',
DELETE_WORKSPACE_CATEGORIES: 'DeleteWorkspaceCategories',
SET_POLICY_REQUIRES_TAG: 'SetPolicyRequiresTag',
Expand Down Expand Up @@ -287,6 +288,7 @@ type WriteCommandParameters = {
[WRITE_COMMANDS.SET_POLICY_REQUIRES_TAG]: Parameters.SetPolicyRequiresTag;
[WRITE_COMMANDS.RENAME_POLICY_TAG_LIST]: Parameters.RenamePolicyTaglist;
[WRITE_COMMANDS.CREATE_POLICY_TAG]: Parameters.CreatePolicyTagsParams;
[WRITE_COMMANDS.RENAME_POLICY_TAG]: Parameters.RenamePolicyTagsParams;
[WRITE_COMMANDS.CREATE_TASK]: Parameters.CreateTaskParams;
[WRITE_COMMANDS.CANCEL_TASK]: Parameters.CancelTaskParams;
[WRITE_COMMANDS.EDIT_TASK_ASSIGNEE]: Parameters.EditTaskAssigneeParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ const SettingsModalStackNavigator = createModalStackNavigator<SettingsNavigatorP
[SCREENS.WORKSPACE.TAGS_SETTINGS]: () => require('../../../pages/workspace/tags/WorkspaceTagsSettingsPage').default as React.ComponentType,
[SCREENS.WORKSPACE.TAGS_EDIT]: () => require('../../../pages/workspace/tags/WorkspaceEditTagsPage').default as React.ComponentType,
[SCREENS.WORKSPACE.TAG_CREATE]: () => require('../../../pages/workspace/tags/WorkspaceCreateTagPage').default as React.ComponentType,
[SCREENS.WORKSPACE.TAG_EDIT]: () => require('../../../pages/workspace/tags/WorkspaceEditTagPage').default as React.ComponentType,
[SCREENS.REIMBURSEMENT_ACCOUNT]: () => require('../../../pages/ReimbursementAccount/ReimbursementAccountPage').default as React.ComponentType,
[SCREENS.GET_ASSISTANCE]: () => require('../../../pages/GetAssistancePage').default as React.ComponentType,
[SCREENS.SETTINGS.TWO_FACTOR_AUTH]: () => require('../../../pages/settings/Security/TwoFactorAuth/TwoFactorAuthPage').default as React.ComponentType,
Expand Down
6 changes: 6 additions & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,12 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[SCREENS.WORKSPACE.TAG_CREATE]: {
path: ROUTES.WORKSPACE_TAG_CREATE.route,
},
[SCREENS.WORKSPACE.TAG_EDIT]: {
path: ROUTES.WORKSPACE_TAG_EDIT.route,
waterim marked this conversation as resolved.
Show resolved Hide resolved
parse: {
tagName: (tagName: string) => decodeURI(tagName),
waterim marked this conversation as resolved.
Show resolved Hide resolved
},
},
[SCREENS.REIMBURSEMENT_ACCOUNT]: {
path: ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.route,
exact: true,
Expand Down
4 changes: 4 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ type SettingsNavigatorParamList = {
policyID: string;
tagName: string;
};
[SCREENS.WORKSPACE.TAG_EDIT]: {
policyID: string;
tagName: string;
};
[SCREENS.WORKSPACE.MEMBER_DETAILS]: {
policyID: string;
accountID: string;
Expand Down
71 changes: 71 additions & 0 deletions src/libs/actions/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2826,6 +2826,76 @@ function createPolicyTag(policyID: string, tagName: string) {
API.write(WRITE_COMMANDS.CREATE_POLICY_TAG, parameters, onyxData);
}

function renamePolicyTag(policyID: string, policyTag: {oldName: string; newName: string}) {
const tagListName = Object.keys(allPolicyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`] ?? {})[0];
const oldTag = allPolicyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`]?.[policyTag.oldName] ?? {};
const onyxData: OnyxData = {
optimisticData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`,
value: {
[tagListName]: {
tags: {
[policyTag.oldName]: null,
[policyTag.newName]: {
...oldTag,
name: policyTag.newName,
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
},
},
},
},
],
successData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`,
value: {
[tagListName]: {
tags: {
[policyTag.oldName]: null,
waterim marked this conversation as resolved.
Show resolved Hide resolved
[policyTag.newName]: {
...oldTag,
waterim marked this conversation as resolved.
Show resolved Hide resolved
name: policyTag.newName,
waterim marked this conversation as resolved.
Show resolved Hide resolved
errors: null,
pendingAction: null,
},
},
},
},
},
],
failureData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`,
value: {
[tagListName]: {
tags: {
[policyTag.newName]: null,
[policyTag.oldName]: {
...oldTag,
name: policyTag.oldName,
errors: ErrorUtils.getMicroSecondOnyxError('workspace.categories.genericFailureMessage'),
pendingAction: null,
waterim marked this conversation as resolved.
Show resolved Hide resolved
},
},
},
},
},
],
};

const parameters = {
policyID,
tags: JSON.stringify({[policyTag.oldName]: policyTag.newName}),
};

API.write(WRITE_COMMANDS.RENAME_POLICY_TAG, parameters, onyxData);
}

function setWorkspaceRequiresCategory(policyID: string, requiresCategory: boolean) {
const onyxData: OnyxData = {
optimisticData: [
Expand Down Expand Up @@ -3589,6 +3659,7 @@ export {
openPolicyDistanceRatesPage,
openPolicyMoreFeaturesPage,
createPolicyTag,
renamePolicyTag,
clearWorkspaceReimbursementErrors,
deleteWorkspaceCategories,
};
2 changes: 1 addition & 1 deletion src/pages/workspace/tags/WorkspaceCreateTagPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
import INPUT_IDS from '@src/types/form/WorkspaceTagCreateForm';
import INPUT_IDS from '@src/types/form/WorkspaceTagForm';
import type {PolicyTagList} from '@src/types/onyx';

type WorkspaceCreateTagPageOnyxProps = {
Expand All @@ -39,8 +39,8 @@
const {inputCallbackRef} = useAutoFocusInput();

const validate = useCallback(
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.WORKSPACE_TAG_CREATE_FORM>) => {

Check failure on line 42 in src/pages/workspace/tags/WorkspaceCreateTagPage.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Property 'WORKSPACE_TAG_CREATE_FORM' does not exist on type '{ readonly ADD_DEBIT_CARD_FORM: "addDebitCardForm"; readonly ADD_DEBIT_CARD_FORM_DRAFT: "addDebitCardFormDraft"; readonly WORKSPACE_SETTINGS_FORM: "workspaceSettingsForm"; ... 78 more ...; readonly POLICY_TAG_NAME_FORM_DRAFT: "policyTagNameFormDraft"; }'. Did you mean 'WORKSPACE_CATEGORY_CREATE_FORM'?
const errors: FormInputErrors<typeof ONYXKEYS.FORMS.WORKSPACE_TAG_CREATE_FORM> = {};

Check failure on line 43 in src/pages/workspace/tags/WorkspaceCreateTagPage.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Property 'WORKSPACE_TAG_CREATE_FORM' does not exist on type '{ readonly ADD_DEBIT_CARD_FORM: "addDebitCardForm"; readonly ADD_DEBIT_CARD_FORM_DRAFT: "addDebitCardFormDraft"; readonly WORKSPACE_SETTINGS_FORM: "workspaceSettingsForm"; ... 78 more ...; readonly POLICY_TAG_NAME_FORM_DRAFT: "policyTagNameFormDraft"; }'. Did you mean 'WORKSPACE_CATEGORY_CREATE_FORM'?
const tagName = values.tagName.trim();
const {tags} = PolicyUtils.getTagList(policyTags, 0);

Expand All @@ -50,7 +50,7 @@
errors.tagName = 'workspace.tags.existingTagError';
} else if ([...tagName].length > CONST.TAG_NAME_LIMIT) {
// Uses the spread syntax to count the number of Unicode code points instead of the number of UTF-16 code units.
ErrorUtils.addErrorMessage(errors, 'tagName', ['common.error.characterLimitExceedCounter', {length: [...tagName].length, limit: CONST.TAG_NAME_LIMIT}]);

Check failure on line 53 in src/pages/workspace/tags/WorkspaceCreateTagPage.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Argument of type 'Partial<Record<string | number | symbol, MaybePhraseKey>>' is not assignable to parameter of type 'Errors'.
}

return errors;
Expand All @@ -59,7 +59,7 @@
);

const createTag = useCallback(
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.WORKSPACE_TAG_CREATE_FORM>) => {

Check failure on line 62 in src/pages/workspace/tags/WorkspaceCreateTagPage.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Property 'WORKSPACE_TAG_CREATE_FORM' does not exist on type '{ readonly ADD_DEBIT_CARD_FORM: "addDebitCardForm"; readonly ADD_DEBIT_CARD_FORM_DRAFT: "addDebitCardFormDraft"; readonly WORKSPACE_SETTINGS_FORM: "workspaceSettingsForm"; ... 78 more ...; readonly POLICY_TAG_NAME_FORM_DRAFT: "policyTagNameFormDraft"; }'. Did you mean 'WORKSPACE_CATEGORY_CREATE_FORM'?
Policy.createPolicyTag(route.params.policyID, values.tagName.trim());
Keyboard.dismiss();
Navigation.goBack();
Expand All @@ -81,7 +81,7 @@
onBackButtonPress={Navigation.goBack}
/>
<FormProvider
formID={ONYXKEYS.FORMS.WORKSPACE_TAG_CREATE_FORM}

Check failure on line 84 in src/pages/workspace/tags/WorkspaceCreateTagPage.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Property 'WORKSPACE_TAG_CREATE_FORM' does not exist on type '{ readonly ADD_DEBIT_CARD_FORM: "addDebitCardForm"; readonly ADD_DEBIT_CARD_FORM_DRAFT: "addDebitCardFormDraft"; readonly WORKSPACE_SETTINGS_FORM: "workspaceSettingsForm"; ... 78 more ...; readonly POLICY_TAG_NAME_FORM_DRAFT: "policyTagNameFormDraft"; }'. Did you mean 'WORKSPACE_CATEGORY_CREATE_FORM'?
onSubmit={createTag}
submitButtonText={translate('common.save')}
validate={validate}
Expand Down
114 changes: 114 additions & 0 deletions src/pages/workspace/tags/WorkspaceEditTagPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import type {StackScreenProps} from '@react-navigation/stack';
waterim marked this conversation as resolved.
Show resolved Hide resolved
import React, {useCallback} from 'react';
import {Keyboard} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
import FormProvider from '@components/Form/FormProvider';
import InputWrapper from '@components/Form/InputWrapper';
import type {FormInputErrors, FormOnyxValues} from '@components/Form/types';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import ScreenWrapper from '@components/ScreenWrapper';
import TextInput from '@components/TextInput';
import useAutoFocusInput from '@hooks/useAutoFocusInput';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as ErrorUtils from '@libs/ErrorUtils';
import Navigation from '@libs/Navigation/Navigation';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as ValidationUtils from '@libs/ValidationUtils';
import type {SettingsNavigatorParamList} from '@navigation/types';
import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper';
import PaidPolicyAccessOrNotFoundWrapper from '@pages/workspace/PaidPolicyAccessOrNotFoundWrapper';
import * as Policy from '@userActions/Policy';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import INPUT_IDS from '@src/types/form/WorkspaceTagForm';
import type {PolicyTagList} from '@src/types/onyx';

type WorkspaceEditTagPageOnyxProps = {
/** All policy tags */
policyTags: OnyxEntry<PolicyTagList>;
};

type EditTagPageProps = WorkspaceEditTagPageOnyxProps & StackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.TAG_EDIT>;

function EditTagPage({route, policyTags}: EditTagPageProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const {inputCallbackRef} = useAutoFocusInput();

const validate = useCallback(
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.WORKSPACE_TAG_CREATE_FORM>) => {

Check failure on line 43 in src/pages/workspace/tags/WorkspaceEditTagPage.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Property 'WORKSPACE_TAG_CREATE_FORM' does not exist on type '{ readonly ADD_DEBIT_CARD_FORM: "addDebitCardForm"; readonly ADD_DEBIT_CARD_FORM_DRAFT: "addDebitCardFormDraft"; readonly WORKSPACE_SETTINGS_FORM: "workspaceSettingsForm"; ... 78 more ...; readonly POLICY_TAG_NAME_FORM_DRAFT: "policyTagNameFormDraft"; }'. Did you mean 'WORKSPACE_CATEGORY_CREATE_FORM'?
const errors: FormInputErrors<typeof ONYXKEYS.FORMS.WORKSPACE_TAG_CREATE_FORM> = {};

Check failure on line 44 in src/pages/workspace/tags/WorkspaceEditTagPage.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Property 'WORKSPACE_TAG_CREATE_FORM' does not exist on type '{ readonly ADD_DEBIT_CARD_FORM: "addDebitCardForm"; readonly ADD_DEBIT_CARD_FORM_DRAFT: "addDebitCardFormDraft"; readonly WORKSPACE_SETTINGS_FORM: "workspaceSettingsForm"; ... 78 more ...; readonly POLICY_TAG_NAME_FORM_DRAFT: "policyTagNameFormDraft"; }'. Did you mean 'WORKSPACE_CATEGORY_CREATE_FORM'?
const tagName = values.tagName.trim();
const {tags} = PolicyUtils.getTagList(policyTags, 0);

if (!ValidationUtils.isRequiredFulfilled(tagName)) {
errors.tagName = 'workspace.tags.tagRequiredError';
} else if (tags?.[tagName]) {
errors.tagName = 'workspace.tags.existingTagError';
} else if ([...tagName].length > CONST.TAG_NAME_LIMIT) {
// Uses the spread syntax to count the number of Unicode code points instead of the number of UTF-16 code units.
ErrorUtils.addErrorMessage(errors, 'tagName', ['common.error.characterLimitExceedCounter', {length: [...tagName].length, limit: CONST.TAG_NAME_LIMIT}]);

Check failure on line 54 in src/pages/workspace/tags/WorkspaceEditTagPage.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Argument of type 'Partial<Record<string | number | symbol, MaybePhraseKey>>' is not assignable to parameter of type 'Errors'.
}

return errors;
},
[policyTags],
);

const editTag = useCallback(
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.WORKSPACE_TAG_CREATE_FORM>) => {

Check failure on line 63 in src/pages/workspace/tags/WorkspaceEditTagPage.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Property 'WORKSPACE_TAG_CREATE_FORM' does not exist on type '{ readonly ADD_DEBIT_CARD_FORM: "addDebitCardForm"; readonly ADD_DEBIT_CARD_FORM_DRAFT: "addDebitCardFormDraft"; readonly WORKSPACE_SETTINGS_FORM: "workspaceSettingsForm"; ... 78 more ...; readonly POLICY_TAG_NAME_FORM_DRAFT: "policyTagNameFormDraft"; }'. Did you mean 'WORKSPACE_CATEGORY_CREATE_FORM'?
Policy.renamePolicyTag(route.params.policyID, {oldName: route.params.tagName, newName: values.tagName.trim()});
Keyboard.dismiss();
Navigation.goBack(ROUTES.WORKSPACE_TAGS.getRoute(route.params.policyID));
},
[route.params.policyID, route.params.tagName],
);

return (
<AdminPolicyAccessOrNotFoundWrapper policyID={route.params.policyID}>
<PaidPolicyAccessOrNotFoundWrapper policyID={route.params.policyID}>
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
style={[styles.defaultModalContainer]}
testID={EditTagPage.displayName}
shouldEnableMaxHeight
>
<HeaderWithBackButton
title={translate('workspace.tags.addTag')}
onBackButtonPress={Navigation.goBack}
/>
<FormProvider
luacmartins marked this conversation as resolved.
Show resolved Hide resolved
formID={ONYXKEYS.FORMS.WORKSPACE_TAG_CREATE_FORM}

Check failure on line 85 in src/pages/workspace/tags/WorkspaceEditTagPage.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Property 'WORKSPACE_TAG_CREATE_FORM' does not exist on type '{ readonly ADD_DEBIT_CARD_FORM: "addDebitCardForm"; readonly ADD_DEBIT_CARD_FORM_DRAFT: "addDebitCardFormDraft"; readonly WORKSPACE_SETTINGS_FORM: "workspaceSettingsForm"; ... 78 more ...; readonly POLICY_TAG_NAME_FORM_DRAFT: "policyTagNameFormDraft"; }'. Did you mean 'WORKSPACE_CATEGORY_CREATE_FORM'?
onSubmit={editTag}
submitButtonText={translate('common.save')}
validate={validate}
style={[styles.mh5, styles.flex1]}
enabledWhenOffline
>
<InputWrapper
InputComponent={TextInput}
maxLength={CONST.TAG_NAME_LIMIT}
label={translate('common.name')}
accessibilityLabel={translate('common.name')}
inputID={INPUT_IDS.TAG_NAME}
role={CONST.ROLE.PRESENTATION}
ref={inputCallbackRef}
/>
</FormProvider>
</ScreenWrapper>
</PaidPolicyAccessOrNotFoundWrapper>
</AdminPolicyAccessOrNotFoundWrapper>
);
}

EditTagPage.displayName = 'EditTagPage';

export default withOnyx<EditTagPageProps, WorkspaceEditTagPageOnyxProps>({
policyTags: {
key: ({route}) => `${ONYXKEYS.COLLECTION.POLICY_TAGS}${route?.params?.policyID}`,
},
})(EditTagPage);
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ const INPUT_IDS = {

type InputID = ValueOf<typeof INPUT_IDS>;

type WorkspaceTagCreateForm = Form<
type WorkspaceTagForm = Form<
InputID,
{
[INPUT_IDS.TAG_NAME]: string;
}
>;

export type {WorkspaceTagCreateForm};
export type {WorkspaceTagForm};
export default INPUT_IDS;
2 changes: 1 addition & 1 deletion src/types/form/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ export type {WorkspaceSettingsForm} from './WorkspaceSettingsForm';
export type {ReportPhysicalCardForm} from './ReportPhysicalCardForm';
export type {WorkspaceDescriptionForm} from './WorkspaceDescriptionForm';
export type {PolicyTagNameForm} from './PolicyTagNameForm';
export type {WorkspaceTagCreateForm} from './WorkspaceTagCreateForm';
export type {WorkspaceTagForm} from './WorkspaceTagForm';
export type {default as Form} from './Form';
Loading