Skip to content

Commit

Permalink
fix: only manager can see star rating
Browse files Browse the repository at this point in the history
  • Loading branch information
Ponchimeow committed Jan 9, 2025
1 parent 54106c0 commit 0ed13f5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/components/sale/SalesLeadTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const StyledDelPhone = styled.p`
const SalesLeadTable: React.VFC<{
variant?: 'followed' | 'completed' | 'resubmission' | 'callbacked'
manager: Manager
currentMemberIsManager: boolean
leads: SalesLeadMember[]
isLoading: boolean
onRefetch: () => Promise<void>
Expand All @@ -116,6 +117,7 @@ const SalesLeadTable: React.VFC<{
}> = ({
variant,
manager,
currentMemberIsManager,
leads,
onRefetch,
onTableChange,
Expand Down Expand Up @@ -557,7 +559,7 @@ const SalesLeadTable: React.VFC<{
</span>
</a>
<small>{lead?.email}</small>
{
{currentMemberIsManager ? (
<div>
<StarRating
value={
Expand All @@ -580,7 +582,7 @@ const SalesLeadTable: React.VFC<{
}}
/>
</div>
}
) : null}
{hasFullNameProperty ? (
<div className="d-flex align-items-center">
<p>{`${formatMessage(saleMessages.SalesLeadTable.memberFullName)}:`}</p>
Expand Down
11 changes: 10 additions & 1 deletion src/components/sale/SalesLeadTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,19 @@ export type SelectedLeadStatusCategory = {

const SalesLeadTabs: React.VFC<{
manager: Manager
currentMemberIsManager: boolean
activeKey: string
selectedLeadStatusCategory: SelectedLeadStatusCategory | null
onActiveKeyChanged: (activeKey: string) => void
onSelectedLeadStatusCategoryChange: (selectedLeadStatusCategory: SelectedLeadStatusCategory | null) => void
}> = ({ activeKey, manager, onActiveKeyChanged, selectedLeadStatusCategory, onSelectedLeadStatusCategoryChange }) => {
}> = ({
activeKey,
manager,
currentMemberIsManager,
onActiveKeyChanged,
selectedLeadStatusCategory,
onSelectedLeadStatusCategoryChange,
}) => {
const { settings } = useApp()
const [demoTabState, setDemoTabState] = useState<'INVITED' | 'PRESENTED' | null>(null)
const [contactedTabState, setContactedTabState] = useState<'ANSWERED' | 'CONTACTED' | null>(null)
Expand Down Expand Up @@ -117,6 +125,7 @@ const SalesLeadTabs: React.VFC<{
<SalesLeadTable
title={salesLeadTableTitle}
variant={salesLeadTableVariant}
currentMemberIsManager={currentMemberIsManager}
manager={manager}
selectedLeadStatusCategoryId={selectedLeadStatusCategory?.categoryId}
onRefetch={async () => await refetch?.()}
Expand Down
3 changes: 3 additions & 0 deletions src/pages/SalesLeadPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ const SalesLeadPage: React.VFC = () => {
const manager =
managers.find(manager => manager.id === managerId) || (permissions.SALES_LEAD_ADMIN ? managers?.[0] : null)

const currentMemberIsManager = managers.some(manager => manager.id === currentMemberId)

if (!enabledModules.sales || (!permissions.SALES_LEAD_ADMIN && !permissions.SALES_LEAD_NORMAL && !manager)) {
return <ForbiddenPage />
}
Expand Down Expand Up @@ -86,6 +88,7 @@ const SalesLeadPage: React.VFC = () => {
<SalesLeadTabs
activeKey={activeKey}
manager={manager}
currentMemberIsManager={currentMemberIsManager}
onActiveKeyChanged={setActiveKey}
selectedLeadStatusCategory={selectedLeadStatusCategory}
onSelectedLeadStatusCategoryChange={selectedLeadStatusCategory =>
Expand Down

0 comments on commit 0ed13f5

Please sign in to comment.