Skip to content

Commit

Permalink
GL-00: исправлены клиент/серверные компоненты, проведены работы с UX
Browse files Browse the repository at this point in the history
  • Loading branch information
Терентьев Вадим Алексеевич committed May 10, 2024
1 parent 541f343 commit 67c59ad
Show file tree
Hide file tree
Showing 42 changed files with 233 additions and 185 deletions.
14 changes: 7 additions & 7 deletions app/auth/signin/page.tsx → src/app/auth/signin/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Link from 'next/link';
import Link from "next/link";

import { SignInForm } from '@/features/auth-credentials-form';
import { cn } from '@/shared/lib/utils';
import { AUTH_PAGES } from '@/shared/routes';
import { buttonVariants } from '@/shared/ui/button';
import { SignInForm } from "../../../features/auth-credentials-form";
import { cn } from "../../../shared/lib/utils";
import { AUTH_PAGES } from "../../../shared/routes";
import { buttonVariants } from "../../../shared/ui/button";

export default function SignInPage() {
return (
Expand All @@ -12,8 +12,8 @@ export default function SignInPage() {
<Link
href={AUTH_PAGES.SIGN_UP}
className={cn(
buttonVariants({ variant: 'ghost' }),
'absolute right-4 top-4 md:right-8 md:top-8',
buttonVariants({ variant: "ghost" }),
"absolute right-4 top-4 md:right-8 md:top-8",
)}
>
Регистрация
Expand Down
14 changes: 7 additions & 7 deletions app/auth/signup/page.tsx → src/app/auth/signup/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Link from 'next/link';
import Link from "next/link";

import { SignUpForm } from '@/features/auth-credentials-form';
import { cn } from '@/shared/lib/utils';
import { AUTH_PAGES } from '@/shared/routes';
import { buttonVariants } from '@/shared/ui/button';
import { SignUpForm } from "../../../features/auth-credentials-form";
import { cn } from "../../../shared/lib/utils";
import { AUTH_PAGES } from "../../../shared/routes";
import { buttonVariants } from "@/shared/ui/button";

export default function SignUPPage() {
return (
Expand All @@ -12,8 +12,8 @@ export default function SignUPPage() {
<Link
href={AUTH_PAGES.SIGN_IN}
className={cn(
buttonVariants({ variant: 'ghost' }),
'absolute right-4 top-4 md:right-8 md:top-8',
buttonVariants({ variant: "ghost" }),
"absolute right-4 top-4 md:right-8 md:top-8",
)}
>
Войти
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { Metadata } from "next";
import { redirect } from "next/navigation";

import { Button } from "@/shared/ui/button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/shared/ui/card";
import { Input } from "@/shared/ui/input";
import { DASHBOARD_PAGES } from "@/shared/routes";

export const metadata: Metadata = {
title: "Настройки",
};

export default async function SettingsPage() {
redirect(DASHBOARD_PAGES.PROFILES);

return (
<div className="flex flex-col items-start py-4">
<h1 className="text-xl font-bold mb-8">Управление аккаунтом</h1>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Metadata } from "next";

import { IntegrationsPage } from "@/pages/integrations";
import { IntegrationsPage } from "@/views/integrations";

export const metadata: Metadata = {
title: "Интеграции",
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions app/dashboard/page.tsx → src/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { Metadata } from "next";
import { redirect } from "next/navigation";

import { Breadcrumbs } from "@/shared/ui/Breadcrumbs";
import { DASHBOARD_PAGES } from "@/shared/routes";

export const metadata: Metadata = {
title: "Дашборд",
};

export default async function DashboardPage() {
redirect(DASHBOARD_PAGES.PROFILES);

return (
<>
<Breadcrumbs current={"Главная"} />
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Metadata } from "next";

import { ProfilePage } from "@/pages/profile";
import { ProfilePage } from "@/views/profile";

export async function generateMetadata({ params: { name } }: Props): Promise<Metadata> {
return { title: `Настройка профиля ${name}` };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Metadata } from "next";

import { ProfilesPage } from "@/pages/profiles";
import { ProfilesPage } from "@/views/profiles";

export const metadata: Metadata = {
title: "Профили",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Metadata } from "next";

import { SettingsPage } from "@/pages/settings";
import { SettingsPage } from "@/views/settings";

export const metadata: Metadata = {
title: "Настройки платформы",
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions app/layout.tsx → src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import type { Metadata } from "next";
import { Manrope } from "next/font/google";

import "./globals.css";
import { QueryProvider } from "@/app/providers/QueryProvider";
import { ThemeProvider } from "@/app/providers/ThemeProvider";
import { TooltipProvider } from "@/app/providers/TooltipProvider";
import { QueryProvider } from "@/core/providers/QueryProvider";
import { ThemeProvider } from "@/core/providers/ThemeProvider";
import { TooltipProvider } from "@/core/providers/TooltipProvider";
import { cn } from "@/shared/lib/utils";
import { Toaster } from "@/shared/ui/toaster";

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 11 additions & 11 deletions src/entities/IntegrationCard/ui/IntegrationCard.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { ReactNode } from "react";

import { Card } from "@/shared/ui/card";
import { Button } from "@/shared/ui/button";
import { PlugIcon, Settings2 } from "lucide-react";

interface IntegrationCardProps {
title: string;
description?: string;
status?: "CONNECTED" | "UNCONNECTED";
buttonText?: string;
isDisabled?: boolean;
action?: () => void;
dialog?: ReactNode;
}

export const IntegrationCard = (props: IntegrationCardProps) => {
const { title, description, buttonText = "Подключить", status, isDisabled, action } = props;
const { title, description, dialog } = props;

return (
<Card className="flex flex-col justify-between gap-y-8 p-6">
Expand All @@ -22,11 +20,13 @@ export const IntegrationCard = (props: IntegrationCardProps) => {
</div>
{description && <p className="text-sm text-gray-700 dark:text-gray-300">{description}</p>}
</div>
<Button size="sm" variant="outline" className="w-fit" onClick={action} disabled={isDisabled}>
{status === "CONNECTED" && <Settings2 className="mr-2" size={16} />}
{status === "UNCONNECTED" && <PlugIcon className="mr-2" size={16} />}
{buttonText}
</Button>
{dialog ? (
dialog
) : (
<Button size="sm" variant="outline" className="w-fit" disabled>
Отключено
</Button>
)}
</Card>
);
};
19 changes: 9 additions & 10 deletions src/features/connect-textures-form/ui/ConnectTexturesForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,34 @@ import React from "react";

import { Controller, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";

import { cn } from "@/shared/lib/utils";
import { Button } from "@/shared/ui/button";
import { Form, FormControl, FormItem, FormLabel, FormMessage } from "@/shared/ui/form";
import { Input } from "@/shared/ui/input";
import { TexturesServiceType } from "@/shared/enums";
import { useConnectTextures, useEditConnectTextures } from "@/shared/hooks";
import { useEditConnectTextures } from "@/shared/hooks";
import { Icons } from "@/shared/ui/icons";

import { ConnectTexturesFormSchemaType, ConnectTexturesSchema } from "../lib/static";
import { TextureServiceBaseEntity } from "@/shared/api/contracts";

interface ConnectTexturesFormProps extends React.HTMLAttributes<HTMLDivElement> {
skins?: TextureServiceBaseEntity;
cloaks?: TextureServiceBaseEntity;
onOpenChange: (open: boolean) => void;
}

export function ConnectTexturesForm({
className,
skins,
cloaks,
onOpenChange,
...props
}: ConnectTexturesFormProps) {
const { data: textures_skins } = useConnectTextures(TexturesServiceType.TEXTURES_SERVICE_SKINS);
const { data: textures_cloaks } = useConnectTextures(TexturesServiceType.TEXTURES_SERVICE_CLOAKS);

const { mutateAsync, isPending } = useEditConnectTextures();

const form = useForm<ConnectTexturesFormSchemaType>({
values: {
url_skins: textures_skins?.url || "",
url_cloaks: textures_cloaks?.url || "",
url_skins: skins?.url || "",
url_cloaks: cloaks?.url || "",
},
resolver: zodResolver(ConnectTexturesSchema),
});
Expand All @@ -58,7 +57,7 @@ export function ConnectTexturesForm({
};

return (
<div className={cn("grid gap-4", className)} {...props}>
<div className="grid gap-4" {...props}>
<Form {...form}>
<form className="flex flex-col space-y-6" onSubmit={form.handleSubmit(onSubmit)}>
<Controller
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
"use client";

import { SubmitHandler, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
Expand Down
14 changes: 7 additions & 7 deletions src/features/install-client-form/ui/InstallClientForm.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
"use client";

import React from "react";

import { Controller, SubmitHandler, useForm } from "react-hook-form";

import { zodResolver } from "@hookform/resolvers/zod";
Expand All @@ -19,9 +15,11 @@ import { useToast } from "@/shared/ui/use-toast";
import { InstallClientFormSchemaType, InstallClientSchema } from "../lib/static";
import { useConnectionHub } from "../lib/useConnectionHub";

interface InstallClientFormProps extends React.HTMLAttributes<HTMLDivElement> {}
interface InstallClientFormProps extends React.HTMLAttributes<HTMLDivElement> {
onOpenChange: () => void;
}

export function InstallClientForm({ className, ...props }: InstallClientFormProps) {
export function InstallClientForm({ className, onOpenChange, ...props }: InstallClientFormProps) {
const { connectionHub, process, percent } = useConnectionHub();
const { data: branches } = useGithubLauncherVersions();
const { toast } = useToast();
Expand All @@ -36,7 +34,9 @@ export function InstallClientForm({ className, ...props }: InstallClientFormProp
) => {
process.onIsProcessingToggle();
try {
connectionHub?.invoke("Download", data.branch, data.host, data.folder);
connectionHub?.invoke("Download", data.branch, data.host, data.folder).then(() => {
onOpenChange();
});
} catch (error: unknown) {
toast({
variant: "destructive",
Expand Down
2 changes: 1 addition & 1 deletion src/shared/services/AuthService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { $api } from "@/app/api";
import { $api } from "@/core/api";
import {
TPostSignInRequest,
TPostSignInResponse,
Expand Down
2 changes: 1 addition & 1 deletion src/shared/services/IntegrationService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AxiosResponse } from "axios";

import { $api } from "@/app/api";
import { $api } from "@/core/api";
import {
TGetActiveAuthIntegrationsRequest,
TGetActiveAuthIntegrationsResponse,
Expand Down
2 changes: 1 addition & 1 deletion src/shared/services/ProfileService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { $api } from "@/app/api";
import { $api } from "@/core/api";
import {
TDeleteProfileRequest,
TDeleteProfileResponse,
Expand Down
2 changes: 1 addition & 1 deletion src/shared/services/SettingsService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { $api } from "@/app/api";
import { $api } from "@/core/api";
import {
TGetSettingsPlatformRequest,
TGetSettingsPlatformResponse,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,33 +1,14 @@
"use client";

import { useState } from "react";

import { GenerateLauncherDialog } from "@/widgets/generate-launcher-dialog";
import { ChooseAuthenticationMethodDialog } from "@/widgets/choose-authentication-method-dialog";
import { ConnectSentryDialog } from "@/widgets/connect-sentry-dialog";
import { ConnectTexturesDialog } from "@/widgets/connect-textures-dialog";
import { ConnectSentryDialog } from "@/widgets/connect-sentry-dialog";

import { IntegrationCard } from "@/entities/IntegrationCard";

import { Breadcrumbs } from "@/shared/ui/Breadcrumbs";
import { useSentry } from "@/shared/hooks";
import { DASHBOARD_PAGES } from "@/shared/routes";

export const IntegrationsPage = () => {
const [isGenerateLauncherDialogOpen, setIsGenerateLauncherDialogOpen] = useState(false);
const onGenerateLauncherDialogToggle = () => setIsGenerateLauncherDialogOpen((prev) => !prev);

const [isAuthenticationDialogOpen, setIsAuthenticationDialogOpen] = useState(false);
const onAuthenticationDialogToggle = () => setIsAuthenticationDialogOpen((prev) => !prev);

const [isSentryConnectDialogOpen, setIsSentryConnectDialogOpen] = useState(false);
const onSentryConnectDialogToggle = () => setIsSentryConnectDialogOpen((prev) => !prev);

const [isConnectTexturesDialogOpen, setIsConnectTexturesDialogOpen] = useState(false);
const onConnectTexturesDialogToggle = () => setIsConnectTexturesDialogOpen((prev) => !prev);

const { data: sentry, isLoading: isLoadingSentry } = useSentry();

return (
<>
<Breadcrumbs
Expand All @@ -42,65 +23,33 @@ export const IntegrationsPage = () => {
<IntegrationCard
title="Аутентификация"
description="Синхронизация и управление данными о пользователях на платформе"
action={onAuthenticationDialogToggle}
status={"CONNECTED"}
buttonText={"Изменить"}
dialog={<ChooseAuthenticationMethodDialog />}
/>
<IntegrationCard
title="Сборка лаунчера"
description="Создайте лаунчер для платформ Windows, MacOS и Linux в пару кликов"
action={onGenerateLauncherDialogToggle}
status={"CONNECTED"}
buttonText={"Собрать"}
dialog={<GenerateLauncherDialog />}
/>
<IntegrationCard
title="Сервис скинов"
description="Добавь интеграцию со сервисом скинов, для отображения скинов и плащей в игре"
action={onConnectTexturesDialogToggle}
status={"CONNECTED"}
buttonText={"Настроить"}
dialog={<ConnectTexturesDialog />}
/>
<IntegrationCard
title="Sentry"
description={"Подключение платформы для отслеживания ошибок и мониторинга приложений"}
action={onSentryConnectDialogToggle}
isDisabled={isLoadingSentry}
status={sentry?.url ? "CONNECTED" : "UNCONNECTED"}
buttonText={sentry?.url ? "Изменить" : "Подключить"}
dialog={<ConnectSentryDialog />}
/>
<IntegrationCard
isDisabled
title="Discord"
description="Синхронизация лаунчера и вашего Discord сервера"
/>
<IntegrationCard
isDisabled
buttonText="Предложить"
title="Нужен сервис?"
description="Отправь заявку, а мы придумаем что-нибудь"
/>
</div>
</div>

<ChooseAuthenticationMethodDialog
open={isAuthenticationDialogOpen}
onOpenChange={onAuthenticationDialogToggle}
/>

<GenerateLauncherDialog
open={isGenerateLauncherDialogOpen}
onOpenChange={onGenerateLauncherDialogToggle}
/>

<ConnectSentryDialog
open={isSentryConnectDialogOpen}
onOpenChange={onSentryConnectDialogToggle}
/>

<ConnectTexturesDialog
open={isConnectTexturesDialogOpen}
onOpenChange={onConnectTexturesDialogToggle}
/>
</>
);
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 67c59ad

Please sign in to comment.