mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-30 12:55:02 +00:00
tweaking documents and measures tables
This commit is contained in:
parent
881364b562
commit
31a1e46661
4 changed files with 11 additions and 10 deletions
|
|
@ -77,7 +77,7 @@ export default function DocumentTable({ data, onOpenDrawer, docStatusMap, portfo
|
|||
() => createDocumentTableColumns(
|
||||
onOpenDrawer,
|
||||
docStatusMap,
|
||||
userCapability === "contractor" ? setUploadDeal : undefined,
|
||||
userCapability.includes("contractor") ? setUploadDeal : undefined,
|
||||
),
|
||||
[onOpenDrawer, docStatusMap, userCapability],
|
||||
);
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ export default function MeasuresTable({
|
|||
<span className="text-xs text-gray-400">
|
||||
{filtered.length} of {dealsWithMeasures.length} properties
|
||||
</span>
|
||||
{userCapability === "approver" && hasPendingChanges && (
|
||||
{userCapability.includes("approver") && hasPendingChanges && (
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={() => setShowConfirm(true)}
|
||||
|
|
@ -389,7 +389,7 @@ export default function MeasuresTable({
|
|||
<div className="flex flex-wrap gap-1.5">
|
||||
{proposed.map((measure) => {
|
||||
const isApproved = approvedSet.has(measure);
|
||||
if (userCapability === "approver") {
|
||||
if (userCapability.includes("approver")) {
|
||||
return (
|
||||
<label
|
||||
key={measure}
|
||||
|
|
|
|||
|
|
@ -123,8 +123,8 @@ export default async function LiveReportingPage(props: {
|
|||
const deals = rawDeals.map(mapDbRowToHubspotDeal);
|
||||
const trackerData = computeLiveTrackerData(deals);
|
||||
|
||||
// Fetch current user's portfolio capability (approver / contractor)
|
||||
let userCapability: PortfolioCapabilityType = null;
|
||||
// Fetch current user's portfolio capabilities (approver / contractor — can have both)
|
||||
let userCapability: PortfolioCapabilityType = [];
|
||||
const userEmail = user?.user?.email;
|
||||
if (userEmail) {
|
||||
const userRow = await db
|
||||
|
|
@ -134,7 +134,7 @@ export default async function LiveReportingPage(props: {
|
|||
.limit(1);
|
||||
|
||||
if (userRow[0]) {
|
||||
const capRow = await db
|
||||
const capRows = await db
|
||||
.select({ capability: portfolioCapabilities.capability })
|
||||
.from(portfolioCapabilities)
|
||||
.where(
|
||||
|
|
@ -142,9 +142,10 @@ export default async function LiveReportingPage(props: {
|
|||
eq(portfolioCapabilities.portfolioId, BigInt(portfolioId)),
|
||||
eq(portfolioCapabilities.userId, userRow[0].id),
|
||||
),
|
||||
)
|
||||
.limit(1);
|
||||
userCapability = (capRow[0]?.capability as PortfolioCapabilityType) ?? null;
|
||||
);
|
||||
userCapability = capRows
|
||||
.map((r) => r.capability)
|
||||
.filter((c): c is "approver" | "contractor" => c === "approver" || c === "contractor");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ export type ProjectData = {
|
|||
// -----------------------------------------------------------------------
|
||||
// Portfolio capability for the current viewing user
|
||||
// -----------------------------------------------------------------------
|
||||
export type PortfolioCapabilityType = "approver" | "contractor" | null;
|
||||
export type PortfolioCapabilityType = ("approver" | "contractor")[];
|
||||
|
||||
// Approved measure names per HubSpot deal ID
|
||||
export type ApprovalsByDeal = Record<string, string[]>;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue