From 133915f4820b0f4e4a629e525c2f6eca639f4e04 Mon Sep 17 00:00:00 2001 From: Oksamies Date: Mon, 27 Nov 2023 20:06:12 +0200 Subject: [PATCH] Get Upload page ready for Mythic to finish --- .../src/forms/UploadPackageForm.module.css | 27 +++++++ .../src/forms/UploadPackageForm.tsx | 72 +++++++++---------- .../src/fetch/packageUpload.ts | 14 ++-- packages/ts-api-react-forms/src/schema.ts | 2 +- 4 files changed, 73 insertions(+), 42 deletions(-) diff --git a/packages/cyberstorm-forms/src/forms/UploadPackageForm.module.css b/packages/cyberstorm-forms/src/forms/UploadPackageForm.module.css index 2a8fdc30b..26cc3153a 100644 --- a/packages/cyberstorm-forms/src/forms/UploadPackageForm.module.css +++ b/packages/cyberstorm-forms/src/forms/UploadPackageForm.module.css @@ -13,3 +13,30 @@ flex-direction: row; gap: var(--gap--16); } + +.submit > :last-child { + flex-grow: 1; +} + +.teamContentWrapper { + display: flex; + flex-direction: column; + gap: var(--space--12); +} + +.createTeamModalLink { + color: #39e9aa; + font-weight: var(--font-weight-medium); + background: transparent; +} + +.createTeamSentence { + display: flex; + flex-direction: row; + gap: var(--space--8); + color: var(--text-tertiary, #9c9cc4); + font-weight: var(--font-weight-semibold); + + font-size: 0.875rem; + line-height: 1.7; +} diff --git a/packages/cyberstorm-forms/src/forms/UploadPackageForm.tsx b/packages/cyberstorm-forms/src/forms/UploadPackageForm.tsx index 6d9389c63..82fdd17a7 100644 --- a/packages/cyberstorm-forms/src/forms/UploadPackageForm.tsx +++ b/packages/cyberstorm-forms/src/forms/UploadPackageForm.tsx @@ -47,28 +47,26 @@ export function UploadPackageForm(props: UploadPackageFormProps) { successMessage: "Package submitted", }); - // Parse categories to the right format for form - function communityCategoriesParse( + // Parse communities to the right format for form + function communitiesParse( selected: { label: string; value: string; - }[], - onChange: (selected: { [key: string]: string[] }) => void + }[] ) { - const communityCategories: { [key: string]: string[] } = {}; - selected.map((x) => (communityCategories[x.value] = [x.value])); - onChange(communityCategories); + return selected.map((x) => x.value); } - // Parse communities to the right format for form - function communitiesParse( + // Parse categories to the right format for form + function communityCategoriesParse( selected: { label: string; value: string; - }[], - onChange: (selected: string[]) => void + }[] ) { - onChange(selected.map((x) => x.value)); + const communityCategories: { [key: string]: string[] } = {}; + selected.map((x) => (communityCategories[x.value] = [x.value])); + return communityCategories; } return ( @@ -87,41 +85,41 @@ export function UploadPackageForm(props: UploadPackageFormProps) {
- Create team - - - - - } - > - - - } + description="Select the team you want your package to be associated with." content={ - t.name)} - placeholder="Choose a team..." - /> +
+ t.name)} + placeholder="Choose a team..." + /> +
+ No teams available? + + Create Team + + } + > + + +
+
} /> } /> @@ -134,7 +132,7 @@ export function UploadPackageForm(props: UploadPackageFormProps) { schema={uploadPackageFormSchema} options={options} placeholder="Choose categories..." - onChangeParse={communityCategoriesParse} + fieldFormFormatParser={communityCategoriesParse} /> } /> diff --git a/packages/thunderstore-api/src/fetch/packageUpload.ts b/packages/thunderstore-api/src/fetch/packageUpload.ts index 5dac66fa5..9a14332a0 100644 --- a/packages/thunderstore-api/src/fetch/packageUpload.ts +++ b/packages/thunderstore-api/src/fetch/packageUpload.ts @@ -7,7 +7,7 @@ export type PackageUploadApiArgs = { team: string; community_categories: { [key: string]: string[] }; communities: string[]; - has_nsfw_content: boolean; + has_nsfw_content?: boolean; }; export function packageUpload( @@ -17,12 +17,18 @@ export function packageUpload( const path = "api/experimental/submission/submit/"; // TODO: Add these datas in form - const todoData = { ...data, upload_uuid: "123", author_name: "root" }; + const todoData = { + ...data, + upload_uuid: "123", + author_name: "root", + }; return apiFetch2({ config, path, - method: "POST", - body: JSON.stringify(todoData), + request: { + method: "POST", + body: JSON.stringify(todoData), + }, }); } diff --git a/packages/ts-api-react-forms/src/schema.ts b/packages/ts-api-react-forms/src/schema.ts index 245dc12c4..8d7de9c2a 100644 --- a/packages/ts-api-react-forms/src/schema.ts +++ b/packages/ts-api-react-forms/src/schema.ts @@ -13,5 +13,5 @@ export const uploadPackageFormSchema = z.object({ team: z.string(), community_categories: z.record(z.array(z.string())), communities: z.array(z.string()).nonempty(), - has_nsfw_content: z.boolean(), + has_nsfw_content: z.boolean().default(false), });