dev@locazia: mik ver
This commit is contained in:
parent
5c3500d17c
commit
8c217ab321
|
|
@ -1,3 +1,4 @@
|
||||||
.idea
|
.idea
|
||||||
node_modules
|
node_modules
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
dist
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
|
|
||||||
# React + TypeScript + Vite
|
# React + TypeScript + Vite
|
||||||
|
|
||||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||||
|
|
||||||
Currently, two official plugins are available:
|
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](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
|
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import { WelcomeStep } from "./steps/welcome-step";
|
|
||||||
import { DataStep } from "./steps/data-step";
|
import { DataStep } from "./steps/data-step";
|
||||||
import { RoyaltyStep } from "./steps/royalty-step";
|
import { RoyaltyStep } from "./steps/royalty-step";
|
||||||
import { PresubmitStep } from "./steps/presubmit-step";
|
import { PresubmitStep } from "./steps/presubmit-step";
|
||||||
|
|
@ -9,8 +8,8 @@ import { PriceStep } from "~/pages/root/steps/price-step";
|
||||||
export const RootPage = () => {
|
export const RootPage = () => {
|
||||||
const { ActiveSection } = useSteps(({ nextStep, prevStep }) => {
|
const { ActiveSection } = useSteps(({ nextStep, prevStep }) => {
|
||||||
return [
|
return [
|
||||||
<WelcomeStep nextStep={nextStep} />,
|
// <WelcomeStep nextStep={nextStep} />,
|
||||||
<DataStep prevStep={prevStep} nextStep={nextStep} />,
|
<DataStep nextStep={nextStep} />,
|
||||||
// <AuthorsStep prevStep={prevStep} nextStep={nextStep} />,
|
// <AuthorsStep prevStep={prevStep} nextStep={nextStep} />,
|
||||||
<RoyaltyStep prevStep={prevStep} nextStep={nextStep} />,
|
<RoyaltyStep prevStep={prevStep} nextStep={nextStep} />,
|
||||||
<PriceStep prevStep={prevStep} nextStep={nextStep} />,
|
<PriceStep prevStep={prevStep} nextStep={nextStep} />,
|
||||||
|
|
|
||||||
|
|
@ -12,19 +12,19 @@ import { CoverButton } from "~/pages/root/steps/data-step/components/cover-butto
|
||||||
import { HiddenFileInput } from "~/shared/ui/hidden-file-input";
|
import { HiddenFileInput } from "~/shared/ui/hidden-file-input";
|
||||||
import { useRootStore } from "~/shared/stores/root";
|
import { useRootStore } from "~/shared/stores/root";
|
||||||
import { Checkbox } from "~/shared/ui/checkbox";
|
import { Checkbox } from "~/shared/ui/checkbox";
|
||||||
import { BackButton } from "~/shared/ui/back-button";
|
import { useAuth } from "~/shared/services/auth";
|
||||||
|
|
||||||
type DataStepProps = {
|
type DataStepProps = {
|
||||||
prevStep(): void;
|
|
||||||
nextStep(): void;
|
nextStep(): void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DataStep = ({ nextStep, prevStep }: DataStepProps) => {
|
export const DataStep = ({ nextStep }: DataStepProps) => {
|
||||||
const rootStore = useRootStore();
|
const rootStore = useRootStore();
|
||||||
|
const auth = useAuth();
|
||||||
|
|
||||||
const formSchema = useMemo(() => {
|
const formSchema = useMemo(() => {
|
||||||
return z.object({
|
return z.object({
|
||||||
name: z.string().min(1),
|
name: z.string().min(1, "Обязательное поле"),
|
||||||
author: z.string().optional(),
|
author: z.string().optional(),
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
@ -50,6 +50,9 @@ export const DataStep = ({ nextStep, prevStep }: DataStepProps) => {
|
||||||
rootStore.setAuthor(values.author);
|
rootStore.setAuthor(values.author);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const res = await auth.mutateAsync();
|
||||||
|
sessionStorage.setItem("auth_v1_token", res.data.auth_v1_token);
|
||||||
|
|
||||||
nextStep();
|
nextStep();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error:", error);
|
console.error("Error:", error);
|
||||||
|
|
@ -59,8 +62,6 @@ export const DataStep = ({ nextStep, prevStep }: DataStepProps) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className={"mt-4 px-4 pb-8"}>
|
<section className={"mt-4 px-4 pb-8"}>
|
||||||
<BackButton onClick={prevStep} />
|
|
||||||
|
|
||||||
<div className={"mb-[30px] flex flex-col text-sm"}>
|
<div className={"mb-[30px] flex flex-col text-sm"}>
|
||||||
<span className={"ml-4"}>/Заполните информацию о контенте</span>
|
<span className={"ml-4"}>/Заполните информацию о контенте</span>
|
||||||
<div>
|
<div>
|
||||||
|
|
@ -72,6 +73,7 @@ export const DataStep = ({ nextStep, prevStep }: DataStepProps) => {
|
||||||
<FormLabel label={"Название"}>
|
<FormLabel label={"Название"}>
|
||||||
<Input
|
<Input
|
||||||
placeholder={"[ Введите название ]"}
|
placeholder={"[ Введите название ]"}
|
||||||
|
error={form.formState.errors?.name}
|
||||||
{...form.register("name")}
|
{...form.register("name")}
|
||||||
/>
|
/>
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
|
|
@ -79,6 +81,7 @@ export const DataStep = ({ nextStep, prevStep }: DataStepProps) => {
|
||||||
<FormLabel label={"Имя автора/исполнителя"}>
|
<FormLabel label={"Имя автора/исполнителя"}>
|
||||||
<Input
|
<Input
|
||||||
placeholder={"[ введите имя автора/исполнителя ]"}
|
placeholder={"[ введите имя автора/исполнителя ]"}
|
||||||
|
error={form.formState.errors?.author}
|
||||||
{...form.register("author")}
|
{...form.register("author")}
|
||||||
/>
|
/>
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,12 @@ export const PresubmitStep = ({ prevStep }: PresubmitStepProps) => {
|
||||||
WebApp.close();
|
WebApp.close();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("An error occurred during the submission process:", error);
|
console.error("An error occurred during the submission process:", error);
|
||||||
alert(`Возникла ошибка, ${JSON.stringify(error)}`);
|
|
||||||
|
if (error?.status === 400) {
|
||||||
|
alert(
|
||||||
|
"Введенные данные неверные, проверьте правильность введенных данных.",
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import axios from "axios";
|
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({
|
export const request = axios.create({
|
||||||
baseURL: APP_API_BASE_URL,
|
baseURL: APP_API_BASE_URL,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue