Remove payments API routing initialization
[ProtonMail-WebClient.git] / packages / components / containers / filters / constants.ts
blobdd4faaa0fa233b0dd6ad7c71116adde7609d763a
1 import { c } from 'ttag';
3 import { ConditionComparator, ConditionType, FilterStatement } from './interfaces';
4 import type { SelectOption } from './modal/FilterActionsFormFolderRow';
6 export const FILTER_VERSION = 2;
8 export const getConditionTypeLabels = (type: ConditionType) => {
9     switch (type) {
10         case ConditionType.SELECT:
11             return c('Filter modal type').t`Select…`;
12         case ConditionType.SUBJECT:
13             return c('Filter modal type').t`The subject`;
14         case ConditionType.SENDER:
15             return c('Filter modal type').t`The sender`;
16         case ConditionType.RECIPIENT:
17             return c('Filter modal type').t`The recipient`;
18         case ConditionType.ATTACHMENTS:
19             return c('Filter modal type').t`The attachment`;
20         default:
21             return '';
22     }
25 export const getComparatorLabels = (comparator: ConditionComparator) => {
26     switch (comparator) {
27         case ConditionComparator.CONTAINS:
28             return c('Condition for custom filter').t`contains`;
29         case ConditionComparator.IS:
30             return c('Condition for custom filter').t`is exactly`;
31         case ConditionComparator.STARTS:
32             return c('Condition for custom filter').t`begins with`;
33         case ConditionComparator.ENDS:
34             return c('Condition for custom filter').t`ends with`;
35         case ConditionComparator.MATCHES:
36             return c('Condition for custom filter').t`matches`;
37         case ConditionComparator.DOES_NOT_CONTAIN:
38             return c('Condition for custom filter').t`does not contain`;
39         case ConditionComparator.IS_NOT:
40             return c('Condition for custom filter').t`is not`;
41         case ConditionComparator.DOES_NOT_START:
42             return c('Condition for custom filter').t`does not begin with`;
43         case ConditionComparator.DOES_NOT_END:
44             return c('Condition for custom filter').t`does not end with`;
45         case ConditionComparator.DOES_NOT_MATCH:
46             return c('Condition for custom filter').t`does not match`;
47         default:
48             return '';
49     }
52 export const getOperatorLabels = (statement: FilterStatement) => {
53     switch (statement) {
54         case FilterStatement.ALL:
55             return c('Filter modal operators').t`All conditions must be fulfilled (AND)`;
56         case FilterStatement.ANY:
57             return c('Filter modal operators').t`One condition must be fulfilled (OR)`;
58         default:
59             return '';
60     }
63 export const TYPES = [
64     {
65         label: getConditionTypeLabels(ConditionType.SELECT),
66         value: ConditionType.SELECT,
67     },
68     {
69         label: getConditionTypeLabels(ConditionType.SUBJECT),
70         value: ConditionType.SUBJECT,
71     },
72     {
73         label: getConditionTypeLabels(ConditionType.SENDER),
74         value: ConditionType.SENDER,
75     },
76     {
77         label: getConditionTypeLabels(ConditionType.RECIPIENT),
78         value: ConditionType.RECIPIENT,
79     },
80     {
81         label: getConditionTypeLabels(ConditionType.ATTACHMENTS),
82         value: ConditionType.ATTACHMENTS,
83     },
86 export const COMPARATORS = [
87     {
88         label: getComparatorLabels(ConditionComparator.CONTAINS),
89         value: ConditionComparator.CONTAINS,
90     },
91     {
92         label: getComparatorLabels(ConditionComparator.IS),
93         value: ConditionComparator.IS,
94     },
95     {
96         label: getComparatorLabels(ConditionComparator.STARTS),
97         value: ConditionComparator.STARTS,
98     },
99     {
100         label: getComparatorLabels(ConditionComparator.ENDS),
101         value: ConditionComparator.ENDS,
102     },
103     {
104         label: getComparatorLabels(ConditionComparator.MATCHES),
105         value: ConditionComparator.MATCHES,
106     },
107     {
108         label: getComparatorLabels(ConditionComparator.DOES_NOT_CONTAIN),
109         value: ConditionComparator.DOES_NOT_CONTAIN,
110     },
111     {
112         label: getComparatorLabels(ConditionComparator.IS_NOT),
113         value: ConditionComparator.IS_NOT,
114     },
115     {
116         label: getComparatorLabels(ConditionComparator.DOES_NOT_START),
117         value: ConditionComparator.DOES_NOT_START,
118     },
119     {
120         label: getComparatorLabels(ConditionComparator.DOES_NOT_END),
121         value: ConditionComparator.DOES_NOT_END,
122     },
123     {
124         label: getComparatorLabels(ConditionComparator.DOES_NOT_MATCH),
125         value: ConditionComparator.DOES_NOT_MATCH,
126     },
129 export const OPERATORS = [
130     {
131         label: getOperatorLabels(FilterStatement.ALL),
132         value: FilterStatement.ALL,
133     },
134     {
135         label: getOperatorLabels(FilterStatement.ANY),
136         value: FilterStatement.ANY,
137     },
140 export const noFolderValue = '';
141 export const noFolderOption = {
142     type: 'option',
143     text: c('Filter Actions').t`Do not move`,
144     value: noFolderValue,
145 } as SelectOption;
147 export const getDefaultFolders = () => {
148     return [
149         {
150             group: c('Option group').t`Move to...`,
151             text: c('Filter Actions').t`Select a folder`,
152             value: '',
153             disabled: true,
154         },
155         {
156             group: c('Option group').t`Default folders`,
157             text: c('Filter Actions').t`Archive`,
158             value: 'archive',
159         },
160         {
161             group: c('Option group').t`Default folders`,
162             text: c('Filter Actions').t`Inbox`,
163             value: 'inbox',
164         },
165         {
166             group: c('Option group').t`Default folders`,
167             text: c('Filter Actions').t`Spam`,
168             value: 'spam',
169         },
170         {
171             group: c('Option group').t`Default folders`,
172             text: c('Filter Actions').t`Trash`,
173             value: 'trash',
174         },
175     ];
178 export const getDefaultFolderOptions = () => {
179     return [
180         {
181             type: 'label',
182             text: c('Option group').t`Default folders`,
183         },
184         {
185             type: 'option',
186             text: c('Filter Actions').t`Archive`,
187             value: 'archive',
188         },
189         {
190             type: 'option',
191             text: c('Filter Actions').t`Inbox - Default`,
192             value: 'inbox',
193         },
194         {
195             type: 'option',
196             text: c('Filter Actions').t`Spam`,
197             value: 'spam',
198         },
199         {
200             type: 'option',
201             text: c('Filter Actions').t`Trash`,
202             value: 'trash',
203         },
204     ] as SelectOption[];