Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: online sync plans code refactor & small features #114

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

qamarq
Copy link
Member

@qamarq qamarq commented Dec 11, 2024

This pull request includes various updates and improvements to the frontend codebase, particularly involving the addition of a new tooltip component and the refactoring of plan-related types and functions. The most important changes include adding the @radix-ui/react-tooltip package, refactoring type imports, and enhancing the user interface with tooltips and offline alerts.

Package Updates:

  • Added @radix-ui/react-tooltip version 1.1.4 to package.json and package-lock.json. [1] [2] [3]

Type Refactoring:

  • Refactored type imports in frontend/src/actions/plans.ts to use a centralized types file.

UI Enhancements:

Code Organization:

@qamarq qamarq changed the title feat: new tooltip messages on sync button, alert while log out refactor: online sync plans code refactor & small features Dec 11, 2024
@qamarq qamarq self-assigned this Dec 11, 2024
@qamarq qamarq marked this pull request as ready for review December 11, 2024 18:50

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 6 out of 18 changed files in this pull request and generated no suggestions.

Files not reviewed (12)
  • frontend/package-lock.json: Language not supported
  • frontend/package.json: Language not supported
  • frontend/src/app/plans/edit/[id]/page.client.tsx: Evaluated as low risk
  • frontend/src/app/plans/edit/[id]/page.tsx: Evaluated as low risk
  • frontend/src/app/plans/page.client.tsx: Evaluated as low risk
  • frontend/src/actions/plans.ts: Evaluated as low risk
  • frontend/src/app/plans/page.tsx: Evaluated as low risk
  • frontend/src/app/layout.tsx: Evaluated as low risk
  • frontend/src/lib/usePlan.ts: Evaluated as low risk
  • frontend/src/components/PlanDisplayLink.tsx: Evaluated as low risk
  • frontend/src/app/plans/edit/[id]/_components/SyncedButton.tsx: Evaluated as low risk
  • frontend/src/app/plans/edit/[id]/_components/OfflineAlert.tsx: Evaluated as low risk
Copy link
Member

@Rei-x Rei-x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

widać, że się postarałeś i doceniam za chęci, ale pomyśl nad lepszymi abstrakcjami, jest szansa, że będzie trzeba to bardziej od zera przebudować, bo zarządzanie tym stanem wygląda dość źle

frontend/src/app/layout.tsx Outdated Show resolved Hide resolved
frontend/src/app/layout.tsx Outdated Show resolved Hide resolved
Comment on lines +36 to +47
const message = useMemo(() => {
if (synced && equalsDates) {
return "Zsynchronizowano";
} else if (!(onlineId ?? "")) {
return "Plan dostępny tylko lokalnie";
} else if (syncing) {
return "Synchronizowanie...";
} else if (!equalsDates) {
return "Twoja wersja różni się od wersji online";
}
return "Masz lokalne zmiany";
}, [synced, onlineId, syncing, equalsDates]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zdublowałeś tą logike, jest tutaj i niżej decyduje jaki komponent wyświetlić, wydziel to do jednej funkcji bo to ohydny kod i jestem pewien, że da się go zrobić lepiej

frontend/src/app/plans/edit/[id]/page.client.tsx Outdated Show resolved Hide resolved
frontend/src/app/plans/edit/[id]/page.client.tsx Outdated Show resolved Hide resolved
Comment on lines +173 to +180
useEffect(() => {
resetInactivityTimer();
return () => {
if (inactivityTimeout.current !== null) {
clearTimeout(inactivityTimeout.current);
}
};
}, [plan.name, plan.courses, plan.registrations, plan.allGroups]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nie rozumiem trochę po co refa tutaj użyłeś zamiast wszystko wrzucić do środka tego useEffecta

Comment on lines +14 to +25
<Tooltip>
<TooltipTrigger asChild={true}>
<Button asChild={true} size="icon">
<Link href={`/plans/preview/${id}`}>
<FolderSearch className="size-4" />
</Link>
</Button>
</TooltipTrigger>
<TooltipContent>
<p>Podgląd</p>
</TooltipContent>
</Tooltip>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pamiętaj, że na telefonie tooltipy nie działają, moze zamiast ikonki to napis z ikonką?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Czemu? Przecież jak przytrzymasz to się pojawia. Plus właśnie dlatego dałem ikonki bo za dużo miejsca, chyba że tylko ja tel pokazywać tekst. Wgl zacznijmy od tego że on nie jest bardzo bardzo potrzebny i to bardziej dodatek zważywszy że większość ludzi na kompie wchodzi na to bo wygodniej

frontend/src/lib/usePlan.ts Outdated Show resolved Hide resolved
frontend/src/lib/utils/handleCreateOnlinePlan.ts Outdated Show resolved Hide resolved
Comment on lines 7 to 9
plan: PlanState,
refetchOnlinePlan: () => Promise<T>,
setSyncing: (value: boolean) => void,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jak już masz tyle argumentów to przekazuj obiekt

Suggested change
plan: PlanState,
refetchOnlinePlan: () => Promise<T>,
setSyncing: (value: boolean) => void,
{plan, refetchOnlinePlan, setSyncing}:{plan: PlanState,
refetchOnlinePlan: () => Promise<T>,
setSyncing: (value: boolean) => void}

(to nie zmienia faktu, że z tej abstrakcji aż cieknie)

<CloudIcon className="size-4 text-emerald-500" />
) : !(onlineId ?? "") ? (
<AlertTriangleIcon className="size-4 text-rose-500" />
) : syncing ? (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nie można tutaj jakoś ładniej tego zrobić? Bo te ternary w renderze trochę średnio wyglądają

className="min-w-10"
onClick={() => {
if (!equalsDates) {
bounceAlert();
Copy link
Member

@D0dii D0dii Dec 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Te ify trochę brzydkie na moje

import { useAtom } from "jotai";

import { type ExtendedCourse, planFamily } from "@/atoms/planFamily";

import type { Registration } from "./types";

export interface PlanState {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nie chcemy wszystkich interfejsów razem trzymać w types?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chcemy, lint bartusia nie chce

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jak nie pozwala

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

message: string;
}

export type CourseType = Array<{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pewnie przekopiowałeś to, ale nie możemy zrobić wszędzie interfejsów, żeby spójnie było?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fajnie by bylo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nie da się takiego typu zrobić interfacem niestety

Copy link
Member

@olekszczepanowski olekszczepanowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorka ze tak pozno, wiekszosc zostala juz poprawiona i nie widze niczego co mi nie pasuje

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants