Skip to content
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

Draft
wants to merge 30 commits into
base: dev
Choose a base branch
from
Draft

Feat/report button graphql #1471

wants to merge 30 commits into from

Conversation

YongChenSu
Copy link
Collaborator

Close #1380
Close #1379

這個 PR 是?

  1. 更新「面試頁面 / 評價頁面 (experience) 」回報數量顯示。
  2. 更新「公司薪資列表頁面 (companies)」回報數量顯示。
  3. 新增「面試頁面 / 評價頁面 (experience)」回報功能。

Screenshots

image

2025-01-04 23 52 20

有什麼背景知識是我需要知道的?

PRD:
https://goodjoblife.atlassian.net/wiki/spaces/GJ/pages/81133569/PRD

我應該如何手動測試?

  1. 第一次檢舉後理應成功,重複檢舉相同文章會出現「已檢舉」等相關提示。

TODOs

  1. 職稱薪資列表頁面 (job-titles) 待確認是否成功顯示。
  2. 公司薪資列表頁面 / 職稱薪資列表頁面,回報功能待實作。

@YongChenSu
Copy link
Collaborator Author

YongChenSu commented Jan 4, 2025

import 路徑有問題導致 CI fail,但我 local run 起來挺正常的,我再檢查一下。

import styles from './ReportDialog.module.css';
import cn from 'classnames';

const ReportDialog = ({ reportCount, isHighlighted }) => {
Copy link
Contributor

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 })

Copy link
Collaborator Author

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,
};

Copy link
Contributor

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 他是沒有說不能用,但也沒建議用


ReportDialog.propTypes = {
isHighlighted: PropTypes.bool,
reportCount: PropTypes.number,
Copy link
Contributor

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?

Copy link
Contributor

@mark86092 mark86092 Jan 4, 2025

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) && (
Copy link
Contributor

@mark86092 mark86092 Jan 4, 2025

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 的意思嗎?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是為了解決這件事:當 experience.report_count 為 0 時,會顯示 0。因為使用 && 且 0 為 falsy,故顯示 0。

我改成 experience.report_count > 0 ,這樣比較好理解

image

image

@@ -195,6 +209,7 @@ WorkInfoBlocks.propTypes = {
originalCompanyName: PropTypes.string.isRequired,
recommend_to_others: PropTypes.string,
region: PropTypes.string,
report_count: PropTypes.number,
Copy link
Contributor

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!
}

Copy link
Collaborator Author

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(
Copy link
Contributor

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.

Copy link
Collaborator Author

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'));
Copy link
Contributor

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
}
Copy link
Contributor

@mark86092 mark86092 Jan 10, 2025

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
}
Copy link
Contributor

@mark86092 mark86092 Jan 10, 2025

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

@barry800414
Copy link
Contributor

barry800414 commented Jan 11, 2025

@YongChenSu

  1. 是我 spec 沒有寫清楚。沒有任何回報的時候,experience 單篇右上角的 icon 不用顯示。因為顯示卻不能按有點怪。
    Screenshot 2025-01-11 at 11 48 28 AM

  2. 手機版這三顆按鈕會跑版
    Screenshot 2025-01-11 at 11 50 14 AM

  3. 薪資列表的回報按鈕無法按
    Screenshot 2025-01-11 at 11 51 37 AM

  4. 單篇有人回報的情況下,沒有辦法看到內文。預期的行為是可以點進去先看別人的回報,要回報再進行回報
    Screenshot 2025-01-11 at 11 53 01 AM
    Screenshot 2025-01-11 at 11 53 08 AM

@YongChenSu
Copy link
Collaborator Author

@YongChenSu

  1. 是我 spec 沒有寫清楚。沒有任何回報的時候,experience 單篇右上角的 icon 不用顯示。因為顯示卻不能按有點怪。
    Screenshot 2025-01-11 at 11 48 28 AM
  2. 手機版這三顆按鈕會跑版
    Screenshot 2025-01-11 at 11 50 14 AM
  3. 薪資列表的回報按鈕無法按
    Screenshot 2025-01-11 at 11 51 37 AM
  4. 單篇有人回報的情況下,沒有辦法看到內文。預期的行為是可以點進去先看別人的回報,要回報再進行回報
    Screenshot 2025-01-11 at 11 53 01 AM
    Screenshot 2025-01-11 at 11 53 08 AM

謝謝韋銘拉會議說明,經討論後只有 1. 彼此認知不一樣,3. 4. 點彼此理解一樣,是我 PR 描述不夠清楚,我會於該 PR 更新並修正。

@YongChenSu YongChenSu marked this pull request as draft January 12, 2025 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants