Skip to content

Commit 2caa969

Browse files
authored
fix circuit id not found, return null (#1020)
1 parent ea95365 commit 2caa969

File tree

3 files changed

+7
-5
lines changed
  • src
    • app/app/virtual-lab/[virtualLabId]/[projectId]/workflows/simulate/configure/circuit/[id]
    • entity-configuration/definitions
    • features/small-microcircuit/_components/atoms

3 files changed

+7
-5
lines changed

src/app/app/virtual-lab/[virtualLabId]/[projectId]/workflows/simulate/configure/circuit/[id]/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export default function Page({
3434

3535
const { data: entity } = useSuspenseQuery({
3636
queryKey: [modelId],
37-
queryFn: () => getCircuit({ id: modelId, context: { virtualLabId, projectId } }),
37+
queryFn: () =>
38+
modelId ? getCircuit({ id: modelId, context: { virtualLabId, projectId } }) : null,
3839
});
3940

4041
const {
@@ -52,7 +53,7 @@ export default function Page({
5253
},
5354
});
5455

55-
if (error) {
56+
if (error || !entity) {
5657
return notFound();
5758
}
5859

src/entity-configuration/definitions/renderer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export function RenderCustomField<R extends EntityCoreIdentifiable>({
123123
useEffect(() => {
124124
async function getEntity() {
125125
setPayload({ entity: null, error: null, loading: true });
126-
if (entityConfig && entityConfig.api.query.one) {
126+
if (entityConfig && entityConfig.api.query.one && entityId) {
127127
const { data, error } = await tryCatch<R, any>(
128128
// @ts-ignore
129129
entityConfig.api.query.one({ id: entityId, context: { virtualLabId, projectId } })

src/features/small-microcircuit/_components/atoms/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,9 @@ export const simulationsByCampaignIdAtomFamily = readAtomFamilyWithExpiration(
152152

153153
export const circuitAtomFamily = readAtomFamilyWithExpiration(
154154
({ circuitId, context }: { circuitId: string; context: WorkspaceContext }) =>
155-
atom<Promise<ICircuit>>(async () => {
156-
return getCircuit({ id: circuitId, context });
155+
atom<Promise<ICircuit | null>>(async () => {
156+
if (circuitId) return getCircuit({ id: circuitId, context });
157+
return null;
157158
}),
158159
{
159160
ttl: 120000, // 2 minutes

0 commit comments

Comments
 (0)