-
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.
Merge pull request #10 from marmelab/features/edit-users
added users edit form
- Loading branch information
Showing
6 changed files
with
48 additions
and
2 deletions.
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
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
Empty file.
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,30 @@ | ||
import { | ||
Edit, | ||
SimpleForm, | ||
TextInput, | ||
ReferenceInput, | ||
AutocompleteInput, | ||
email, | ||
} from "react-admin"; | ||
|
||
const filterToQuery = (searchText: any) => ({ | ||
"name@ilike": `%${searchText}%`, | ||
}); | ||
|
||
export const UserEdit = () => ( | ||
<Edit resource="users" redirect="/users_view"> | ||
<SimpleForm> | ||
<TextInput source="username" label="Username" /> | ||
<TextInput source="first_name" label="First Name" /> | ||
<TextInput source="last_name" label="Last Name" /> | ||
<TextInput source="email" label="Email" validate={email()} /> | ||
<ReferenceInput source="league_id" reference="leagues"> | ||
<AutocompleteInput | ||
optionText="name" | ||
label="League" | ||
filterToQuery={filterToQuery} | ||
/> | ||
</ReferenceInput> | ||
</SimpleForm> | ||
</Edit> | ||
); |
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
14 changes: 14 additions & 0 deletions
14
supabase/migrations/20240204105200_cascade_users_delete_on_games.sql
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,14 @@ | ||
ALTER TABLE games DROP CONSTRAINT IF EXISTS games_first_player_id_fkey; | ||
ALTER TABLE games DROP CONSTRAINT IF EXISTS games_second_player_id_fkey; | ||
|
||
ALTER TABLE games | ||
ADD CONSTRAINT games_first_player_id_fkey | ||
FOREIGN KEY (first_player_id) | ||
REFERENCES users(id) | ||
ON DELETE CASCADE; | ||
|
||
ALTER TABLE games | ||
ADD CONSTRAINT games_second_player_id_fkey | ||
FOREIGN KEY (second_player_id) | ||
REFERENCES users(id) | ||
ON DELETE CASCADE; |