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

Replaced all deprecated classNames with cn function #10605

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/Utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ export const isAppleDevice = _isAppleDevice();
*
* @deprecated Use `cn` from `@/lib/utils` instead.
*/
export const classNames = (...classes: (string | boolean | undefined)[]) => {
return classes.filter(Boolean).join(" ");
};

export const isUserOnline = (user: { last_login: DateLike }) => {
return user.last_login
Expand Down
6 changes: 4 additions & 2 deletions src/components/Common/LanguageSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import careConfig from "@careConfig";
import { useEffect } from "react";
import { useTranslation } from "react-i18next";

import { classNames, keysOf } from "@/Utils/utils";
import { cn } from "@/lib/utils";

import { keysOf } from "@/Utils/utils";
import { LANGUAGES } from "@/i18n";

export const LanguageSelector = (props: any) => {
Expand All @@ -27,7 +29,7 @@ export const LanguageSelector = (props: any) => {
return (
<div className="relative flex items-center">
<select
className={classNames(
className={cn(
props.className,
"w-full cursor-pointer appearance-none rounded-md py-2 pl-2 pr-10 focus:border-primary-500 focus:outline-none focus:ring-primary-500",
)}
Expand Down
6 changes: 4 additions & 2 deletions src/components/Common/LanguageSelectorLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import careConfig from "@careConfig";
import { useEffect } from "react";
import { useTranslation } from "react-i18next";

import { classNames, keysOf } from "@/Utils/utils";
import { cn } from "@/lib/utils";

import { keysOf } from "@/Utils/utils";
import { LANGUAGES } from "@/i18n";

export const LanguageSelectorLogin = () => {
Expand Down Expand Up @@ -32,7 +34,7 @@ export const LanguageSelectorLogin = () => {
<button
key={e}
onClick={() => handleLanguage(e)}
className={classNames(
className={cn(
"text-primary-400 hover:text-primary-600",
(i18n.language === e ||
(i18n.language === "en-US" && e === "en")) &&
Expand Down
9 changes: 3 additions & 6 deletions src/components/Common/UpdatableApp.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Popover, Transition } from "@headlessui/react";
import { ReactNode, useEffect, useState } from "react";

import { cn } from "@/lib/utils";

import CareIcon from "@/CAREUI/icons/CareIcon";

import { Button } from "@/components/ui/button";

import { classNames } from "@/Utils/utils";

const META_URL = "/build-meta.json";
const APP_VERSION_KEY = "app-version";
const APP_UPDATED_KEY = "app-updated";
Expand Down Expand Up @@ -120,10 +120,7 @@ const UpdateAppPopup = ({ onUpdate }: UpdateAppPopupProps) => {
<div className="flex items-center gap-4">
<CareIcon
icon="l-sync"
className={classNames(
"care-l-sync text-2xl",
isUpdating && "animate-spin",
)}
className={cn("care-l-sync text-2xl", isUpdating && "animate-spin")}
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved
/>
<span className="mr-4 flex flex-col">
<p className="font-semibold">Software Update</p>
Expand Down
6 changes: 3 additions & 3 deletions src/components/Users/UserFormValidations.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Trans } from "react-i18next";

import CareIcon from "@/CAREUI/icons/CareIcon";
import { cn } from "@/lib/utils";

import { classNames } from "@/Utils/utils";
import CareIcon from "@/CAREUI/icons/CareIcon";

export type UserType = "doctor" | "nurse" | "staff" | "volunteer";

Expand Down Expand Up @@ -72,7 +72,7 @@ export const validateRule = (
<CareIcon icon="l-times-circle" className="text-sm text-red-500" />
)}{" "}
<span
className={classNames(
className={cn(
isInitialRender
? "text-black text-sm"
: isConditionMet
Expand Down
11 changes: 3 additions & 8 deletions src/components/ui/sidebar/patient-switcher.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { useTranslation } from "react-i18next";

import { cn } from "@/lib/utils";

import {
Select,
SelectContent,
Expand All @@ -13,8 +15,6 @@ import { Avatar } from "@/components/Common/Avatar";

import { usePatientContext } from "@/hooks/usePatientUser";

import { classNames } from "@/Utils/utils";

interface PatientSwitcherProps {
className?: string;
}
Expand All @@ -30,12 +30,7 @@ export function PatientSwitcher({ className }: PatientSwitcherProps) {
}

return (
<div
className={classNames(
"mx-2 mt-4 mb-2 flex flex-wrap flex-row",
className,
)}
>
<div className={cn("mx-2 mt-4 mb-2 flex flex-wrap flex-row", className)}>
<Select
disabled={patientUserContext.patients?.length === 0}
value={
Expand Down
6 changes: 4 additions & 2 deletions src/hooks/useFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { QueryParam, setQueryParamsOptions, useQueryParams } from "raviger";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";

import { cn } from "@/lib/utils";

import GenericFilterBadge from "@/CAREUI/display/FilterBadge";

import PaginationComponent from "@/components/Common/Pagination";

import FiltersCache from "@/Utils/FiltersCache";
import { classNames, humanizeStrings } from "@/Utils/utils";
import { humanizeStrings } from "@/Utils/utils";

export type FilterState = Record<string, unknown>;

Expand Down Expand Up @@ -222,7 +224,7 @@ export default function useFilters({
}
return (
<div
className={classNames(
className={cn(
"flex w-full justify-center",
totalCount > limit ? "visible" : "invisible",
!noMargin && "mt-4",
Expand Down
Loading