Skip to content

feature/migrate to Tailwind (shadcn.ui) and Zod #1629

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

Draft
wants to merge 38 commits into
base: master
Choose a base branch
from

Conversation

afternoon2
Copy link
Contributor

@afternoon2 afternoon2 commented Aug 8, 2025

The following PR closes #1550, #1548

Here, we're migrating from React-Bootstrap & Yup to Tailwind-based UI that uses shadcn.ui component set and Zod library with React Hook Form for the form schema validations.

Sneak peek:

Zrzut ekranu 2025-08-8 o 16 48 58

Feel free to run this PR locally to check if things work correctly, comment, and review.

@afternoon2 afternoon2 requested review from grubach and Copilot August 8, 2025 14:52
@afternoon2 afternoon2 self-assigned this Aug 8, 2025
@afternoon2 afternoon2 added improvement javascript Pull requests that update javascript code labels Aug 8, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR migrates the UI from React-Bootstrap and Yup to Tailwind CSS with shadcn/ui components and Zod for form validation. The migration modernizes the styling approach and introduces a more type-safe form validation system.

  • Complete replacement of React-Bootstrap components with Tailwind CSS-based shadcn/ui components
  • Migration from Yup to Zod schema validation for all forms
  • Consolidation of path aliases to use a single @/* pattern for better maintainability

Reviewed Changes

Copilot reviewed 79 out of 80 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
vite.config.ts Adds Tailwind CSS plugin and simplifies path aliases to use @/* pattern
tsconfig.json/tsconfig.app.json Updates path aliases configuration for the new alias pattern
src/index.css Replaces Bootstrap CSS with Tailwind and shadcn/ui theme variables
src/pages/**/index.tsx Migrates all page components from React-Bootstrap/Yup to shadcn/ui/Zod
src/components/ui/* Adds new shadcn/ui component library
src/components/AppNavbar/* Creates new responsive navigation using shadcn/ui components
src/App.tsx Restructures routing and adds new layout components
package.json Updates dependencies to include Tailwind, shadcn/ui, and Zod

Comment on lines +42 to +46
when(payload) {
return schema
.pick({ password: true, repeatedPassword: true })
.safeParse(payload.value).success;
},
Copy link
Preview

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

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

The when method in Zod should be used within a schema definition, not directly on the schema object. This syntax appears incorrect and may cause runtime errors.

Suggested change
when(payload) {
return schema
.pick({ password: true, repeatedPassword: true })
.safeParse(payload.value).success;
},

Copilot uses AI. Check for mistakes.

.object({
login: z.string('Login is required').min(1),
email: z.email('Email is required'),
password: z.string('Password is required').min(8),
Copy link
Preview

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

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

The password minimum length validation (8) is inconsistent with the description that states 'Password must be at least 8 characters long' but the old Yup validation required only 5 characters. Consider updating the description or validation to be consistent.

Copilot uses AI. Check for mistakes.

import { ErrorMessage } from '@/components/ErrorMessage';

const schema = z.object({
loginOrEmail: z.email('Login or email is required').or(z.string().min(1)),
Copy link
Preview

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

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

The schema validation logic is incorrect. The .or() method should come before the error message. The correct syntax should be z.string().email().or(z.string().min(1)) or use z.union().

Suggested change
loginOrEmail: z.email('Login or email is required').or(z.string().min(1)),
loginOrEmail: z.string().email().or(z.string().min(1, 'Login or email is required')),

Copilot uses AI. Check for mistakes.

import { NavLink } from 'react-router';

const schema = z.object({
loginOrEmail: z.email().or(z.string().min(1)),
Copy link
Preview

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

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

The validation logic is incorrect. z.email() will always fail first before trying the .or() alternative. Use z.union([z.string().email(), z.string().min(1)]) or z.string().min(1) with custom validation.

Suggested change
loginOrEmail: z.email().or(z.string().min(1)),
loginOrEmail: z.union([z.string().email(), z.string().min(1)]),

Copilot uses AI. Check for mistakes.

</p>
</div>
<div className="w-full h-[50%] flex flex-col items-center justify-center text-center">
<p className="fs-3">Brought to you by</p>
Copy link
Preview

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

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

The fs-3 class appears to be a Bootstrap class that should be replaced with Tailwind CSS classes like text-3xl to maintain consistency with the migration.

Suggested change
<p className="fs-3">Brought to you by</p>
<p className="text-2xl">Brought to you by</p>

Copilot uses AI. Check for mistakes.

Comment on lines +98 to 102
console.log(
'Mock setup correctly:',
vi.mocked(apiComponents.usePostUserRegister).mock.results[0]?.value
);

Copy link
Preview

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

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

Console.log statements should be removed from test files as they can clutter test output and serve no functional purpose in production code.

Suggested change
console.log(
'Mock setup correctly:',
vi.mocked(apiComponents.usePostUserRegister).mock.results[0]?.value
);

Copilot uses AI. Check for mistakes.

@afternoon2 afternoon2 marked this pull request as draft August 8, 2025 14:55
@afternoon2 afternoon2 linked an issue Aug 8, 2025 that may be closed by this pull request
@adamw adamw requested a review from grubach August 12, 2025 09:17
@adamw
Copy link
Member

adamw commented Aug 12, 2025

@grubach maybe you could take a look, not necessarily at the code in detail, but overall on the library choices - is that something that would be your first pick when writing a simple "CRUD" app?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement javascript Pull requests that update javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate from React Bootstrap UI library Replace Yup with Zod for schema validation
2 participants