Skip to content

Commit 5c728fb

Browse files
committed
feat(web): fixed type errors and updated turbo.json
1 parent ae4bd26 commit 5c728fb

8 files changed

Lines changed: 57 additions & 57 deletions

File tree

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Suspense } from "react";
12
import PageClient from "./page-client";
23

34
export const metadata = {
@@ -6,7 +7,15 @@ export const metadata = {
67
};
78

89
function Page() {
9-
return <PageClient />;
10+
<Suspense
11+
fallback={
12+
<div className="flex min-h-screen items-center justify-center">
13+
<p>Loading...</p>
14+
</div>
15+
}
16+
>
17+
<PageClient />
18+
</Suspense>;
1019
}
1120

1221
export default Page;

apps/web/app/(main)/projects/[project]/flags/[flag]/page-client.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function PageClient() {
3636
const { currentEnvironment, allEnvironments } = useCurrentEnvironment();
3737

3838
// This is the project/workspace active environment, the actual Writable Environment
39-
const USER_WORKSPACE_ENV = currentEnvironment.name;
39+
const USER_WORKSPACE_ENV = currentEnvironment?.name;
4040

4141
// This tracks the environment currently displayed in the CONFIG section dropdown.
4242
const [viewingEnvironmentName, setViewingEnvironmentName] = useState<
@@ -45,7 +45,7 @@ function PageClient() {
4545

4646
// This derives the environment name used for the API call and display.
4747
const displayEnvironmentName =
48-
viewingEnvironmentName || currentEnvironment?.name;
48+
viewingEnvironmentName || currentEnvironment?.name || "development";
4949

5050
const isEditable = displayEnvironmentName === USER_WORKSPACE_ENV;
5151

@@ -239,7 +239,10 @@ function PageClient() {
239239

240240
const handleRuleOrderUpdate = useCallback(
241241
(newRules: TargetingRule[]) => {
242-
const ruleIdsInNewOrder = newRules.map((r) => r.id);
242+
const ruleIdsInNewOrder = newRules
243+
.map((r) => r.id)
244+
.filter((id): id is string => Boolean(id));
245+
243246
reorderRulesMutation.mutate({ ruleIdsInNewOrder });
244247
},
245248
[reorderRulesMutation]

apps/web/app/(main)/projects/[project]/flags/page-client.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function FlagsPageClient() {
2828
isLoading,
2929
isError,
3030
} = useQuery<FlagType[]>({
31-
queryKey: projectId ? QUERY_KEYS.FLAGS(projectId) : undefined,
31+
queryKey: QUERY_KEYS.FLAGS(projectId),
3232
queryFn: () =>
3333
api.get(`/api/flags?projectId=${projectId}`).then((res) => res.data),
3434
enabled: Boolean(projectId),
@@ -62,7 +62,7 @@ function FlagsPageClient() {
6262
);
6363

6464
const handleCreateFlag = (key: string, description: string) => {
65-
if (flags.some((flag) => flag.key === key)) {
65+
if (flagList.some((flag) => flag.key === key)) {
6666
toast.error(`Flag with key '${key}' already exists.`);
6767
return;
6868
}

apps/web/app/(main)/projects/[project]/page-client.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,26 @@ export default function ProjectDashboardPage() {
2121
enabled: !!projectId,
2222
});
2323

24+
if (isLoading) {
25+
return (
26+
<div>
27+
<DashboardSkeleton />
28+
</div>
29+
);
30+
}
31+
32+
if (isError || !data) {
33+
return (
34+
<div className="flex flex-col items-center justify-center py-16 text-center text-red-600">
35+
<h2 className="mb-2 font-semibold text-xl">Failed to Load Dashboard</h2>
36+
<p className="text-gray-600">
37+
We couldn't retrieve the project metrics. Please check your connection
38+
or try again.
39+
</p>
40+
</div>
41+
);
42+
}
43+
2444
const METRICS_MAP: {
2545
[key in keyof typeof data.metrics]: {
2646
title: string;
@@ -55,26 +75,6 @@ export default function ProjectDashboardPage() {
5575
},
5676
};
5777

58-
if (isLoading) {
59-
return (
60-
<div>
61-
<DashboardSkeleton />
62-
</div>
63-
);
64-
}
65-
66-
if (isError || !data) {
67-
return (
68-
<div className="flex flex-col items-center justify-center py-16 text-center text-red-600">
69-
<h2 className="mb-2 font-semibold text-xl">Failed to Load Dashboard</h2>
70-
<p className="text-gray-600">
71-
We couldn't retrieve the project metrics. Please check your connection
72-
or try again.
73-
</p>
74-
</div>
75-
);
76-
}
77-
7878
const dashboardMetrics = (
7979
Object.keys(data.metrics) as Array<keyof typeof data.metrics>
8080
).map((key) => {

apps/web/components/flags/main/sortable-rule-list.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const arrayMove = <T,>(arr: T[], from: number, to: number): T[] => {
1717
};
1818

1919
type SortableItemProps = {
20-
rule: TargetingRule;
20+
rule: TargetingRule & { id: string };
2121
variations: FlagVariation[];
2222
isEditable: boolean;
2323
isDeletingRule: boolean;
@@ -82,7 +82,10 @@ export const SortableRuleList = ({
8282
onRuleOrderChange,
8383
...cardProps
8484
}: SortableRuleListProps) => {
85-
const ruleIds = rules.map((r) => r.id);
85+
const validRules = rules.filter((r): r is TargetingRule & { id: string } =>
86+
Boolean(r.id)
87+
);
88+
const ruleIds = validRules.map((r) => r.id);
8689

8790
const handleDragEnd = (event: DragEndEvent) => {
8891
const { active, over } = event;
@@ -101,7 +104,7 @@ export const SortableRuleList = ({
101104
<DndContext collisionDetection={closestCenter} onDragEnd={handleDragEnd}>
102105
<SortableContext items={ruleIds} strategy={verticalListSortingStrategy}>
103106
<div className="space-y-3">
104-
{rules.map((rule) => (
107+
{validRules.map((rule) => (
105108
<SortableItem key={rule.id} rule={rule} {...cardProps} />
106109
))}
107110
</div>

apps/web/lib/flagix.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

apps/web/next.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1+
import path from "node:path";
2+
import { fileURLToPath } from "node:url";
3+
4+
const __filename = fileURLToPath(import.meta.url);
5+
const __dirname = path.dirname(__filename);
6+
17
/** @type {import('next').NextConfig} */
28
const nextConfig = {
9+
outputFileTracingRoot: path.join(__dirname, "../../"),
10+
transpilePackages: [
11+
"@flagix/react",
12+
"@flagix/js-sdk",
13+
"@flagix/evaluation-core",
14+
],
315
images: {
416
remotePatterns: [
517
{

turbo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"build": {
66
"dependsOn": ["^build"],
77
"inputs": ["$TURBO_DEFAULT$", ".env*"],
8-
"outputs": [".next/**", "!.next/cache/**"]
8+
"outputs": [".next/**", "!.next/cache/**", "dist/**"]
99
},
1010
"lint": {
1111
"dependsOn": ["^lint"]

0 commit comments

Comments
 (0)