fix: fix credential 3rd error
This commit is contained in:
parent
c669d66969
commit
0b5f25a263
36
Cargo.lock
generated
36
Cargo.lock
generated
@ -886,9 +886,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytemuck"
|
name = "bytemuck"
|
||||||
version = "1.23.0"
|
version = "1.23.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9134a6ef01ce4b366b50689c94f82c14bc72bc5d0386829828a2e2752ef7958c"
|
checksum = "5c76a5792e44e4abe34d3abf15636779261d45a7450612059293d1d2cfc63422"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byteorder"
|
name = "byteorder"
|
||||||
@ -2347,11 +2347,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "getopts"
|
name = "getopts"
|
||||||
version = "0.2.21"
|
version = "0.2.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5"
|
checksum = "cba6ae63eb948698e300f645f87c70f76630d505f23b8907cf1e193ee85048c1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-width",
|
"unicode-width 0.2.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2523,9 +2523,9 @@ checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.15.3"
|
version = "0.15.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3"
|
checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"allocator-api2",
|
"allocator-api2",
|
||||||
"equivalent",
|
"equivalent",
|
||||||
@ -2538,7 +2538,7 @@ version = "0.10.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1"
|
checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hashbrown 0.15.3",
|
"hashbrown 0.15.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -3027,7 +3027,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e"
|
checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"equivalent",
|
"equivalent",
|
||||||
"hashbrown 0.15.3",
|
"hashbrown 0.15.4",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -3091,7 +3091,7 @@ dependencies = [
|
|||||||
"newline-converter",
|
"newline-converter",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"unicode-segmentation",
|
"unicode-segmentation",
|
||||||
"unicode-width",
|
"unicode-width 0.1.14",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -3751,7 +3751,7 @@ version = "0.12.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38"
|
checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hashbrown 0.15.3",
|
"hashbrown 0.15.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -3871,7 +3871,7 @@ dependencies = [
|
|||||||
"miette-derive",
|
"miette-derive",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"thiserror 1.0.69",
|
"thiserror 1.0.69",
|
||||||
"unicode-width",
|
"unicode-width 0.1.14",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -6513,7 +6513,7 @@ dependencies = [
|
|||||||
"futures-intrusive",
|
"futures-intrusive",
|
||||||
"futures-io",
|
"futures-io",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"hashbrown 0.15.3",
|
"hashbrown 0.15.4",
|
||||||
"hashlink",
|
"hashlink",
|
||||||
"indexmap 2.9.0",
|
"indexmap 2.9.0",
|
||||||
"log",
|
"log",
|
||||||
@ -7623,6 +7623,12 @@ version = "0.1.14"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
|
checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-width"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "universal-hash"
|
name = "universal-hash"
|
||||||
version = "0.5.1"
|
version = "0.5.1"
|
||||||
@ -8492,9 +8498,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zune-jpeg"
|
name = "zune-jpeg"
|
||||||
version = "0.4.16"
|
version = "0.4.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3e4a518c0ea2576f4da876349d7f67a7be489297cd77c2cf9e04c2e05fcd3974"
|
checksum = "0f6fe2e33d02a98ee64423802e16df3de99c43e5cf5ff983767e1128b394c8ac"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zune-core",
|
"zune-core",
|
||||||
]
|
]
|
||||||
|
@ -28,7 +28,11 @@ impl MigrationTrait for Migration {
|
|||||||
table_auto_z(Credential3rd::Table)
|
table_auto_z(Credential3rd::Table)
|
||||||
.col(pk_auto(Credential3rd::Id))
|
.col(pk_auto(Credential3rd::Id))
|
||||||
.col(integer(Credential3rd::SubscriberId))
|
.col(integer(Credential3rd::SubscriberId))
|
||||||
.col(string(Credential3rd::CredentialType))
|
.col(enumeration(
|
||||||
|
Credential3rd::CredentialType,
|
||||||
|
Credential3rdTypeEnum,
|
||||||
|
Credential3rdType::iden_values(),
|
||||||
|
))
|
||||||
.col(string_null(Credential3rd::Cookies))
|
.col(string_null(Credential3rd::Cookies))
|
||||||
.col(string_null(Credential3rd::Username))
|
.col(string_null(Credential3rd::Username))
|
||||||
.col(string_null(Credential3rd::Password))
|
.col(string_null(Credential3rd::Password))
|
||||||
|
@ -18,6 +18,7 @@ use crate::{
|
|||||||
db_type = "Enum",
|
db_type = "Enum",
|
||||||
enum_name = "credential_3rd_type"
|
enum_name = "credential_3rd_type"
|
||||||
)]
|
)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum Credential3rdType {
|
pub enum Credential3rdType {
|
||||||
#[sea_orm(string_value = "mikan")]
|
#[sea_orm(string_value = "mikan")]
|
||||||
Mikan,
|
Mikan,
|
||||||
|
@ -65,6 +65,7 @@
|
|||||||
"input-otp": "^1.4.2",
|
"input-otp": "^1.4.2",
|
||||||
"jotai": "^2.12.3",
|
"jotai": "^2.12.3",
|
||||||
"jotai-signal": "^0.9.0",
|
"jotai-signal": "^0.9.0",
|
||||||
|
"lodash-es": "^4.17.21",
|
||||||
"lucide-react": "^0.512.0",
|
"lucide-react": "^0.512.0",
|
||||||
"oidc-client-rx": "0.1.0-alpha.9",
|
"oidc-client-rx": "0.1.0-alpha.9",
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
@ -91,6 +92,7 @@
|
|||||||
"@tanstack/react-router": "^1.112.0",
|
"@tanstack/react-router": "^1.112.0",
|
||||||
"@tanstack/router-devtools": "^1.112.6",
|
"@tanstack/router-devtools": "^1.112.6",
|
||||||
"@tanstack/router-plugin": "^1.112.13",
|
"@tanstack/router-plugin": "^1.112.13",
|
||||||
|
"@types/lodash-es": "^4.17.12",
|
||||||
"@types/react": "^19.1.2",
|
"@types/react": "^19.1.2",
|
||||||
"@types/react-dom": "^19.1.2",
|
"@types/react-dom": "^19.1.2",
|
||||||
"chalk": "^5.4.1",
|
"chalk": "^5.4.1",
|
||||||
|
@ -3,6 +3,7 @@ import {
|
|||||||
type SubscriptionsInsertInput,
|
type SubscriptionsInsertInput,
|
||||||
} from '@/infra/graphql/gql/graphql';
|
} from '@/infra/graphql/gql/graphql';
|
||||||
import { Injectable, inject } from '@outposts/injection-js';
|
import { Injectable, inject } from '@outposts/injection-js';
|
||||||
|
import { omit } from 'lodash-es';
|
||||||
import { buildMikanSubscriptionSeasonSourceUrl } from '../schema/mikan';
|
import { buildMikanSubscriptionSeasonSourceUrl } from '../schema/mikan';
|
||||||
import type { SubscriptionInsertForm } from '../schema/subscriptions';
|
import type { SubscriptionInsertForm } from '../schema/subscriptions';
|
||||||
import { MikanService } from './mikan.service';
|
import { MikanService } from './mikan.service';
|
||||||
@ -14,18 +15,15 @@ export class SubscriptionService {
|
|||||||
transformInsertFormToInput(
|
transformInsertFormToInput(
|
||||||
form: SubscriptionInsertForm
|
form: SubscriptionInsertForm
|
||||||
): SubscriptionsInsertInput {
|
): SubscriptionsInsertInput {
|
||||||
let sourceUrl: string;
|
|
||||||
if (form.category === SubscriptionCategoryEnum.MikanSeason) {
|
if (form.category === SubscriptionCategoryEnum.MikanSeason) {
|
||||||
sourceUrl = buildMikanSubscriptionSeasonSourceUrl(
|
return {
|
||||||
|
...omit(form, ['seasonStr', 'year']),
|
||||||
|
sourceUrl: buildMikanSubscriptionSeasonSourceUrl(
|
||||||
this.mikan.mikanBaseUrl,
|
this.mikan.mikanBaseUrl,
|
||||||
form
|
form
|
||||||
).toString();
|
).toString(),
|
||||||
} else {
|
|
||||||
sourceUrl = form.sourceUrl;
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
...form,
|
|
||||||
sourceUrl,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
return form;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,3 +13,23 @@ export function arkValidatorToTypeNarrower<
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function validateOr<T, D>(
|
||||||
|
validated: T | ArkErrors,
|
||||||
|
defaultValue: D
|
||||||
|
): T | D {
|
||||||
|
if (validated instanceof ArkErrors) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
return validated;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function validateOrElse<T, D>(
|
||||||
|
validated: T | ArkErrors,
|
||||||
|
elseFn: (errors: ArkErrors) => D
|
||||||
|
): T | D {
|
||||||
|
if (validated instanceof ArkErrors) {
|
||||||
|
return elseFn(validated);
|
||||||
|
}
|
||||||
|
return validated;
|
||||||
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { type } from 'arktype';
|
||||||
import {
|
import {
|
||||||
BookOpen,
|
BookOpen,
|
||||||
Folders,
|
Folders,
|
||||||
@ -112,3 +113,15 @@ export const AppNavMainData = [
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const CreateCompleteAction = {
|
||||||
|
Back: 'back',
|
||||||
|
Detail: 'detail',
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export type CreateCompleteAction =
|
||||||
|
(typeof CreateCompleteAction)[keyof typeof CreateCompleteAction];
|
||||||
|
|
||||||
|
export const CreateCompleteActionSchema = type.enumerated(
|
||||||
|
...Object.values(CreateCompleteAction)
|
||||||
|
);
|
||||||
|
@ -29,33 +29,65 @@ import {
|
|||||||
type InsertCredential3rdMutationVariables,
|
type InsertCredential3rdMutationVariables,
|
||||||
} from '@/infra/graphql/gql/graphql';
|
} from '@/infra/graphql/gql/graphql';
|
||||||
import { PlatformService } from '@/infra/platform/platform.service';
|
import { PlatformService } from '@/infra/platform/platform.service';
|
||||||
|
import {
|
||||||
|
CreateCompleteAction,
|
||||||
|
CreateCompleteActionSchema,
|
||||||
|
} from '@/infra/routes/nav';
|
||||||
import type { RouteStateDataOption } from '@/infra/routes/traits';
|
import type { RouteStateDataOption } from '@/infra/routes/traits';
|
||||||
import { useMutation } from '@apollo/client';
|
import { useMutation } from '@apollo/client';
|
||||||
import { createFileRoute, useNavigate } from '@tanstack/react-router';
|
import {
|
||||||
|
createFileRoute,
|
||||||
|
useCanGoBack,
|
||||||
|
useNavigate,
|
||||||
|
useRouter,
|
||||||
|
} from '@tanstack/react-router';
|
||||||
|
import { type } from 'arktype';
|
||||||
import { Loader2, Save } from 'lucide-react';
|
import { Loader2, Save } from 'lucide-react';
|
||||||
import { toast } from 'sonner';
|
import { toast } from 'sonner';
|
||||||
|
|
||||||
|
const RouteSearchSchema = type({
|
||||||
|
completeAction: CreateCompleteActionSchema.optional(),
|
||||||
|
});
|
||||||
|
|
||||||
export const Route = createFileRoute('/_app/credential3rd/create')({
|
export const Route = createFileRoute('/_app/credential3rd/create')({
|
||||||
component: CredentialCreateRouteComponent,
|
component: CredentialCreateRouteComponent,
|
||||||
staticData: {
|
staticData: {
|
||||||
breadcrumb: { label: 'Create' },
|
breadcrumb: { label: 'Create' },
|
||||||
} satisfies RouteStateDataOption,
|
} satisfies RouteStateDataOption,
|
||||||
|
validateSearch: RouteSearchSchema,
|
||||||
});
|
});
|
||||||
|
|
||||||
function CredentialCreateRouteComponent() {
|
function CredentialCreateRouteComponent() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const router = useRouter();
|
||||||
|
const canGoBack = useCanGoBack();
|
||||||
|
const search = Route.useSearch();
|
||||||
const platformService = useInject(PlatformService);
|
const platformService = useInject(PlatformService);
|
||||||
|
|
||||||
|
const handleBack = () => {
|
||||||
|
if (canGoBack) {
|
||||||
|
router.history.back();
|
||||||
|
} else {
|
||||||
|
navigate({
|
||||||
|
to: '/credential3rd/manage',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const [insertCredential3rd, { loading }] = useMutation<
|
const [insertCredential3rd, { loading }] = useMutation<
|
||||||
InsertCredential3rdMutation['credential3rdCreateOne'],
|
InsertCredential3rdMutation,
|
||||||
InsertCredential3rdMutationVariables
|
InsertCredential3rdMutationVariables
|
||||||
>(INSERT_CREDENTIAL_3RD, {
|
>(INSERT_CREDENTIAL_3RD, {
|
||||||
onCompleted(data) {
|
onCompleted(data) {
|
||||||
toast.success('Credential created');
|
toast.success('Credential created');
|
||||||
|
if (search.completeAction === CreateCompleteAction.Back) {
|
||||||
|
handleBack();
|
||||||
|
} else {
|
||||||
navigate({
|
navigate({
|
||||||
to: '/credential3rd/detail/$id',
|
to: '/credential3rd/detail/$id',
|
||||||
params: { id: `${data.id}` },
|
params: { id: `${data.credential3rdCreateOne.id}` },
|
||||||
});
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onError(error) {
|
onError(error) {
|
||||||
toast.error('Failed to create credential', {
|
toast.error('Failed to create credential', {
|
||||||
@ -168,8 +200,6 @@ function CredentialCreateRouteComponent() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</form.Field>
|
</form.Field>
|
||||||
|
|
||||||
{/* 密码 */}
|
|
||||||
<form.Field name="password">
|
<form.Field name="password">
|
||||||
{(field) => (
|
{(field) => (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
@ -194,8 +224,6 @@ function CredentialCreateRouteComponent() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</form.Field>
|
</form.Field>
|
||||||
|
|
||||||
{/* User Agent */}
|
|
||||||
<form.Field name="userAgent">
|
<form.Field name="userAgent">
|
||||||
{(field) => (
|
{(field) => (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
|
@ -16,7 +16,12 @@ import { GET_CREDENTIAL_3RD_DETAIL } from '@/domains/recorder/schema/credential3
|
|||||||
import type { GetCredential3rdDetailQuery } from '@/infra/graphql/gql/graphql';
|
import type { GetCredential3rdDetailQuery } from '@/infra/graphql/gql/graphql';
|
||||||
import type { RouteStateDataOption } from '@/infra/routes/traits';
|
import type { RouteStateDataOption } from '@/infra/routes/traits';
|
||||||
import { useQuery } from '@apollo/client';
|
import { useQuery } from '@apollo/client';
|
||||||
import { createFileRoute, useNavigate } from '@tanstack/react-router';
|
import {
|
||||||
|
createFileRoute,
|
||||||
|
useCanGoBack,
|
||||||
|
useNavigate,
|
||||||
|
useRouter,
|
||||||
|
} from '@tanstack/react-router';
|
||||||
import { format } from 'date-fns/format';
|
import { format } from 'date-fns/format';
|
||||||
import { ArrowLeft, Edit, Eye, EyeOff } from 'lucide-react';
|
import { ArrowLeft, Edit, Eye, EyeOff } from 'lucide-react';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
@ -31,8 +36,21 @@ export const Route = createFileRoute('/_app/credential3rd/detail/$id')({
|
|||||||
function Credential3rdDetailRouteComponent() {
|
function Credential3rdDetailRouteComponent() {
|
||||||
const { id } = Route.useParams();
|
const { id } = Route.useParams();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const router = useRouter();
|
||||||
|
const canGoBack = useCanGoBack();
|
||||||
|
|
||||||
const [showPassword, setShowPassword] = useState(false);
|
const [showPassword, setShowPassword] = useState(false);
|
||||||
|
|
||||||
|
const handleBack = () => {
|
||||||
|
if (canGoBack) {
|
||||||
|
router.history.back();
|
||||||
|
} else {
|
||||||
|
navigate({
|
||||||
|
to: '/credential3rd/manage',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const { loading, error, data } = useQuery<GetCredential3rdDetailQuery>(
|
const { loading, error, data } = useQuery<GetCredential3rdDetailQuery>(
|
||||||
GET_CREDENTIAL_3RD_DETAIL,
|
GET_CREDENTIAL_3RD_DETAIL,
|
||||||
{
|
{
|
||||||
@ -43,12 +61,6 @@ function Credential3rdDetailRouteComponent() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleBack = () => {
|
|
||||||
navigate({
|
|
||||||
to: '/credential3rd/manage',
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleEnterEditMode = () => {
|
const handleEnterEditMode = () => {
|
||||||
navigate({
|
navigate({
|
||||||
to: '/credential3rd/edit/$id',
|
to: '/credential3rd/edit/$id',
|
||||||
|
@ -67,7 +67,7 @@ function FormView({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const [updateCredential, { loading: updating }] = useMutation<
|
const [updateCredential, { loading: updating }] = useMutation<
|
||||||
UpdateCredential3rdMutation['credential3rdUpdate'],
|
UpdateCredential3rdMutation,
|
||||||
UpdateCredential3rdMutationVariables
|
UpdateCredential3rdMutationVariables
|
||||||
>(UPDATE_CREDENTIAL_3RD, {
|
>(UPDATE_CREDENTIAL_3RD, {
|
||||||
onCompleted,
|
onCompleted,
|
||||||
|
@ -7,8 +7,10 @@ import {
|
|||||||
type GetCredential3rdQueryVariables,
|
type GetCredential3rdQueryVariables,
|
||||||
OrderByEnum,
|
OrderByEnum,
|
||||||
} from '@/infra/graphql/gql/graphql';
|
} from '@/infra/graphql/gql/graphql';
|
||||||
|
import { CreateCompleteAction } from '@/infra/routes/nav';
|
||||||
import { useQuery } from '@apollo/client';
|
import { useQuery } from '@apollo/client';
|
||||||
import { AlertCircle, Loader2, RefreshCw } from 'lucide-react';
|
import { useNavigate } from '@tanstack/react-router';
|
||||||
|
import { AlertCircle, Loader2, Plus, RefreshCw } from 'lucide-react';
|
||||||
import type { ComponentProps } from 'react';
|
import type { ComponentProps } from 'react';
|
||||||
|
|
||||||
export interface Credential3rdSelectContentProps
|
export interface Credential3rdSelectContentProps
|
||||||
@ -20,6 +22,8 @@ export function Credential3rdSelectContent({
|
|||||||
credentialType,
|
credentialType,
|
||||||
...props
|
...props
|
||||||
}: Credential3rdSelectContentProps) {
|
}: Credential3rdSelectContentProps) {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const { data, loading, error, refetch } = useQuery<
|
const { data, loading, error, refetch } = useQuery<
|
||||||
GetCredential3rdQuery,
|
GetCredential3rdQuery,
|
||||||
GetCredential3rdQueryVariables
|
GetCredential3rdQueryVariables
|
||||||
@ -76,10 +80,24 @@ export function Credential3rdSelectContent({
|
|||||||
{!loading &&
|
{!loading &&
|
||||||
!error &&
|
!error &&
|
||||||
(credentials.length === 0 ? (
|
(credentials.length === 0 ? (
|
||||||
<div className="py-6 text-center">
|
<div className="flex flex-col items-center gap-2 py-6 text-center">
|
||||||
<span className="text-muted-foreground text-sm">
|
<span className="text-muted-foreground text-sm">
|
||||||
No credentials found
|
No credentials found
|
||||||
</span>
|
</span>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
onClick={() =>
|
||||||
|
navigate({
|
||||||
|
to: '/credential3rd/create',
|
||||||
|
search: {
|
||||||
|
completeAction: CreateCompleteAction.Back,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Plus className="h-3 w-3" />
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
credentials.map((credential) => (
|
credentials.map((credential) => (
|
||||||
|
@ -52,14 +52,14 @@ function SubscriptionCreateRouteComponent() {
|
|||||||
const subscriptionService = useInject(SubscriptionService);
|
const subscriptionService = useInject(SubscriptionService);
|
||||||
|
|
||||||
const [insertSubscription, { loading }] = useMutation<
|
const [insertSubscription, { loading }] = useMutation<
|
||||||
InsertSubscriptionMutation['subscriptionsCreateOne'],
|
InsertSubscriptionMutation,
|
||||||
InsertSubscriptionMutationVariables
|
InsertSubscriptionMutationVariables
|
||||||
>(INSERT_SUBSCRIPTION, {
|
>(INSERT_SUBSCRIPTION, {
|
||||||
onCompleted(data) {
|
onCompleted(data) {
|
||||||
toast.success('Subscription created');
|
toast.success('Subscription created');
|
||||||
navigate({
|
navigate({
|
||||||
to: '/subscriptions/detail/$id',
|
to: '/subscriptions/detail/$id',
|
||||||
params: { id: `${data.id}` },
|
params: { id: `${data.subscriptionsCreateOne.id}` },
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onError(error) {
|
onError(error) {
|
||||||
@ -80,7 +80,8 @@ function SubscriptionCreateRouteComponent() {
|
|||||||
seasonStr: '',
|
seasonStr: '',
|
||||||
} as unknown as SubscriptionInsertForm,
|
} as unknown as SubscriptionInsertForm,
|
||||||
validators: {
|
validators: {
|
||||||
onBlur: SubscriptionInsertFormSchema,
|
onChangeAsync: SubscriptionInsertFormSchema,
|
||||||
|
onChangeAsyncDebounceMs: 300,
|
||||||
onSubmit: SubscriptionInsertFormSchema,
|
onSubmit: SubscriptionInsertFormSchema,
|
||||||
},
|
},
|
||||||
onSubmit: async (form) => {
|
onSubmit: async (form) => {
|
||||||
@ -233,7 +234,7 @@ function SubscriptionCreateRouteComponent() {
|
|||||||
Number.parseInt(e.target.value)
|
Number.parseInt(e.target.value)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
placeholder="Please enter full year (e.g. 2025)"
|
placeholder={`Please enter full year (e.g. ${new Date().getFullYear()})`}
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
/>
|
/>
|
||||||
{field.state.meta.errors && (
|
{field.state.meta.errors && (
|
||||||
@ -252,7 +253,12 @@ function SubscriptionCreateRouteComponent() {
|
|||||||
{(field) => (
|
{(field) => (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Label htmlFor={field.name}>Season *</Label>
|
<Label htmlFor={field.name}>Season *</Label>
|
||||||
<Select>
|
<Select
|
||||||
|
value={field.state.value}
|
||||||
|
onValueChange={(value) =>
|
||||||
|
field.handleChange(value as MikanSeasonEnum)
|
||||||
|
}
|
||||||
|
>
|
||||||
<SelectTrigger>
|
<SelectTrigger>
|
||||||
<SelectValue placeholder="Select season" />
|
<SelectValue placeholder="Select season" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
|
18
pnpm-lock.yaml
generated
18
pnpm-lock.yaml
generated
@ -224,6 +224,9 @@ importers:
|
|||||||
jotai-signal:
|
jotai-signal:
|
||||||
specifier: ^0.9.0
|
specifier: ^0.9.0
|
||||||
version: 0.9.0(jotai@2.12.5(@types/react@19.1.6)(react@19.1.0))(react@19.1.0)
|
version: 0.9.0(jotai@2.12.5(@types/react@19.1.6)(react@19.1.0))(react@19.1.0)
|
||||||
|
lodash-es:
|
||||||
|
specifier: ^4.17.21
|
||||||
|
version: 4.17.21
|
||||||
lucide-react:
|
lucide-react:
|
||||||
specifier: ^0.512.0
|
specifier: ^0.512.0
|
||||||
version: 0.512.0(react@19.1.0)
|
version: 0.512.0(react@19.1.0)
|
||||||
@ -291,6 +294,9 @@ importers:
|
|||||||
'@tanstack/router-plugin':
|
'@tanstack/router-plugin':
|
||||||
specifier: ^1.112.13
|
specifier: ^1.112.13
|
||||||
version: 1.120.15(@rsbuild/core@1.3.22)(@tanstack/react-router@1.120.15(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(vite@5.4.11(@types/node@22.15.29)(lightningcss@1.30.1)(sass@1.77.4)(terser@5.41.0))(webpack@5.97.1)
|
version: 1.120.15(@rsbuild/core@1.3.22)(@tanstack/react-router@1.120.15(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(vite@5.4.11(@types/node@22.15.29)(lightningcss@1.30.1)(sass@1.77.4)(terser@5.41.0))(webpack@5.97.1)
|
||||||
|
'@types/lodash-es':
|
||||||
|
specifier: ^4.17.12
|
||||||
|
version: 4.17.12
|
||||||
'@types/react':
|
'@types/react':
|
||||||
specifier: ^19.1.2
|
specifier: ^19.1.2
|
||||||
version: 19.1.6
|
version: 19.1.6
|
||||||
@ -3509,6 +3515,9 @@ packages:
|
|||||||
'@types/json-schema@7.0.15':
|
'@types/json-schema@7.0.15':
|
||||||
resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}
|
resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}
|
||||||
|
|
||||||
|
'@types/lodash-es@4.17.12':
|
||||||
|
resolution: {integrity: sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==}
|
||||||
|
|
||||||
'@types/lodash.merge@4.6.9':
|
'@types/lodash.merge@4.6.9':
|
||||||
resolution: {integrity: sha512-23sHDPmzd59kUgWyKGiOMO2Qb9YtqRO/x4IhkgNUiPQ1+5MUVqi6bCZeq9nBJ17msjIMbEIO5u+XW4Kz6aGUhQ==}
|
resolution: {integrity: sha512-23sHDPmzd59kUgWyKGiOMO2Qb9YtqRO/x4IhkgNUiPQ1+5MUVqi6bCZeq9nBJ17msjIMbEIO5u+XW4Kz6aGUhQ==}
|
||||||
|
|
||||||
@ -5428,6 +5437,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==}
|
resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
|
||||||
|
lodash-es@4.17.21:
|
||||||
|
resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==}
|
||||||
|
|
||||||
lodash.chunk@4.2.0:
|
lodash.chunk@4.2.0:
|
||||||
resolution: {integrity: sha512-ZzydJKfUHJwHa+hF5X66zLFCBrWn5GeF28OHEr4WVWtNDXlQ/IjWKPBiikqKo2ne0+v6JgCgJ0GzJp8k8bHC7w==}
|
resolution: {integrity: sha512-ZzydJKfUHJwHa+hF5X66zLFCBrWn5GeF28OHEr4WVWtNDXlQ/IjWKPBiikqKo2ne0+v6JgCgJ0GzJp8k8bHC7w==}
|
||||||
|
|
||||||
@ -10673,6 +10685,10 @@ snapshots:
|
|||||||
'@types/json-schema@7.0.15':
|
'@types/json-schema@7.0.15':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@types/lodash-es@4.17.12':
|
||||||
|
dependencies:
|
||||||
|
'@types/lodash': 4.17.13
|
||||||
|
|
||||||
'@types/lodash.merge@4.6.9':
|
'@types/lodash.merge@4.6.9':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/lodash': 4.17.13
|
'@types/lodash': 4.17.13
|
||||||
@ -12880,6 +12896,8 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
p-locate: 4.1.0
|
p-locate: 4.1.0
|
||||||
|
|
||||||
|
lodash-es@4.17.21: {}
|
||||||
|
|
||||||
lodash.chunk@4.2.0: {}
|
lodash.chunk@4.2.0: {}
|
||||||
|
|
||||||
lodash.get@4.4.2: {}
|
lodash.get@4.4.2: {}
|
||||||
|
Loading…
Reference in New Issue
Block a user