Skip to content

Commit

Permalink
refactor(web): reorganize imports for better readability across compo…
Browse files Browse the repository at this point in the history
…nents
  • Loading branch information
cstrnt committed Feb 28, 2025
1 parent d0e308e commit 92a9c87
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 31 deletions.
18 changes: 9 additions & 9 deletions apps/web/src/components/Test/CreateTestSection.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import { Button } from "components/ui/button";
import { Card, CardContent, CardHeader } from "components/ui/card";
import { Input } from "components/ui/input";
import { cn } from "lib/utils";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "components/ui/select";
import produce from "immer";
import {
type Dispatch,
type SetStateAction,
useState,
useEffect,
useRef,
} from "react";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "components/ui/tooltip";
import produce from "immer";
import { cn } from "lib/utils";
import { RotateCcw } from "lucide-react";
import { PieChart, Plus, Trash2 } from "lucide-react";
import {
type Dispatch,
type SetStateAction,
useEffect,
useRef,
useState,
} from "react";

type Props = {
testName: string;
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Test/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { Button } from "components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "components/ui/card";
import { useFeatureFlag } from "lib/abby";
import { cn } from "lib/utils";
import { ChevronRight, TrashIcon } from "lucide-react";
import { useRouter } from "next/router";
import type { ProjectClientEvents } from "pages/projects/[projectId]";
import { type ReactNode, useState } from "react";
import { toast } from "react-hot-toast";
import { BiInfoCircle } from "react-icons/bi";
import { ChevronRight, TrashIcon } from "lucide-react";
import type { ClientOption } from "server/trpc/router/project";
import { trpc } from "utils/trpc";
import { Metrics } from "./Metrics";
Expand Down
16 changes: 8 additions & 8 deletions apps/web/src/components/Test/Weights.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { Button } from "components/ui/button";
import { Input } from "components/ui/input";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "components/ui/select";
import { Input } from "components/ui/input";
import { useRouter } from "next/router";
import { useState, useMemo, useEffect, useRef } from "react";
import { toast } from "react-hot-toast";
import type { ClientOption } from "server/trpc/router/project";
import { trpc } from "utils/trpc";
import { cn } from "lib/utils";
import { RotateCcw, PieChart } from "lucide-react";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "components/ui/tooltip";
import { cn } from "lib/utils";
import { PieChart, RotateCcw } from "lucide-react";
import { useRouter } from "next/router";
import { useEffect, useMemo, useRef, useState } from "react";
import { toast } from "react-hot-toast";
import type { ClientOption } from "server/trpc/router/project";
import { trpc } from "utils/trpc";

// Distribution color palette using tailwind colors that work well in both modes
const WEIGHT_COLORS = [
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/charts/Donut.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";
import { Label, Pie, PieChart } from "recharts";

import { DOCS_URL } from "@tryabby/core";
import { Card, CardContent, CardFooter } from "components/ui/card";
import {
type ChartConfig,
Expand All @@ -10,10 +11,9 @@ import {
ChartTooltip,
ChartTooltipContent,
} from "components/ui/chart";
import Link from "next/link";
import type { ProjectClientEvents } from "pages/projects/[projectId]";
import { useMemo } from "react";
import Link from "next/link";
import { DOCS_URL } from "@tryabby/core";

export function DonutChart({
totalVisits,
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/ui/tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import * as React from "react";
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
import * as React from "react";

import { cn } from "lib/utils";

Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/pages/projects/[projectId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { FullPageLoadingSpinner } from "components/LoadingSpinner";
import Section from "components/Test/Section";
import { Button } from "components/ui/button";
import { Input } from "components/ui/input";
import Fuse from "fuse.js";
import { useProjectId } from "lib/hooks/useProjectId";
import { Search } from "lucide-react";
import type { GetStaticPaths, GetStaticProps } from "next";
import type { NextPageWithLayout } from "pages/_app";
import { useMemo, useState } from "react";
import { AiOutlinePlus } from "react-icons/ai";
import { Search } from "lucide-react";
import type { AppRouter } from "server/trpc/router/_app";
import { trpc } from "utils/trpc";
import Fuse from "fuse.js";

export type ProjectClientEvents =
inferRouterOutputs<AppRouter>["project"]["getProjectData"]["project"]["tests"][number]["pingEvents"];
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/server/queue/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const EventTypeToRequestType = {
const eventWorker = new Worker<EventJobPayload>(
eventQueue.name,
async ({ data: event }) => {
// TODO: add those to a queue and process them in a background job as they are not critical
switch (event.type) {
case AbbyEventType.PING:
case AbbyEventType.ACT: {
Expand Down
8 changes: 1 addition & 7 deletions packages/core/tests/math.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { validateWeights, getWeightedRandomVariant } from "../src/mathHelpers";
import { getWeightedRandomVariant, validateWeights } from "../src/mathHelpers";

describe("Math helpers", () => {
it("validates weight", () => {
Expand Down Expand Up @@ -40,12 +40,6 @@ describe("Math helpers", () => {
const expectedCount = iterations / 3;
const marginOfError = 0.05 * iterations; // 5% margin of error

console.log({
counts,
expectedCount,
marginOfError,
});

Object.values(counts).forEach((count) => {
expect(count).toBeGreaterThan(expectedCount - marginOfError);
expect(count).toBeLessThan(expectedCount + marginOfError);
Expand Down

0 comments on commit 92a9c87

Please sign in to comment.