dev@locazia: mik ver

This commit is contained in:
user 2024-03-28 01:26:43 +03:00
parent 5c3500d17c
commit 8c217ab321
8 changed files with 639 additions and 499 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.idea
node_modules
.DS_Store
dist

View File

@ -1,9 +1,9 @@
# React + TypeScript + Vite
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

View File

@ -1,4 +1,3 @@
import { WelcomeStep } from "./steps/welcome-step";
import { DataStep } from "./steps/data-step";
import { RoyaltyStep } from "./steps/royalty-step";
import { PresubmitStep } from "./steps/presubmit-step";
@ -9,8 +8,8 @@ import { PriceStep } from "~/pages/root/steps/price-step";
export const RootPage = () => {
const { ActiveSection } = useSteps(({ nextStep, prevStep }) => {
return [
<WelcomeStep nextStep={nextStep} />,
<DataStep prevStep={prevStep} nextStep={nextStep} />,
// <WelcomeStep nextStep={nextStep} />,
<DataStep nextStep={nextStep} />,
// <AuthorsStep prevStep={prevStep} nextStep={nextStep} />,
<RoyaltyStep prevStep={prevStep} nextStep={nextStep} />,
<PriceStep prevStep={prevStep} nextStep={nextStep} />,

View File

@ -12,19 +12,19 @@ import { CoverButton } from "~/pages/root/steps/data-step/components/cover-butto
import { HiddenFileInput } from "~/shared/ui/hidden-file-input";
import { useRootStore } from "~/shared/stores/root";
import { Checkbox } from "~/shared/ui/checkbox";
import { BackButton } from "~/shared/ui/back-button";
import { useAuth } from "~/shared/services/auth";
type DataStepProps = {
prevStep(): void;
nextStep(): void;
};
export const DataStep = ({ nextStep, prevStep }: DataStepProps) => {
export const DataStep = ({ nextStep }: DataStepProps) => {
const rootStore = useRootStore();
const auth = useAuth();
const formSchema = useMemo(() => {
return z.object({
name: z.string().min(1),
name: z.string().min(1, "Обязательное поле"),
author: z.string().optional(),
});
}, []);
@ -50,6 +50,9 @@ export const DataStep = ({ nextStep, prevStep }: DataStepProps) => {
rootStore.setAuthor(values.author);
}
const res = await auth.mutateAsync();
sessionStorage.setItem("auth_v1_token", res.data.auth_v1_token);
nextStep();
} catch (error) {
console.error("Error:", error);
@ -59,8 +62,6 @@ export const DataStep = ({ nextStep, prevStep }: DataStepProps) => {
return (
<section className={"mt-4 px-4 pb-8"}>
<BackButton onClick={prevStep} />
<div className={"mb-[30px] flex flex-col text-sm"}>
<span className={"ml-4"}>/Заполните информацию о контенте</span>
<div>
@ -72,6 +73,7 @@ export const DataStep = ({ nextStep, prevStep }: DataStepProps) => {
<FormLabel label={"Название"}>
<Input
placeholder={"[ Введите название ]"}
error={form.formState.errors?.name}
{...form.register("name")}
/>
</FormLabel>
@ -79,6 +81,7 @@ export const DataStep = ({ nextStep, prevStep }: DataStepProps) => {
<FormLabel label={"Имя автора/исполнителя"}>
<Input
placeholder={"[ введите имя автора/исполнителя ]"}
error={form.formState.errors?.author}
{...form.register("author")}
/>
</FormLabel>

View File

@ -81,7 +81,12 @@ export const PresubmitStep = ({ prevStep }: PresubmitStepProps) => {
WebApp.close();
} catch (error) {
console.error("An error occurred during the submission process:", error);
alert(`Возникла ошибка, ${JSON.stringify(error)}`);
if (error?.status === 400) {
alert(
"Введенные данные неверные, проверьте правильность введенных данных.",
);
}
}
};

View File

@ -1,6 +1,6 @@
import axios from "axios";
export const APP_API_BASE_URL = import.meta.env.VITE_API_BASE_URL as string;
export const APP_API_BASE_URL = import.meta.env.VITE_API_BASE_URL;
export const request = axios.create({
baseURL: APP_API_BASE_URL,

View File

@ -1,3 +1,3 @@
{
"rewrites": [{ "source": "/(.*)", "destination": "/" }]
"rewrites": [{ "source": "/(.*)", "destination": "/" }]
}

1104
yarn.lock

File diff suppressed because it is too large Load Diff