feat(platform): checkpoint current implementation state
This commit is contained in:
@@ -5,6 +5,7 @@ import Link from "next/link";
|
||||
import dynamic from "next/dynamic";
|
||||
import { EstimateExportFormat } from "@capakraken/shared";
|
||||
import { clsx } from "clsx";
|
||||
import { useSession } from "next-auth/react";
|
||||
import type {
|
||||
EstimateWorkspaceView,
|
||||
WorkspaceTab,
|
||||
@@ -113,17 +114,19 @@ function ActionNotice({
|
||||
}
|
||||
|
||||
export function EstimateWorkspaceClient({ estimateId }: { estimateId: string }) {
|
||||
const { status: sessionStatus } = useSession();
|
||||
const [tab, setTab] = useState<WorkspaceTab>("overview");
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
const [actionMessage, setActionMessage] = useState<string | null>(null);
|
||||
const [actionError, setActionError] = useState<string | null>(null);
|
||||
const { canEdit, canViewCosts } = usePermissions();
|
||||
const isPermissionsLoading = sessionStatus === "loading";
|
||||
const utils = trpc.useUtils();
|
||||
|
||||
const detailQuery = trpc.estimate.getById.useQuery(
|
||||
{ id: estimateId },
|
||||
{
|
||||
enabled: canViewCosts,
|
||||
enabled: canViewCosts && !isPermissionsLoading,
|
||||
staleTime: 15_000,
|
||||
},
|
||||
);
|
||||
@@ -132,10 +135,16 @@ export function EstimateWorkspaceClient({ estimateId }: { estimateId: string })
|
||||
const createRevisionMutation = trpc.estimate.createRevision.useMutation();
|
||||
const createExportMutation = trpc.estimate.createExport.useMutation();
|
||||
const createPlanningHandoffMutation = trpc.estimate.createPlanningHandoff.useMutation();
|
||||
const estimateCommentTarget = { entityType: "estimate" as const, entityId: estimateId };
|
||||
const canLoadCommentCount =
|
||||
canViewCosts
|
||||
&& !isPermissionsLoading
|
||||
&& detailQuery.status === "success"
|
||||
&& detailQuery.data != null;
|
||||
|
||||
const commentCountQuery = trpc.comment.count.useQuery(
|
||||
{ entityType: "estimate", entityId: estimateId },
|
||||
{ enabled: canViewCosts, staleTime: 30_000 },
|
||||
estimateCommentTarget,
|
||||
{ enabled: canLoadCommentCount, staleTime: 30_000 },
|
||||
);
|
||||
const commentCount = commentCountQuery.data ?? 0;
|
||||
|
||||
@@ -281,7 +290,9 @@ export function EstimateWorkspaceClient({ estimateId }: { estimateId: string })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{!canViewCosts ? (
|
||||
{isPermissionsLoading ? (
|
||||
<EmptyState>Loading estimate workspace...</EmptyState>
|
||||
) : !canViewCosts ? (
|
||||
<EmptyState>Your role can access the estimate list, but not the detailed financial workspace.</EmptyState>
|
||||
) : detailQuery.isLoading ? (
|
||||
<EmptyState>Loading estimate workspace...</EmptyState>
|
||||
@@ -364,7 +375,7 @@ export function EstimateWorkspaceClient({ estimateId }: { estimateId: string })
|
||||
<h2 className="mb-4 text-lg font-semibold text-gray-900 dark:text-gray-50">
|
||||
Comments
|
||||
</h2>
|
||||
<CommentThread entityId={estimate.id} />
|
||||
<CommentThread commentTarget={estimateCommentTarget} />
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user