Skip to content

Commit

Permalink
feat: add more suggested search aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin9foong committed Dec 2, 2024
1 parent 3e3c248 commit bdbf925
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const checkSearchValueMatchesFieldMeta = (
const lowerCaseSearchValue = searchValue.toLowerCase()
return (
fieldMeta.label.toLowerCase().includes(lowerCaseSearchValue) ||
fieldMeta.alias?.some((alias) =>
alias.toLowerCase().includes(lowerCaseSearchValue),
fieldMeta.searchAliases?.some((searchAlias) =>
searchAlias.toLowerCase().includes(lowerCaseSearchValue),
)
)
}
Expand Down
73 changes: 51 additions & 22 deletions frontend/src/features/admin-form/create/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export type BuilderSidebarFieldMeta = {
icon: As
// Is this fieldType included in submissions?
isSubmitted: boolean
alias?: string[]
searchAliases?: string[]
}

// !!! Do not use this to reference field titles for MyInfo fields. !!!
Expand All @@ -64,42 +64,48 @@ export const BASICFIELD_TO_DRAWER_META: {
label: 'Image',
icon: BiImage,
isSubmitted: false,
alias: ['photo', 'picture'],
searchAliases: ['photo', 'picture'],
},

[BasicField.Statement]: {
label: 'Paragraph',
icon: BiText,
isSubmitted: false,
alias: ['description'],
searchAliases: ['description'],
},

[BasicField.Section]: {
label: 'Heading',
icon: BiHeading,
isSubmitted: false,
alias: ['header', 'title', 'section'],
searchAliases: ['header', 'title', 'section'],
},

[BasicField.Attachment]: {
label: 'Attachment',
icon: BiCloudUpload,
isSubmitted: true,
alias: ['document', 'file', 'upload'],
searchAliases: ['supporting', 'screenshot', 'document', 'file', 'upload'],
},

[BasicField.Checkbox]: {
label: 'Checkbox',
icon: BiSelectMultiple,
isSubmitted: true,
alias: ['choice', 'options', 'multiple'],
searchAliases: [
'choice',
'options',
'multiple',
'declaration',
'acknowledgement',
],
},

[BasicField.Date]: {
label: 'Date',
icon: BiCalendarEvent,
isSubmitted: true,
alias: [
searchAliases: [
'birthdate',
'dob',
'date of birth',
Expand All @@ -114,45 +120,46 @@ export const BASICFIELD_TO_DRAWER_META: {
label: 'Decimal',
icon: BiCalculator,
isSubmitted: true,
alias: ['price', 'amount', 'cost'],
searchAliases: ['price', 'amount', 'cost'],
},

[BasicField.Dropdown]: {
label: 'Dropdown',
icon: BiCaretDownSquare,
isSubmitted: true,
alias: ['choice', 'options', 'category', 'type', 'status'],
searchAliases: ['choice', 'options', 'category', 'type', 'status'],
},

[BasicField.CountryRegion]: {
label: 'Country/Region',
icon: BiFlag,
isSubmitted: true,
alias: ['country', 'region', 'location', 'nationality'],
searchAliases: ['country', 'region', 'location', 'nationality'],
},

[BasicField.Email]: {
label: 'Email',
icon: BiMailSend,
isSubmitted: true,
alias: ['contact'],
searchAliases: ['contact'],
},

[BasicField.HomeNo]: {
label: 'Home number',
icon: BiPhone,
isSubmitted: true,
alias: ['phone', 'contact', 'telephone'],
searchAliases: ['phone', 'contact', 'telephone'],
},

[BasicField.LongText]: {
label: 'Long answer',
icon: BiAlignLeft,
isSubmitted: true,
alias: [
searchAliases: [
'text',
'description',
'comments',
'remarks',
'feedback',
'notes',
'details',
Expand All @@ -165,49 +172,55 @@ export const BASICFIELD_TO_DRAWER_META: {
label: 'Mobile number',
icon: BiMobile,
isSubmitted: true,
alias: ['phone', 'contact', 'telephone'],
searchAliases: ['phone', 'contact', 'telephone', 'sms'],
},

[BasicField.Nric]: {
label: 'NRIC/FIN',
icon: BiUser,
isSubmitted: true,
alias: ['id', 'identification', 'national', 'singpass', 'ic number'],
searchAliases: [
'id',
'identification',
'national',
'singpass',
'ic number',
],
},

[BasicField.Number]: {
label: 'Number',
icon: BiHash,
isSubmitted: true,
alias: ['age', 'quantity', 'count'],
searchAliases: ['age', 'quantity', 'count'],
},

[BasicField.Radio]: {
label: 'Radio',
icon: BiRadioCircleMarked,
isSubmitted: true,
alias: ['choice', 'options', 'mcq', 'multiple'],
searchAliases: ['choice', 'options', 'mcq', 'multiple'],
},

[BasicField.Rating]: {
label: 'Rating',
icon: BiStar,
isSubmitted: true,
alias: ['satisfaction', 'quality', 'performance'],
searchAliases: ['satisfaction', 'quality', 'performance'],
},

[BasicField.ShortText]: {
label: 'Short answer',
icon: BiRename,
isSubmitted: true,
alias: ['name', 'text'],
searchAliases: ['name', 'text'],
},

[BasicField.Table]: {
label: 'Table',
icon: BiTable,
isSubmitted: true,
alias: [
searchAliases: [
'grid',
'spreadsheet',
'list',
Expand All @@ -223,14 +236,29 @@ export const BASICFIELD_TO_DRAWER_META: {
label: 'UEN',
icon: BiBuilding,
isSubmitted: true,
alias: ['business id', 'company registration', 'organization number'],
searchAliases: [
'id',
'business',
'company registration',
'organization',
'corporation',
'unique entity',
'number',
],
},

[BasicField.YesNo]: {
label: 'Yes/No',
icon: BiToggleLeft,
isSubmitted: true,
alias: ['consent', 'agreement', 'confirmation', 'approval', 'accept_terms'],
searchAliases: [
'consent',
'agreement',
'confirmation',
'approve',
'approval',
'accept',
],
},

[BasicField.Children]: {
Expand All @@ -254,6 +282,7 @@ export const MYINFO_FIELD_TO_DRAWER_META: {
label: 'Sex',
icon: BiInfinite,
isSubmitted: true,
searchAliases: ['gender'],
},
[MyInfoAttribute.DateOfBirth]: {
label: 'Date of Birth',
Expand Down

0 comments on commit bdbf925

Please sign in to comment.