diff --git a/src/widgets/adding-mods-dialog/ui/AddingModsDialog.tsx b/src/widgets/adding-mods-dialog/ui/AddingModsDialog.tsx index e1691d6a..9dfdd64b 100644 --- a/src/widgets/adding-mods-dialog/ui/AddingModsDialog.tsx +++ b/src/widgets/adding-mods-dialog/ui/AddingModsDialog.tsx @@ -34,14 +34,14 @@ interface ProfileModDialog { profile?: ProfileExtendedBaseEntity; modDirection: string; modType: ModType; + disabled: boolean; } -export function AddingModsDialog({ profile, modDirection, modType }: ProfileModDialog) { +export function AddingModsDialog({ profile, modDirection, modType, disabled }: ProfileModDialog) { const form = useForm(); const [searchQuery, setSearchQuery] = useState(''); const { ref, inView } = useInView(); - // Используем useCallback для мемоизации функции поиска const handleSearch = useCallback( debounce((query: string) => { setSearchQuery(query); @@ -52,19 +52,16 @@ export function AddingModsDialog({ profile, modDirection, modType }: ProfileModD const { data: searchMods, status, - error, fetchNextPage, refetch, } = useSearchMods(profile?.profileName ?? '', searchQuery, modType); - // Эффект для автоматического поиска при изменении searchQuery useEffect(() => { if (searchQuery) { refetch(); } }, [searchQuery, refetch]); - // Эффект для пагинации useEffect(() => { if (inView) { fetchNextPage(); @@ -75,22 +72,21 @@ export function AddingModsDialog({ profile, modDirection, modType }: ProfileModD handleSearch(content.name); }; - // Добавляем обработчик изменений инпута для живого поиска const handleInputChange = (e: React.ChangeEvent) => { handleSearch(e.target.value); }; return ( - - @@ -100,26 +96,30 @@ export function AddingModsDialog({ profile, modDirection, modType }: ProfileModD {modDirection} - + {modType === 1 ? ( <> - Modrinth + Modrinth Modrinth ) : ( <> - Curseforge + Curseforge CurseForge )} - + Minecraft: {profile?.minecraftVersion} - + Загрузчик: {profile?.launchVersion} - + Фильтр: Mods @@ -139,7 +139,7 @@ export function AddingModsDialog({ profile, modDirection, modType }: ProfileModD @@ -152,20 +152,22 @@ export function AddingModsDialog({ profile, modDirection, modType }: ProfileModD
- + - +

{mod?.name} - - + + {formatNumber(mod?.downloadCount)} - - + + {formatNumber(mod?.followsCount)}

@@ -181,12 +183,12 @@ export function AddingModsDialog({ profile, modDirection, modType }: ProfileModD ))}
- +
) : (
- +

Ничего не найдено

Попробуйте изменить запрос или проверьте параметры фильтрации. diff --git a/src/widgets/client-hub/ui/DownloadClientHub.tsx b/src/widgets/client-hub/ui/DownloadClientHub.tsx index eec4be59..20c34a88 100644 --- a/src/widgets/client-hub/ui/DownloadClientHub.tsx +++ b/src/widgets/client-hub/ui/DownloadClientHub.tsx @@ -7,25 +7,14 @@ import { ArrowBigDownDash, ChevronsUpDown, Package2Icon } from 'lucide-react'; import { useConnectionHub } from '../lib/useConnectionHub'; -import { - JavaVersionBaseEntity, - ProfileExtendedBaseEntity, - RestoreProfileSchemaType, -} from '@/shared/api/contracts'; +import { JavaVersionBaseEntity, ProfileExtendedBaseEntity, RestoreProfileSchemaType, } from '@/shared/api/contracts'; import { cn } from '@/shared/lib/utils'; import { Button } from '@/shared/ui/button'; import { Progress } from '@/shared/ui/progress'; import { Textarea } from '@/shared/ui/textarea'; import { Icons } from '@/shared/ui/icons'; import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/shared/ui/form'; -import { - Command, - CommandEmpty, - CommandGroup, - CommandInput, - CommandItem, - CommandList, -} from '@/shared/ui/command'; +import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from '@/shared/ui/command'; import { Separator } from '@/shared/ui/separator'; import { Popover, PopoverContent, PopoverTrigger } from '@/shared/ui/popover'; @@ -87,8 +76,8 @@ export function DownloadClientHub(props: DownloadClientHubProps) { Управление {!isConnected && Подключение к консоли...} -

- {/* Карточка 1 шаг */} +
@@ -118,12 +107,12 @@ export function DownloadClientHub(props: DownloadClientHubProps) { ? `${(JSON.parse(field.value) as JavaVersionBaseEntity).name}@${(JSON.parse(field.value) as JavaVersionBaseEntity).version}` : 'По умолчанию'} - + - + Версия не найдена @@ -142,7 +131,7 @@ export function DownloadClientHub(props: DownloadClientHubProps) {
- + {javaVersions.data && javaVersions.data.map((version, i) => ( - + )} /> @@ -183,8 +172,8 @@ export function DownloadClientHub(props: DownloadClientHubProps) { !isConnected || isDisable || !props.profile || !props.profile.hasUpdate } > - {isDisable && } - + {isDisable && } + Загрузить
@@ -192,9 +181,9 @@ export function DownloadClientHub(props: DownloadClientHubProps) { - {/* Карточка 2 шаг */}
-
+
Шаг второй

@@ -207,8 +196,8 @@ export function DownloadClientHub(props: DownloadClientHubProps) { onClick={onBuildDistributive} disabled={!isConnected || isDisable || !props.profile || !props.profile.hasUpdate} > - {isDisable && } - + {isDisable && } + Собрать

@@ -250,8 +239,8 @@ export function DownloadClientHub(props: DownloadClientHubProps) { Общий прогресс: {percentAllStages}%
- - + +
diff --git a/src/widgets/game-mods/ui/GameMods.tsx b/src/widgets/game-mods/ui/GameMods.tsx index 6b000297..5a639dbd 100644 --- a/src/widgets/game-mods/ui/GameMods.tsx +++ b/src/widgets/game-mods/ui/GameMods.tsx @@ -1,4 +1,4 @@ -import { FileIcon, PlusIcon, MagnifyingGlassIcon } from '@radix-ui/react-icons'; +import { FileIcon, MagnifyingGlassIcon, PlusIcon } from '@radix-ui/react-icons'; import React from 'react'; import { clsx } from 'clsx'; @@ -15,6 +15,7 @@ import { Button } from '@/shared/ui/button'; import { EntityState, ModType } from '@/shared/enums'; import { Card, CardContent, CardHeader } from '@/shared/ui/card'; import { GameModItem } from '@/widgets/game-mods/ui/GameModItem'; +import { useProfileCardStore } from "@/entities/ProfileCard/lib/store"; interface GameServersParams { profile: ProfileExtendedBaseEntity; @@ -23,12 +24,13 @@ interface GameServersParams { export const GameMods = ({ profile }: GameServersParams) => { const { data: mods } = useMods({ profileName: profile.profileName }); const { data: optionalMods } = useOptionalMods({ profileName: profile.profileName }); + const { state } = useProfileCardStore(); + const { mutateAsync: loadModMutate } = useLoadProfileMods(); const { mutateAsync: removeModMutate } = useRemoveProfileMod(); const { data: detailsMods, isPending } = useDetailsMods(); const MAX_FILE_SIZE = 100 * 1024 * 1024; - // 🔍 Состояние для поиска const [searchQuery, setSearchQuery] = React.useState(''); const handleFileChange = async ( @@ -55,19 +57,23 @@ export const GameMods = ({ profile }: GameServersParams) => { }); }; - const canEditModsList = ![ - EntityState.ENTITY_STATE_ACTIVE, - EntityState.ENTITY_STATE_NEED_COMPILE, - ].includes(profile.state); + const canEditModsList = [ + EntityState.ENTITY_STATE_CREATED, + EntityState.ENTITY_STATE_LOADING, + EntityState.ENTITY_STATE_INITIALIZE, + EntityState.ENTITY_STATE_ERROR, + EntityState.ENTITY_STATE_PACKING, + EntityState.ENTITY_STATE_DISABLED, + ].includes(state || EntityState.ENTITY_STATE_ACTIVE); const removeMod = async (fileName: string) => { await removeModMutate({ profileName: profile.profileName, modName: fileName }); }; - // 🔍 Фильтрация по названию мода const filteredMods = mods?.filter((mod) => mod.name.toLowerCase().includes(searchQuery.toLowerCase()), ); + const filteredOptionalMods = optionalMods?.filter((mod) => mod.name.toLowerCase().includes(searchQuery.toLowerCase()), ); @@ -91,13 +97,11 @@ export const GameMods = ({ profile }: GameServersParams) => { 'blur-sm': canEditModsList, })} > - {/* === Основные моды === */}
Список модов
- {/* 🔍 Поле поиска */}
- + {
- + - + {mod?.name} - + Jar
@@ -144,7 +149,6 @@ export const GameMods = ({ profile }: GameServersParams) => { - {/* === Добавление модов === */}
{ accept=".jar" onChange={(e) => handleFileChange(e, false)} className="hidden" + disabled={canEditModsList} />
- - + + +
- {/* === Опциональные моды === */}
Опциональные моды
@@ -176,7 +191,7 @@ export const GameMods = ({ profile }: GameServersParams) => { {filteredOptionalMods && detailsMods && filteredOptionalMods.length > 0 ? ( filteredOptionalMods.map((mod, index) => ( - + )) ) : ( @@ -196,7 +211,7 @@ export const GameMods = ({ profile }: GameServersParams) => { className="cursor-pointer inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-secondary text-secondary-foreground hover:bg-secondary/80 h-10 px-4 py-2 w-max gap-2" > Загрузить - + { profile={profile} modDirection="optional" modType={ModType.MODRINTH} + disabled={canEditModsList} />