-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added create/list/show/edit for schools to RA (#476)
* Added create/list/show/edit for schools to RA * Removed unneceseary form transform * Changed to built-in email validation * Fixed lint errors * Fixed even more lint errors
- Loading branch information
Showing
5 changed files
with
120 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/components/Admin/resources/personal/schools/SchoolCreate.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import {FC} from 'react' | ||
import {AutocompleteInput, email, ReferenceInput, required, SimpleForm, TextInput} from 'react-admin' | ||
|
||
import {MyCreate} from '@/components/Admin/custom/MyCreate' | ||
|
||
export const SchoolCreate: FC = () => ( | ||
<MyCreate> | ||
<SimpleForm> | ||
<TextInput | ||
fullWidth | ||
source="name" | ||
helperText="Oficiálny názov školy. Napr. Gymnázium Jura Hronca" | ||
validate={required()} | ||
/> | ||
<TextInput fullWidth source="street" validate={required()} /> | ||
<TextInput fullWidth source="city" validate={required()} /> | ||
<TextInput fullWidth source="zip_code" helperText="PSČ školy" validate={required()} /> | ||
<ReferenceInput source="district" reference="personal/districts"> | ||
<AutocompleteInput fullWidth validate={required()} /> | ||
</ReferenceInput> | ||
<TextInput | ||
fullWidth | ||
source="abbreviation" | ||
helperText="Skratka školy. Zadávajte v tvare napr.: SNov3BA (Druh školy, adresa, číslo, okres)" | ||
validate={required()} | ||
/> | ||
<TextInput | ||
fullWidth | ||
source="email" | ||
helperText="Emailový kontakt na školu. Ak neexistuje všeobecný, tak napr. na riaditeľa/vyučujúceho" | ||
validate={email()} | ||
/> | ||
</SimpleForm> | ||
</MyCreate> | ||
) |
35 changes: 35 additions & 0 deletions
35
src/components/Admin/resources/personal/schools/SchoolEdit.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import {FC} from 'react' | ||
import {AutocompleteInput, email, ReferenceInput, required, SimpleForm, TextInput} from 'react-admin' | ||
|
||
import {MyEdit} from '@/components/Admin/custom/MyEdit' | ||
|
||
export const SchoolEdit: FC = () => ( | ||
<MyEdit> | ||
<SimpleForm> | ||
<TextInput | ||
fullWidth | ||
source="name" | ||
helperText="Oficiálny názov školy. Napr. Gymnázium Jura Hronca" | ||
validate={required()} | ||
/> | ||
<TextInput fullWidth source="street" validate={required()} /> | ||
<TextInput fullWidth source="city" validate={required()} /> | ||
<TextInput fullWidth source="zip_code" helperText="PSČ školy" validate={required()} /> | ||
<ReferenceInput source="district" reference="personal/districts"> | ||
<AutocompleteInput fullWidth validate={required()} /> | ||
</ReferenceInput> | ||
<TextInput | ||
fullWidth | ||
source="abbreviation" | ||
helperText="Skratka školy. Zadávajte v tvare napr.: SNov3BA (Druh školy, adresa, číslo, okres)" | ||
validate={required()} | ||
/> | ||
<TextInput | ||
fullWidth | ||
source="email" | ||
helperText="Emailový kontakt na školu. Ak neexistuje všeobecný, tak napr. na riaditeľa/vyučujúceho" | ||
validate={email()} | ||
/> | ||
</SimpleForm> | ||
</MyEdit> | ||
) |
15 changes: 15 additions & 0 deletions
15
src/components/Admin/resources/personal/schools/SchoolList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {FC} from 'react' | ||
import {Datagrid, List, TextField} from 'react-admin' | ||
|
||
import {TruncatedTextField} from '@/components/Admin/custom/TruncatedTextField' | ||
|
||
export const SchoolList: FC = () => ( | ||
<List> | ||
<Datagrid rowClick="show"> | ||
<TruncatedTextField source="name" maxTextWidth={60} /> | ||
<TextField source="street" /> | ||
<TextField source="city" /> | ||
<TextField source="abbreviation" /> | ||
</Datagrid> | ||
</List> | ||
) |
17 changes: 17 additions & 0 deletions
17
src/components/Admin/resources/personal/schools/SchoolShow.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {FC} from 'react' | ||
import {EmailField, ReferenceField, SimpleShowLayout, TextField} from 'react-admin' | ||
|
||
import {MyShow} from '@/components/Admin/custom/MyShow' | ||
|
||
export const SchoolShow: FC = () => ( | ||
<MyShow> | ||
<SimpleShowLayout> | ||
<TextField source="name" /> | ||
<TextField source="street" /> | ||
<TextField source="zip_code" /> | ||
<ReferenceField source="district" reference="personal/districts" /> | ||
<TextField source="abbreviation" /> | ||
<EmailField source="email" /> | ||
</SimpleShowLayout> | ||
</MyShow> | ||
) |