Skip to content

Commit

Permalink
Revert "add stricter rules"
Browse files Browse the repository at this point in the history
This reverts commit aed484e.
  • Loading branch information
jthrilly committed Nov 20, 2024
1 parent aed484e commit b1a9ce9
Show file tree
Hide file tree
Showing 87 changed files with 487 additions and 533 deletions.
2 changes: 2 additions & 0 deletions apps/analytics-web/app/_actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export async function getEvents() {

return events;
} catch (error) {
console.error("Error getting events", error);
return [];
}
}
Expand All @@ -24,6 +25,7 @@ export async function insertEvent(event: EventInsertType) {

return { data: insertedEvent, error: null };
} catch (error) {
console.error("Error inserting events", error);
return { data: null, error: "Error inserting events" };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ export default function EventsTable() {
<div className="mt-2 flex items-center justify-between">
<div>
<h2>Events</h2>
{events.length === 0 && <p>Loading...</p>}
{!events.length && <p>Loading...</p>}
</div>
{events.length > 0 && <ExportButton data={events} filename="events.csv" />}
{!!events.length && <ExportButton data={events} filename="events.csv" />}
</div>

<div className="mt-2 rounded-md bg-card">
{events.length > 0 && (
{!!events.length && (
<DataTable columns={getColumns(eventTypes, setEventTypes)} data={filteredEvents} pagination={true} />
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const TableFilter = ({ eventTypes, setEventTypes }: TableFilterProps) => {

return (
<DropdownMenu>
<DropdownMenuTrigger asChild={true}>
<DropdownMenuTrigger asChild>
<Button className="text-sm" size={"sm"} variant="outline">
Type
</Button>
Expand All @@ -43,7 +43,7 @@ const TableFilter = ({ eventTypes, setEventTypes }: TableFilterProps) => {

<div className="space-y-3">
<label
for="all-checkbox"
htmlFor="all-checkbox"
className="flex items-center gap-3 rounded-md p-1 pl-2 text-sm transition-colors hover:bg-muted"
>
<Checkbox
Expand All @@ -57,7 +57,7 @@ const TableFilter = ({ eventTypes, setEventTypes }: TableFilterProps) => {

{options.map((option) => (
<label
for={option.text}
htmlFor={option.text}
key={option.text}
className="flex items-center gap-3 rounded-md p-1 pl-2 text-sm transition-colors hover:bg-muted"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Event } from "~/app/_actions/actions";
import { SummaryCard } from "~/components/SummaryCard";
import { getTotalAppsSetup } from "~/utils/getTotalAppsSetup";

export const TotalAppsCard = ({ events }: { events: Event[] }) => {
const TotalAppsCard = ({ events }: { events: Event[] }) => {
const totalAppsSetup = getTotalAppsSetup(events);
return (
<SummaryCard
Expand All @@ -12,3 +12,5 @@ export const TotalAppsCard = ({ events }: { events: Event[] }) => {
/>
);
};

export default TotalAppsCard;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Event } from "~/app/_actions/actions";
import { SummaryCard } from "~/components/SummaryCard";
import { getTotalDataExported } from "~/utils/getTotalDataExported";

export const TotalDataExported = ({ events }: { events: Event[] }) => {
const TotalDataExported = ({ events }: { events: Event[] }) => {
const totalDataExported = getTotalDataExported(events);
return (
<SummaryCard
Expand All @@ -12,3 +12,5 @@ export const TotalDataExported = ({ events }: { events: Event[] }) => {
/>
);
};

export default TotalDataExported;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Event } from "~/app/_actions/actions";
import { SummaryCard } from "~/components/SummaryCard";
import { getTotalErrors } from "~/utils/getTotalErrors";

export const TotalErrorsCard = ({ events }: { events: Event[] }) => {
const TotalErrorsCard = ({ events }: { events: Event[] }) => {
const totalErrors = getTotalErrors(events);
return (
<SummaryCard
Expand All @@ -12,3 +12,5 @@ export const TotalErrorsCard = ({ events }: { events: Event[] }) => {
/>
);
};

export default TotalErrorsCard;
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import VerifiedUsersTable from "./UsersTable/UsersTable";
export default function UserManagementDialog() {
return (
<Dialog>
<DialogTrigger asChild={true}>
<DialogTrigger asChild>
<Button variant="ghost" size="icon" className="mr-4">
<UsersIcon />
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type VerifyUserSwitchProps = {
verified: boolean;
};

export function VerifyUserSwitch({ id, verified: initialVerified }: VerifyUserSwitchProps) {
export default function VerifyUserSwitch({ id, verified: initialVerified }: VerifyUserSwitchProps) {
const [localVerified, setLocalVerified] = useState(initialVerified);

const updateMetadata = async () => {
Expand All @@ -21,9 +21,11 @@ export function VerifyUserSwitch({ id, verified: initialVerified }: VerifyUserSw

if (!response.ok) {
setLocalVerified(!localVerified);
console.error("Database update failed.");
}
} catch (error) {
setLocalVerified;
console.error("Error updating database:", error);
}
};

Expand Down
1 change: 0 additions & 1 deletion apps/analytics-web/app/api/event/route.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { analyticsEvent } from "@codaco/analytics/src";
import { testApiHandler } from "next-test-api-route-handler";
import { afterEach, describe, expect, it, vi } from "vitest";
// biome-ignore lint/style/noNamespaceImport: intended way to import route handler with test framework
import * as appHandler from "./route";

vi.mock("~/app/_actions/actions", () => {
Expand Down
4 changes: 2 additions & 2 deletions apps/analytics-web/app/verification/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { UserButton, useUser } from "@clerk/nextjs";
import { redirect } from "next/navigation";

export function Verification() {
export default function Verification() {
const { user } = useUser();
const isVerified = user?.publicMetadata?.verified;
if (isVerified) {
Expand All @@ -16,7 +16,7 @@ export function Verification() {
<p>Please contact the site administrator to be verified.</p>
</div>

<UserButton />
<UserButton afterSignOutUrl="/" />
</main>
);
}
2 changes: 1 addition & 1 deletion apps/analytics-web/components/DataTable/column-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function DataTableColumnHeader<TData, TValue>({
return (
<div className={cn("flex items-center space-x-2", className)}>
<DropdownMenu>
<DropdownMenuTrigger asChild={true}>
<DropdownMenuTrigger asChild>
<Button variant="ghost" size="sm" className="-ml-3 h-8 data-[state=open]:bg-accent">
<span>{title}</span>
{column.getIsSorted() === "desc" ? (
Expand Down
2 changes: 1 addition & 1 deletion apps/analytics-web/components/DataTable/data-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function DataTable<TData, TValue>({ columns, data, pagination }: DataTabl
))}
</TableHeader>
<TableBody>
{table.getRowModel().rows?.length > 0 ? (
{table.getRowModel().rows?.length ? (
table.getRowModel().rows.map((row) => (
<TableRow key={row.id} data-state={row.getIsSelected() && "selected"}>
{row.getVisibleCells().map((cell) => (
Expand Down
2 changes: 1 addition & 1 deletion apps/analytics-web/components/DialogButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type DialogButtonProps = {
export function DialogButton({ buttonLabel, title, description, content }: DialogButtonProps) {
return (
<Dialog>
<DialogTrigger asChild={true}>
<DialogTrigger asChild>
<Button variant="outline">{buttonLabel}</Button>
</DialogTrigger>
<DialogContent className="max-h-screen overflow-y-auto">
Expand Down
8 changes: 5 additions & 3 deletions apps/analytics-web/components/ExportButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ type ExportButtonProps = {
filename: string;
};

export const ExportButton: React.FC<ExportButtonProps> = ({ data, filename }) => {
const handleExportCsv = () => {
const ExportButton: React.FC<ExportButtonProps> = ({ data, filename }) => {
const handleExportCSV = () => {
const csvData = Papa.unparse(data);

const blob = new Blob([csvData], { type: "text/csv;charset=utf-8;" });
Expand All @@ -29,8 +29,10 @@ export const ExportButton: React.FC<ExportButtonProps> = ({ data, filename }) =>
};

return (
<Button onClick={handleExportCsv} size="sm">
<Button onClick={handleExportCSV} size="sm">
<Download className="mr-2 h-4 w-4" /> Download Data
</Button>
);
};

export default ExportButton;
4 changes: 2 additions & 2 deletions apps/analytics-web/components/ui/button.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Slot } from "@radix-ui/react-slot";
import { type VariantProps, cva } from "class-variance-authority";
import { forwardRef } from "react";
import * as React from "react";

import { cn } from "~/utils/shadcn";

Expand Down Expand Up @@ -35,7 +35,7 @@ export type ButtonProps = {
} & React.ButtonHTMLAttributes<HTMLButtonElement> &
VariantProps<typeof buttonVariants>;

const Button = forwardRef<HTMLButtonElement, ButtonProps>(
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "button";
return <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />;
Expand Down
2 changes: 1 addition & 1 deletion apps/analytics-web/components/ui/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDiv
);
CardFooter.displayName = "CardFooter";

export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle };
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };
41 changes: 20 additions & 21 deletions apps/analytics-web/components/ui/dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"use client";

// biome-ignore lint/style/noNamespaceImport: <explanation>
import * as DialogPrimitive from "@radix-ui/react-dialog";
import { X } from "lucide-react";
import { forwardRef, type ComponentPropsWithoutRef, type ElementRef, type HTMLAttributes } from "react";
import * as React from "react";

import { cn } from "~/utils/shadcn";

Expand All @@ -15,9 +14,9 @@ const DialogPortal = DialogPrimitive.Portal;

const DialogClose = DialogPrimitive.Close;

const DialogOverlay = forwardRef<
ElementRef<typeof DialogPrimitive.Overlay>,
ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
const DialogOverlay = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Overlay
ref={ref}
Expand All @@ -30,9 +29,9 @@ const DialogOverlay = forwardRef<
));
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;

const DialogContent = forwardRef<
ElementRef<typeof DialogPrimitive.Content>,
ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
const DialogContent = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
>(({ className, children, ...props }, ref) => (
<DialogPortal>
<DialogOverlay />
Expand All @@ -54,19 +53,19 @@ const DialogContent = forwardRef<
));
DialogContent.displayName = DialogPrimitive.Content.displayName;

const DialogHeader = ({ className, ...props }: HTMLAttributes<HTMLDivElement>) => (
const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
<div className={cn("flex flex-col space-y-1.5 text-center sm:text-left", className)} {...props} />
);
DialogHeader.displayName = "DialogHeader";

const DialogFooter = ({ className, ...props }: HTMLAttributes<HTMLDivElement>) => (
const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
<div className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)} {...props} />
);
DialogFooter.displayName = "DialogFooter";

const DialogTitle = forwardRef<
ElementRef<typeof DialogPrimitive.Title>,
ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
const DialogTitle = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Title
ref={ref}
Expand All @@ -76,23 +75,23 @@ const DialogTitle = forwardRef<
));
DialogTitle.displayName = DialogPrimitive.Title.displayName;

const DialogDescription = forwardRef<
ElementRef<typeof DialogPrimitive.Description>,
ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
const DialogDescription = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Description ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
));
DialogDescription.displayName = DialogPrimitive.Description.displayName;

export {
Dialog,
DialogPortal,
DialogOverlay,
DialogClose,
DialogTrigger,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogOverlay,
DialogPortal,
DialogFooter,
DialogTitle,
DialogTrigger,
DialogDescription,
};
Loading

0 comments on commit b1a9ce9

Please sign in to comment.