diff --git a/apps/web/i18n b/apps/web/i18n index ba503674..cbd78835 160000 --- a/apps/web/i18n +++ b/apps/web/i18n @@ -1 +1 @@ -Subproject commit ba503674d334b87abeab9e330a7c88a173cf4980 +Subproject commit cbd788355137bc5bbf4dc8469a0eed981be64166 diff --git a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorTable.tsx b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorTable.tsx index 13a731e0..f9a91dc5 100644 --- a/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorTable.tsx +++ b/apps/web/src/modules/analyze/DataView/MetricDetail/MetricContributor/ContributorTable.tsx @@ -15,19 +15,21 @@ import { } from './contribution'; import { getMaxDomain } from './utils'; import DomainPersona from './DomainPersona'; -import type { ColumnsType, TablePaginationConfig } from 'antd/es/table'; -import type { FilterValue, SorterResult } from 'antd/es/table/interface'; import { useTranslation } from 'next-i18next'; import Download from '@common/components/Table/Download'; import { getContributorPolling, getContributorExport } from '../tableDownload'; import { useRouter } from 'next/router'; import { useHandleQueryParams } from '@modules/analyze/hooks/useHandleQueryParams'; import Dialog from '@common/components/Dialog'; +import Tooltip from '@common/components/Tooltip'; import { FiEdit } from 'react-icons/fi'; import { GrClose } from 'react-icons/gr'; import ManageOrgEdit from '@common/components/OrgEdit/ManageOrgEdit'; import useVerifyDetailRange from '@modules/analyze/hooks/useVerifyDetailRange'; +import { useIsCurrentUser } from '@modules/analyze/hooks/useIsCurrentUser'; +import type { ColumnsType, TablePaginationConfig } from 'antd/es/table'; +import type { FilterValue, SorterResult } from 'antd/es/table/interface'; interface TableParams { pagination?: TablePaginationConfig; filterOpts?: FilterOptionInput[]; @@ -47,7 +49,7 @@ const MetricTable: React.FC<{ const [currentName, setCurrentName] = useState(''); const [currentOrgName, setCurrentOrgName] = useState(''); const { data } = useVerifyDetailRange(); - + const { isCurrentUser } = useIsCurrentUser(); const ecologicalOptions = useEcologicalType(); const mileageOptions = useMileageOptions(); const filterMap = { @@ -131,15 +133,6 @@ const MetricTable: React.FC<{ }); setData(items); }, - // keepPreviousData: true, - // onError(res: any) { - // toast.error( - // getErrorMessage(res) || (() => <>{t('lab:create_failed')}), - // { - // position: 'top-center', - // } - // ); - // }, } ); const handleTableChange = ( @@ -246,21 +239,44 @@ const MetricTable: React.FC<{ align: 'left', width: '160px', render: (text, col) => { + let edit = null; + if (isCurrentUser(col.contributor)) { + edit = ( + { + window.open('/settings/profile'); + }} + /> + ); + } else if (data?.verifyDetailDataRange?.labelAdmin) { + edit = ( + { + setCurrentName(col.contributor); + col.organization && setCurrentOrgName(col.organization); + setOpenConfirm(true); + }} + /> + ); + } else { + edit = ( + {t('analyze:no_role_desc')}} + placement="top" + > +
+ +
+
+ ); + } return (
{text || '-'} - - {data?.verifyDetailDataRange?.labelAdmin && ( - { - setCurrentName(col.contributor); - col.organization && setCurrentOrgName(col.organization); - setOpenConfirm(true); - }} - /> - )} - + {}
); }, diff --git a/apps/web/src/modules/analyze/hooks/useIsCurrentUser.tsx b/apps/web/src/modules/analyze/hooks/useIsCurrentUser.tsx new file mode 100644 index 00000000..2d76e0f6 --- /dev/null +++ b/apps/web/src/modules/analyze/hooks/useIsCurrentUser.tsx @@ -0,0 +1,15 @@ +import { useSnapshot } from 'valtio'; +import { userInfoStore } from '@modules/auth/UserInfoStore'; + +export const useIsCurrentUser = () => { + const { currentUser } = useSnapshot(userInfoStore); + const loginBinds = currentUser?.loginBinds; + + const isCurrentUser = (name) => { + return loginBinds?.find((item) => item.nickname === name); + }; + + return { + isCurrentUser, + }; +}; diff --git a/packages/graphql/src/generated.ts b/packages/graphql/src/generated.ts index bd6ddc3a..f4ba88da 100644 --- a/packages/graphql/src/generated.ts +++ b/packages/graphql/src/generated.ts @@ -4876,8 +4876,6 @@ export type VerifyDetailDataRangeQuery = { verifyDetailDataRange: { __typename?: 'ValidDataRange'; status?: boolean | null; - max?: any | null; - min?: any | null; labelAdmin?: boolean | null; }; }; @@ -8978,8 +8976,6 @@ export const VerifyDetailDataRangeDocument = /*#__PURE__*/ ` endDate: $endDate ) { status - max - min labelAdmin } } diff --git a/packages/graphql/src/gql/query.graphql b/packages/graphql/src/gql/query.graphql index 095e0377..7b083568 100644 --- a/packages/graphql/src/gql/query.graphql +++ b/packages/graphql/src/gql/query.graphql @@ -939,8 +939,6 @@ query verifyDetailDataRange( endDate: $endDate ) { status - max - min labelAdmin } }