Skip to content

Commit

Permalink
feature: sale lead delivery filter exact match
Browse files Browse the repository at this point in the history
  • Loading branch information
aniku777tw committed May 8, 2023
1 parent 1fde34b commit 861e378
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"less-loader": "^7.1.0",
"lint-staged": "^10.5.4",
"lodash": "^4.17.21",
"lodestar-app-element": "urfit-tech/lodestar-app-element#v1.45.0",
"lodestar-app-element": "urfit-tech/lodestar-app-element#v1.46.0",
"md5": "^2.3.0",
"moment": "^2.29.1",
"moment-range": "^4.0.2",
Expand Down
69 changes: 56 additions & 13 deletions src/pages/SalesLeadDeliveryPage/SalesLeadDeliveryPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Icon, { SwapOutlined } from '@ant-design/icons'
import { useMutation, useQuery } from '@apollo/client'
import { Button, Checkbox, DatePicker, Form, Input, Result, Slider, Statistic, Steps } from 'antd'
import { Box, Text } from '@chakra-ui/react'
import { ResultProps } from 'antd/lib/result'
import { gql } from '@apollo/client'
import moment from 'moment'
Expand All @@ -13,6 +14,8 @@ import AdminLayout from '../../components/layout/AdminLayout'
import hasura from '../../hasura'
import { notEmpty } from '../../helpers'
import { salesLeadDeliveryPageMessages } from './translation'
import styled from 'styled-components'
import { DESKTOP_BREAK_POINT } from 'lodestar-app-element/src/components/common/Responsive'

type Filter = {
categoryIds: string[]
Expand All @@ -23,6 +26,8 @@ type Filter = {
starRangeIsNull: boolean
marketingActivity: string
adMaterials: string
isAdMaterialsExactMatch: boolean
isMarketingActivitysExactMatch: boolean
}
type AssignResult = {
status: ResultProps['status']
Expand All @@ -41,6 +46,8 @@ const SalesLeadDeliveryPage: React.VFC = () => {
starRangeIsNull: false,
marketingActivity: '',
adMaterials: '',
isAdMaterialsExactMatch: false,
isMarketingActivitysExactMatch: false,
})
const [updateLeadManager] = useMutation<hasura.UPDATE_LEAD_MANAGER, hasura.UPDATE_LEAD_MANAGERVariables>(
UPDATE_LEAD_MANAGER,
Expand Down Expand Up @@ -103,7 +110,17 @@ const SalesLeadDeliveryPage: React.VFC = () => {
const FilterSection: React.FC<{ filter: Filter; onNext?: (filter: Filter) => void }> = ({ filter, onNext }) => {
const { formatMessage } = useIntl()
const [starRangeIsNull, setStarRangeIsNull] = useState(false)

const ExactMatchCheckBox = styled(Form.Item)`
left: 0%;
bottom: -70%;
display: flex;
position: absolute;
@media (min-width: ${DESKTOP_BREAK_POINT}px) {
bottom: 0%;
left: auto;
right: -120px;
}
`
return (
<Form<Filter>
layout="horizontal"
Expand Down Expand Up @@ -133,17 +150,33 @@ const FilterSection: React.FC<{ filter: Filter; onNext?: (filter: Filter) => voi
<Form.Item label={formatMessage(salesLeadDeliveryPageMessages.salesLeadDeliveryPage.starRange)} name="starRange">
<Slider range min={-999} max={999} disabled={starRangeIsNull} />
</Form.Item>
<Form.Item
label={formatMessage(salesLeadDeliveryPageMessages.salesLeadDeliveryPage.marketingActivity)}
name="marketingActivity"
>
<Input />
<Form.Item label={formatMessage(salesLeadDeliveryPageMessages.salesLeadDeliveryPage.marketingActivity)}>
<Box position="relative" w="100%" display="flex">
<Form.Item name="marketingActivity" style={{ width: '100%' }}>
<Input style={{ width: '100%' }}/>
</Form.Item>
<ExactMatchCheckBox name="isMarketingActivitysExactMatch" valuePropName="checked">
<Checkbox style={{ display: 'flex', alignItems: 'center' }}>
<Text color="var(--gary-dark)" size="sm">
{formatMessage(salesLeadDeliveryPageMessages.salesLeadDeliveryPage.exactMatch)}
</Text>
</Checkbox>
</ExactMatchCheckBox>
</Box>
</Form.Item>
<Form.Item
label={formatMessage(salesLeadDeliveryPageMessages.salesLeadDeliveryPage.adMaterials)}
name="adMaterials"
>
<Input />
<Form.Item label={formatMessage(salesLeadDeliveryPageMessages.salesLeadDeliveryPage.adMaterials)}>
<Box position="relative" w="100%" display="flex">
<Form.Item name="adMaterials" style={{ width: '100%' }}>
<Input style={{ width: '100%' }}/>
</Form.Item>
<ExactMatchCheckBox name="isAdMaterialsExactMatch" valuePropName="checked">
<Checkbox style={{ display: 'flex', alignItems: 'center' }}>
<Text color="var(--gary-dark)" size="sm">
{formatMessage(salesLeadDeliveryPageMessages.salesLeadDeliveryPage.exactMatch)}
</Text>
</Checkbox>
</ExactMatchCheckBox>
</Box>
</Form.Item>
<Form.Item
label={formatMessage(salesLeadDeliveryPageMessages.salesLeadDeliveryPage.createdAtRange)}
Expand Down Expand Up @@ -220,13 +253,23 @@ const ConfirmSection: React.FC<{
{
member_properties:
filter.marketingActivity !== ''
? { property: { name: { _eq: '行銷活動' } }, value: { _like: `%${filter.marketingActivity}%` } }
? {
property: { name: { _eq: '行銷活動' } },
value: filter.isMarketingActivitysExactMatch
? { _eq: `${filter.marketingActivity}` }
: { _like: `%${filter.marketingActivity}%` },
}
: undefined,
},
{
member_properties:
filter.adMaterials !== ''
? { property: { name: { _eq: '廣告素材' } }, value: { _like: `%${filter.adMaterials}%` } }
? {
property: { name: { _eq: '廣告素材' } },
value: filter.isAdMaterialsExactMatch
? { _eq: `${filter.adMaterials}` }
: { _like: `%${filter.adMaterials}%` },
}
: undefined,
},
],
Expand Down
1 change: 1 addition & 0 deletions src/pages/SalesLeadDeliveryPage/translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ export const salesLeadDeliveryPageMessages = {
deliveredCount: { id: 'page.salesLeadDeliveryPage.deliveredCount', defaultMessage: '已派發 {count} 筆名單' },
deliveringMessage: { id: 'page.salesLeadDeliveryPage.deliveringMessage', defaultMessage: '正在派發名單中,請稍等' },
deliverAgain: { id: 'page.salesLeadDeliveryPage.deliverAgain', defaultMessage: '再次派發' },
exactMatch: { id: 'page.salesLeadDeliveryPage.exactMatch', defaultMessage: '完全匹配' },
}),
}
2 changes: 2 additions & 0 deletions src/translations/locales/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,7 @@
"error.text.invalidURL": "Invalid URL",
"error.text.memberAlreadyExist": "Member already exists",
"form.*.endedAt": "截止日期",
"form.*.loading": "Loading...",
"form.*.startedAt": "開始日期",
"form.GiftPlanInput.selectGiftPlan": "選擇贈品方案",
"form.GiftPlanInput.whetherProvideGift": "是否有提供贈品",
Expand Down Expand Up @@ -1867,6 +1868,7 @@
"page.salesLeadDeliveryPage.deliveringMessage": "正在派發名單中,請稍等",
"page.salesLeadDeliveryPage.deliveryConfirm": "確認派發",
"page.salesLeadDeliveryPage.deliveryResult": "派發結果",
"page.salesLeadDeliveryPage.exactMatch": "Exact Match",
"page.salesLeadDeliveryPage.expectedDeliveryAmount": "預計派發名單數",
"page.salesLeadDeliveryPage.field": "領域",
"page.salesLeadDeliveryPage.filterSalesLead": "篩選名單",
Expand Down
2 changes: 2 additions & 0 deletions src/translations/locales/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,7 @@
"error.text.invalidURL": "URL tidak valid",
"error.text.memberAlreadyExist": "Anggota sudah ada",
"form.*.endedAt": "截止日期",
"form.*.loading": "讀取中",
"form.*.startedAt": "開始日期",
"form.GiftPlanInput.selectGiftPlan": "選擇贈品方案",
"form.GiftPlanInput.whetherProvideGift": "是否有提供贈品",
Expand Down Expand Up @@ -1867,6 +1868,7 @@
"page.salesLeadDeliveryPage.deliveringMessage": "正在派發名單中,請稍等",
"page.salesLeadDeliveryPage.deliveryConfirm": "確認派發",
"page.salesLeadDeliveryPage.deliveryResult": "派發結果",
"page.salesLeadDeliveryPage.exactMatch": "完全匹配",
"page.salesLeadDeliveryPage.expectedDeliveryAmount": "預計派發名單數",
"page.salesLeadDeliveryPage.field": "領域",
"page.salesLeadDeliveryPage.filterSalesLead": "篩選名單",
Expand Down
2 changes: 2 additions & 0 deletions src/translations/locales/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,7 @@
"error.text.invalidURL": " URL không hợp lệ ",
"error.text.memberAlreadyExist": " Thành viên đã tồn tại ",
"form.*.endedAt": "截止日期",
"form.*.loading": "讀取中",
"form.*.startedAt": "開始日期",
"form.GiftPlanInput.selectGiftPlan": "選擇贈品方案",
"form.GiftPlanInput.whetherProvideGift": "是否有提供贈品",
Expand Down Expand Up @@ -1867,6 +1868,7 @@
"page.salesLeadDeliveryPage.deliveringMessage": "正在派發名單中,請稍等",
"page.salesLeadDeliveryPage.deliveryConfirm": "確認派發",
"page.salesLeadDeliveryPage.deliveryResult": "派發結果",
"page.salesLeadDeliveryPage.exactMatch": "完全匹配",
"page.salesLeadDeliveryPage.expectedDeliveryAmount": "預計派發名單數",
"page.salesLeadDeliveryPage.field": "領域",
"page.salesLeadDeliveryPage.filterSalesLead": "篩選名單",
Expand Down
2 changes: 2 additions & 0 deletions src/translations/locales/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,7 @@
"error.text.invalidURL": "无效的网址",
"error.text.memberAlreadyExist": "会员已存在",
"form.*.endedAt": "截止日期",
"form.*.loading": "讀取中",
"form.*.startedAt": "開始日期",
"form.GiftPlanInput.selectGiftPlan": "選擇贈品方案",
"form.GiftPlanInput.whetherProvideGift": "是否有提供贈品",
Expand Down Expand Up @@ -1867,6 +1868,7 @@
"page.salesLeadDeliveryPage.deliveringMessage": "正在派發名單中,請稍等",
"page.salesLeadDeliveryPage.deliveryConfirm": "確認派發",
"page.salesLeadDeliveryPage.deliveryResult": "派發結果",
"page.salesLeadDeliveryPage.exactMatch": "完全匹配",
"page.salesLeadDeliveryPage.expectedDeliveryAmount": "預計派發名單數",
"page.salesLeadDeliveryPage.field": "領域",
"page.salesLeadDeliveryPage.filterSalesLead": "篩選名單",
Expand Down
2 changes: 2 additions & 0 deletions src/translations/locales/zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,7 @@
"error.text.invalidURL": "無效的網址",
"error.text.memberAlreadyExist": "會員已存在",
"form.*.endedAt": "截止日期",
"form.*.loading": "讀取中",
"form.*.startedAt": "開始日期",
"form.GiftPlanInput.hasGiftPlan": "有贈品",
"form.GiftPlanInput.noGiftPlan": "無贈品",
Expand Down Expand Up @@ -1871,6 +1872,7 @@
"page.salesLeadDeliveryPage.deliveringMessage": "正在派發名單中,請稍等",
"page.salesLeadDeliveryPage.deliveryConfirm": "確認派發",
"page.salesLeadDeliveryPage.deliveryResult": "派發結果",
"page.salesLeadDeliveryPage.exactMatch": "完全匹配",
"page.salesLeadDeliveryPage.expectedDeliveryAmount": "預計派發名單數",
"page.salesLeadDeliveryPage.field": "領域",
"page.salesLeadDeliveryPage.filterSalesLead": "篩選名單",
Expand Down

0 comments on commit 861e378

Please sign in to comment.