updated the course index part

This commit is contained in:
2025-01-22 18:22:04 +08:00
parent b84d9bda94
commit 7644ba35c1
68 changed files with 33316 additions and 27 deletions

View File

@@ -1,2 +1,2 @@
VITE_API_URL=https://localhost
VITE_API_URL=http://localhost
VITE_IMAGE_URL=https://images.oneandallmusic.net

View File

@@ -43,7 +43,7 @@ export type OpenAPIConfig = {
}
export const OpenAPI: OpenAPIConfig = {
BASE: "",
BASE: import.meta.env.VITE_API_URL || "",
CREDENTIALS: "include",
ENCODE_PATH: undefined,
HEADERS: undefined,
@@ -54,4 +54,4 @@ export const OpenAPI: OpenAPIConfig = {
VERSION: "0.1.0",
WITH_CREDENTIALS: false,
interceptors: { request: new Interceptors(), response: new Interceptors() },
}
}

View File

@@ -81,7 +81,8 @@ const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => {
})
let url = config.BASE + path
url = url.replace(/^http:\/\//i, 'https://')
//url = url.replace(/^http:\/\//i, 'https://')
return options.query ? url + getQueryString(options.query) : url
}

View File

@@ -206,6 +206,7 @@ export type CoursePublic = {
sort_description: string,
long_description: string,
information: string,
index: number,
contant: string,
remark: string,
id: string,
@@ -216,6 +217,7 @@ export type CourseCreate = {
title: string,
sort_description: string,
long_description: string,
index: number,
information: string,
contant: string,
remark: string,
@@ -225,6 +227,7 @@ export type CourseDetailsPublic = {
title: string,
sort_description: string,
long_description: string,
index: number,
information: string,
contant: string,
remark: string,
@@ -239,6 +242,7 @@ export type CourseUpdate = {
title: string,
sort_description: string,
long_description: string,
index: number,
information: string,
contant: string,
remark: string,

View File

@@ -7,7 +7,12 @@ import {
Textarea,
Container,
Heading,
Box
Box,
NumberInput,
NumberInputField,
NumberInputStepper,
NumberIncrementStepper,
NumberDecrementStepper,
} from "@chakra-ui/react"
import { useQueryClient, useMutation } from "@tanstack/react-query"
import { useEffect, useState } from "react"
@@ -60,6 +65,7 @@ const CourseDetails = () => {
criteriaMode: "all",
defaultValues: {
title: courseDetails?.title,
index: courseDetails?.index,
sort_description: courseDetails?.sort_description,
long_description: courseDetails?.long_description,
remark: courseDetails?.remark,
@@ -72,6 +78,7 @@ const CourseDetails = () => {
reset({}, { keepDirty: true });
if (courseDetails) {
setValue('title', courseDetails.title, { shouldDirty: true });
setValue('index', courseDetails.index, { shouldDirty: true });
setValue('sort_description', courseDetails.sort_description, { shouldDirty: true });
setValue('long_description', courseDetails.long_description, { shouldDirty: true });
setValue('remark', courseDetails.remark, { shouldDirty: true });
@@ -161,6 +168,23 @@ const CourseDetails = () => {
)}
</FormControl>
<FormControl mt={4}></FormControl>
<FormControl isRequired isInvalid={!!errors.index}>
<FormLabel htmlFor="index">Index</FormLabel >
<NumberInput min={0} max={30} >
<NumberInputField {...register("index", {
required: "index is required.",
})} />
<NumberInputStepper>
<NumberIncrementStepper />
<NumberDecrementStepper />
</NumberInputStepper>
</NumberInput>
{errors.index && (
<FormErrorMessage>{errors.index.message}</FormErrorMessage>
)}
</FormControl>
<FormControl mt={4}></FormControl>
<FormControl >
<FormLabel htmlFor="sort_description">Short Description</FormLabel>
<Textarea

View File

@@ -19,11 +19,11 @@ import { Route as LayoutImport } from './routes/_layout'
import { Route as LayoutIndexImport } from './routes/_layout/index'
import { Route as LayoutWebSettingImport } from './routes/_layout/webSetting'
import { Route as LayoutSettingsImport } from './routes/_layout/settings'
import { Route as LayoutOrganImport } from './routes/_layout/organ'
import { Route as LayoutItemsImport } from './routes/_layout/items'
import { Route as LayoutClientMessagesImport } from './routes/_layout/clientMessages'
import { Route as LayoutAdminImport } from './routes/_layout/admin'
import { Route as LayoutAboutUsImport } from './routes/_layout/aboutUs'
import { Route as LayoutOrganImport } from './routes/_layout/organ'
import { Route as LayoutCoursesCoursesImport } from './routes/_layout/Courses/Courses'
import { Route as LayoutCoursesAddCourseImport } from './routes/_layout/Courses/AddCourse'
import { Route as LayoutCoursesIdEditCourseImport } from './routes/_layout/Courses/$id.EditCourse'
@@ -70,6 +70,11 @@ const LayoutSettingsRoute = LayoutSettingsImport.update({
getParentRoute: () => LayoutRoute,
} as any)
const LayoutOrganRoute = LayoutOrganImport.update({
path: '/organ',
getParentRoute: () => LayoutRoute,
} as any)
const LayoutItemsRoute = LayoutItemsImport.update({
path: '/items',
getParentRoute: () => LayoutRoute,
@@ -90,11 +95,6 @@ const LayoutAboutUsRoute = LayoutAboutUsImport.update({
getParentRoute: () => LayoutRoute,
} as any)
const LayoutOrganRoute = LayoutOrganImport.update({
path: '/organ',
getParentRoute: () => LayoutRoute,
} as any)
const LayoutCoursesCoursesRoute = LayoutCoursesCoursesImport.update({
path: '/Courses/Courses',
getParentRoute: () => LayoutRoute,
@@ -138,12 +138,6 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof LayoutAboutUsImport
parentRoute: typeof LayoutImport
}
'/_layout/organ': {
preLoaderRoute: typeof LayoutOrganImport
parentRoute: typeof LayoutImport
}
'/_layout/admin': {
preLoaderRoute: typeof LayoutAdminImport
parentRoute: typeof LayoutImport
@@ -156,6 +150,10 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof LayoutItemsImport
parentRoute: typeof LayoutImport
}
'/_layout/organ': {
preLoaderRoute: typeof LayoutOrganImport
parentRoute: typeof LayoutImport
}
'/_layout/settings': {
preLoaderRoute: typeof LayoutSettingsImport
parentRoute: typeof LayoutImport
@@ -188,10 +186,10 @@ declare module '@tanstack/react-router' {
export const routeTree = rootRoute.addChildren([
LayoutRoute.addChildren([
LayoutAboutUsRoute,
LayoutOrganRoute,
LayoutAdminRoute,
LayoutClientMessagesRoute,
LayoutItemsRoute,
LayoutOrganRoute,
LayoutSettingsRoute,
LayoutWebSettingRoute,
LayoutIndexRoute,

View File

@@ -5,11 +5,16 @@ import {
FormLabel,
Input,
Textarea,
Container
Container,
NumberInput,
NumberInputField,
NumberInputStepper,
NumberIncrementStepper,
NumberDecrementStepper,
} from "@chakra-ui/react"
import {useQueryClient, useMutation } from "@tanstack/react-query"
import { useQueryClient, useMutation } from "@tanstack/react-query"
import { createFileRoute } from "@tanstack/react-router"
import {useState } from "react"
import { useState } from "react"
import useCustomToast from "../../../hooks/useCustomToast"
import { CoursesService, type ApiError, CourseCreate, } from "../../../client"
import { handleError } from "../../../utils"
@@ -57,6 +62,7 @@ function AddCourseForms() {
criteriaMode: "all",
defaultValues: {
title: "",
index: 10,
sort_description: "",
long_description: "",
information: "",
@@ -106,6 +112,23 @@ function AddCourseForms() {
)}
</FormControl>
<FormControl mt={4}></FormControl>
<FormControl isRequired isInvalid={!!errors.index}>
<FormLabel htmlFor="index">Index</FormLabel >
<NumberInput min={0} max={30} >
<NumberInputField {...register("index", {
required: "index is required.",
})} />
<NumberInputStepper>
<NumberIncrementStepper />
<NumberDecrementStepper />
</NumberInputStepper>
</NumberInput>
{errors.index && (
<FormErrorMessage>{errors.index.message}</FormErrorMessage>
)}
</FormControl>
<FormControl mt={4}></FormControl>
<FormControl >
<FormLabel htmlFor="sort_description">Short Description</FormLabel>
<Textarea
@@ -128,7 +151,7 @@ function AddCourseForms() {
setlongDescription(draftToHtml(convertToRaw(newState.getCurrentContent())));
setValue("long_description", longDescription);
}}
toolbar={toolbar}
/>
</FormControl>