Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2035,6 +2035,7 @@ export default {
tagRequiredError: 'Tag name is required.',
existingTagError: 'A tag with this name already exists.',
genericFailureMessage: 'An error occurred while updating the tag, please try again.',
importedFromAccountingSoftware: 'The tags below are imported from your',
},
taxes: {
subtitle: 'Add tax names, rates, and set defaults.',
Expand Down
3 changes: 2 additions & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1991,7 +1991,7 @@ export default {
categoryRequiredError: 'Lo nombre de la categoría es obligatorio.',
existingCategoryError: 'Ya existe una categoría con este nombre.',
invalidCategoryName: 'Lo nombre de la categoría es invalido.',
importedFromAccountingSoftware: 'Categorías importadas desde',
importedFromAccountingSoftware: 'Etiquetas importadas desde',
},
moreFeatures: {
spendSection: {
Expand Down Expand Up @@ -2062,6 +2062,7 @@ export default {
tagRequiredError: 'Lo nombre de la etiqueta es obligatorio.',
existingTagError: 'Ya existe una etiqueta con este nombre.',
genericFailureMessage: 'Se produjo un error al actualizar la etiqueta, inténtelo nuevamente.',
importedFromAccountingSoftware: 'The tags below are imported from your',
},
taxes: {
subtitle: 'Añade nombres, tasas y establezca valores por defecto para los impuestos.',
Expand Down
53 changes: 31 additions & 22 deletions src/pages/workspace/tags/TagSettingsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type {StackScreenProps} from '@react-navigation/stack';
import React, {useMemo} from 'react';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
import {useOnyx} from 'react-native-onyx';
import ConfirmModal from '@components/ConfirmModal';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import {Trashcan} from '@components/Icon/Expensicons';
Expand All @@ -11,6 +10,8 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback';
import ScreenWrapper from '@components/ScreenWrapper';
import Switch from '@components/Switch';
import Text from '@components/Text';
import TextLink from '@components/TextLink';
import useEnvironment from '@hooks/useEnvironment';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
Expand All @@ -23,24 +24,23 @@ import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper';
import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper';
import PaidPolicyAccessOrNotFoundWrapper from '@pages/workspace/PaidPolicyAccessOrNotFoundWrapper';
import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections';
import withPolicyConnections from '@pages/workspace/withPolicyConnections';
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 type {PolicyTagList} from '@src/types/onyx';

type TagSettingsPageOnyxProps = {
/** All policy tags */
policyTags: OnyxEntry<PolicyTagList>;
};
type TagSettingsPageProps = StackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.TAG_SETTINGS> & WithPolicyConnectionsProps;

type TagSettingsPageProps = TagSettingsPageOnyxProps & StackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.TAG_SETTINGS>;

function TagSettingsPage({route, policyTags}: TagSettingsPageProps) {
function TagSettingsPage({route, policy}: TagSettingsPageProps) {
const policyId = route.params.policyID ?? '';
const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyId}`);
const styles = useThemeStyles();
const {translate} = useLocalize();
const policyTag = useMemo(() => PolicyUtils.getTagList(policyTags, 0), [policyTags]);
const {environmentURL} = useEnvironment();

const {windowWidth} = useWindowDimensions();

Expand All @@ -53,24 +53,24 @@ function TagSettingsPage({route, policyTags}: TagSettingsPageProps) {
}

const deleteTagAndHideModal = () => {
Policy.deletePolicyTags(route.params.policyID, [currentPolicyTag.name]);
Policy.deletePolicyTags(policyId, [currentPolicyTag.name]);
setIsDeleteTagModalOpen(false);
Navigation.goBack();
};

const updateWorkspaceTagEnabled = (value: boolean) => {
setWorkspaceTagEnabled(route.params.policyID, {[currentPolicyTag.name]: {name: currentPolicyTag.name, enabled: value}});
setWorkspaceTagEnabled(policyId, {[currentPolicyTag.name]: {name: currentPolicyTag.name, enabled: value}});
};

const navigateToEditTag = () => {
Navigation.navigate(ROUTES.WORKSPACE_TAG_EDIT.getRoute(route.params.policyID, currentPolicyTag.name));
Navigation.navigate(ROUTES.WORKSPACE_TAG_EDIT.getRoute(policyId, currentPolicyTag.name));
};

return (
<AdminPolicyAccessOrNotFoundWrapper policyID={route.params.policyID}>
<PaidPolicyAccessOrNotFoundWrapper policyID={route.params.policyID}>
<AdminPolicyAccessOrNotFoundWrapper policyID={policyId}>
<PaidPolicyAccessOrNotFoundWrapper policyID={policyId}>
<FeatureEnabledAccessOrNotFoundWrapper
policyID={route.params.policyID}
policyID={policyId}
featureName={CONST.POLICY.MORE_FEATURES.ARE_TAGS_ENABLED}
>
<ScreenWrapper
Expand Down Expand Up @@ -107,7 +107,7 @@ function TagSettingsPage({route, policyTags}: TagSettingsPageProps) {
errors={ErrorUtils.getLatestErrorMessageField(currentPolicyTag)}
pendingAction={currentPolicyTag.pendingFields?.enabled}
errorRowStyles={styles.mh5}
onClose={() => Policy.clearPolicyTagErrors(route.params.policyID, route.params.tagName)}
onClose={() => Policy.clearPolicyTagErrors(policyId, route.params.tagName)}
>
<View style={[styles.mt2, styles.mh5]}>
<View style={[styles.flexRow, styles.mb5, styles.mr2, styles.alignItemsCenter, styles.justifyContentBetween]}>
Expand All @@ -120,6 +120,19 @@ function TagSettingsPage({route, policyTags}: TagSettingsPageProps) {
</View>
</View>
</OfflineWithFeedback>
{Object.keys(policy?.connections ?? {}).length > 0 ? (
<Text>
<Text style={[styles.textNormal, styles.colorMuted]}>{`${translate('workspace.tags.importedFromAccountingSoftware')} `}</Text>
<TextLink
style={[styles.textNormal, styles.link]}
href={`${environmentURL}/${ROUTES.POLICY_ACCOUNTING.getRoute(policyId)}`}
>
{`${translate('workspace.accounting.qbo')} ${translate('workspace.accounting.settings')}`}
</TextLink>
</Text>
) : (
<Text style={[styles.textNormal, styles.colorMuted]}>{translate('workspace.categories.subtitle')}</Text>
)}
<OfflineWithFeedback pendingAction={currentPolicyTag.pendingFields?.name}>
<MenuItemWithTopDescription
title={PolicyUtils.getCleanedTagName(currentPolicyTag.name)}
Expand All @@ -138,8 +151,4 @@ function TagSettingsPage({route, policyTags}: TagSettingsPageProps) {

TagSettingsPage.displayName = 'TagSettingsPage';

export default withOnyx<TagSettingsPageProps, TagSettingsPageOnyxProps>({
policyTags: {
key: ({route}) => `${ONYXKEYS.COLLECTION.POLICY_TAGS}${route.params.policyID}`,
},
})(TagSettingsPage);
export default withPolicyConnections(TagSettingsPage);
1 change: 1 addition & 0 deletions src/pages/workspace/withPolicy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type PolicyRoute = RouteProp<
| typeof SCREENS.WORKSPACE.CARD
| typeof SCREENS.WORKSPACE.OWNER_CHANGE_CHECK
| typeof SCREENS.WORKSPACE.TAX_EDIT
| typeof SCREENS.WORKSPACE.TAG_SETTINGS
>;

function getPolicyIDFromRoute(route: PolicyRoute): string {
Expand Down