-
Notifications
You must be signed in to change notification settings - Fork 11
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
Feat/report button graphql #1471
base: dev
Are you sure you want to change the base?
Conversation
import 路徑有問題導致 CI fail,但我 local run 起來挺正常的,我再檢查一下。 |
import styles from './ReportDialog.module.css'; | ||
import cn from 'classnames'; | ||
|
||
const ReportDialog = ({ reportCount, isHighlighted }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider using ({ reportCount = 0, isHighlighted = false })
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不過我該支檔案的最下方有寫 defaultProps,這樣也需要在參數中加上 parameter 中加上 default 值嗎?
ReportDialog.defaultProps = {
isHighlighted: false,
reportCount: 0,
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
react 給出這樣:https://react.dev/learn/passing-props-to-a-component#specifying-a-default-value-for-a-prop (用參數的預設值來處理)
defaultProps 他是沒有說不能用,但也沒建議用
src/components/CompanyAndJobTitle/TimeAndSalary/ReportDialog.js
Outdated
Show resolved
Hide resolved
src/components/CompanyAndJobTitle/TimeAndSalary/ReportDialog.js
Outdated
Show resolved
Hide resolved
|
||
ReportDialog.propTypes = { | ||
isHighlighted: PropTypes.bool, | ||
reportCount: PropTypes.number, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The graph api has reportCount: Int!
, is there any cases reportCount is null, undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReportDialog
看起來會給 Experience, SalaryWorkTime 使用,建議放在共用的地方,而不是 TimeAndSalary 資料夾
@@ -127,6 +135,12 @@ const WorkInfoBlocks = ({ experience, hideContent }) => { | |||
const expInYearText = formatExperienceInYear(experience.experience_in_year); | |||
return ( | |||
<Fragment> | |||
<div className={styles.reportDialogContainer}> | |||
<ReportDialog reportCount={experience.report_count} /> | |||
{Boolean(experience.report_count) && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Boolean(experience.report_count)
是?這邊是想實作 > 0 的意思嗎?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -195,6 +209,7 @@ WorkInfoBlocks.propTypes = { | |||
originalCompanyName: PropTypes.string.isRequired, | |||
recommend_to_others: PropTypes.string, | |||
region: PropTypes.string, | |||
report_count: PropTypes.number, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
根據 Graphql api, report_count 應該是 PropTypes.number.isRequired
https://github.com/goodjoblife/WorkTimeSurvey-backend/blob/master/schema.graphql#L204-L206
interface Experience {
report_count: Int!
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
喔喔,謝謝,我會再注意 schema 有無帶驚嘆號這件事,謝謝
fetchPermission(); | ||
}, [experienceId, fetchPermission]); | ||
|
||
const renderModalChildren = useCallback( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: We can make it a pure functional component.
const ModalContent = ({ modalState ... }) => {
...
}
so as to avoid nested components in useCallback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made it to a pure func component. Thanks for suggestion.
export const getReports = ({ id }) => | ||
fetchUtil(`/experiences/${id}/reports`) | ||
.get() | ||
.then(R.prop('reports')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以改用 graphql api
query {
experience(id: $id) {
reports {
id
reasonCategory
reason
createdAt
}
}
}
ref: https://github.com/goodjoblife/WorkTimeSurvey-backend/blob/master/schema.graphql#L269-L271
@@ -79,6 +79,9 @@ export const queryJobTitleOverviewGql = /* GraphQL */ ` | |||
salaryWorkTimesResult(start: 0, limit: $salaryWorkTimesLimit) { | |||
count | |||
salaryWorkTimes { | |||
reports { | |||
id | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果是為了拿到數量,最近我有實作給 salaryWorkTime 的 reportCount
可以拿
https://github.com/goodjoblife/WorkTimeSurvey-backend/blob/master/schema.graphql#L729C3-L730
@@ -139,6 +142,9 @@ export const getJobTitleTimeAndSalaryQuery = /* GraphQL */ ` | |||
) { | |||
count | |||
salaryWorkTimes { | |||
reports { | |||
id | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果是為了拿到數量,最近我有實作 reportCount
可以拿
https://github.com/goodjoblife/WorkTimeSurvey-backend/blob/master/schema.graphql#L729C3-L730
謝謝韋銘拉會議說明,經討論後只有 1. 彼此認知不一樣,3. 4. 點彼此理解一樣,是我 PR 描述不夠清楚,我會於該 PR 更新並修正。 |
Close #1380
Close #1379
這個 PR 是?
Screenshots
有什麼背景知識是我需要知道的?
PRD:
https://goodjoblife.atlassian.net/wiki/spaces/GJ/pages/81133569/PRD
我應該如何手動測試?
TODOs