From 25a930e813319596daba0bbf50f33758674603e1 Mon Sep 17 00:00:00 2001 From: skywalker Date: Sun, 25 Aug 2024 00:48:59 +0300 Subject: [PATCH] feat(create-instrument): refactor to css modules and add image field --- .../src/pages/create-instrument/api/loader.ts | 2 + .../ui/CreateInstrumentPage.tsx | 123 ++++++++++++++---- .../ui/styles/CreateInstrumentPage.css | 17 --- .../ui/styles/CreateInstrumentPage.module.css | 23 ++++ .../edit-instrument/ui/EditInstrumentPage.tsx | 2 +- 5 files changed, 126 insertions(+), 41 deletions(-) delete mode 100644 client/src/pages/create-instrument/ui/styles/CreateInstrumentPage.css create mode 100644 client/src/pages/create-instrument/ui/styles/CreateInstrumentPage.module.css diff --git a/client/src/pages/create-instrument/api/loader.ts b/client/src/pages/create-instrument/api/loader.ts index 860e6d5b..61318f4c 100644 --- a/client/src/pages/create-instrument/api/loader.ts +++ b/client/src/pages/create-instrument/api/loader.ts @@ -9,11 +9,13 @@ import type { import { GetInstrumentBasicMaterialsApi } from "generated/api/get-instrument-basic-materials-api"; import { GetCountriesApi } from "generated/api/get-countries-api"; import { GetManufacturersApi } from "generated/api/get-manufacturers-api"; +import { GetInstrumentPhotoApi } from "generated/api/get-instrument-photo-api"; const getInstrumentTypes = new GetInstrumentTypesApi(); const getInstrumentBasicMaterials = new GetInstrumentBasicMaterialsApi(); const getCountries = new GetCountriesApi(); const getManufacturers = new GetManufacturersApi(); +const getInstrumentPhoto = new GetInstrumentPhotoApi(); export interface CreateInstrumentLoader { instrumentTypes: InstrumentType[]; diff --git a/client/src/pages/create-instrument/ui/CreateInstrumentPage.tsx b/client/src/pages/create-instrument/ui/CreateInstrumentPage.tsx index 76b4fb2c..ea38fb6f 100644 --- a/client/src/pages/create-instrument/ui/CreateInstrumentPage.tsx +++ b/client/src/pages/create-instrument/ui/CreateInstrumentPage.tsx @@ -1,5 +1,5 @@ -import React from "react"; -import "./styles/CreateInstrumentPage.css"; +import React, { useEffect } from "react"; +import styles from "./styles/CreateInstrumentPage.module.css"; import { HeaderWidget } from "widgets/header"; import { FooterWidget } from "widgets/footer"; import { Form, useActionData, useLoaderData } from "react-router-dom"; @@ -13,16 +13,39 @@ export const CreateInstrumentPage = () => { return ( <> -

Instrument Creation

-
-
- - + +

Create Instrument

+ + +
+ + +
-
- - {loader.instrumentTypes.map((instrumentType) => (
-
- - {loader.manufacturers.map((manufacturer) => (
-
- +
+ +
-
- +
+ +
-
- - {loader.countries.map((country) => (
-
- - {loader.materials.map((material) => (
+
+ + + +
+ + {actionData?.errors && actionData?.errors.map((error) =>
{error}
)} diff --git a/client/src/pages/create-instrument/ui/styles/CreateInstrumentPage.css b/client/src/pages/create-instrument/ui/styles/CreateInstrumentPage.css deleted file mode 100644 index da72ed05..00000000 --- a/client/src/pages/create-instrument/ui/styles/CreateInstrumentPage.css +++ /dev/null @@ -1,17 +0,0 @@ -#create-instrument { - display: flex; - flex-direction: column; - justify-content: flex-start; - - .create-instrument-field { - display: flex; - - label { - flex-basis: 30%; - } - - input { - flex-basis: 70%; - } - } -} diff --git a/client/src/pages/create-instrument/ui/styles/CreateInstrumentPage.module.css b/client/src/pages/create-instrument/ui/styles/CreateInstrumentPage.module.css new file mode 100644 index 00000000..26a290a9 --- /dev/null +++ b/client/src/pages/create-instrument/ui/styles/CreateInstrumentPage.module.css @@ -0,0 +1,23 @@ +.create_instrument__img { + flex: 1; +} + +.create_instrument__form { + flex: 4; + display: flex; + flex-direction: column; + justify-content: flex-start; +} + +.create_instrument__form__field { + display: flex; + flex-direction: row; +} + +.create_instrument__form__field__key { + flex-basis: 30%; +} + +.create_instrument__form__field__value { + flex-basis: 70%; +} diff --git a/client/src/pages/edit-instrument/ui/EditInstrumentPage.tsx b/client/src/pages/edit-instrument/ui/EditInstrumentPage.tsx index 076818ee..f72713be 100644 --- a/client/src/pages/edit-instrument/ui/EditInstrumentPage.tsx +++ b/client/src/pages/edit-instrument/ui/EditInstrumentPage.tsx @@ -151,7 +151,7 @@ export const EditInstrumentPage = () => { />
- +