From 9d64e300c70aeba50ab4a22f37cb9d265ecbac5e Mon Sep 17 00:00:00 2001 From: Julien MAIRE Date: Tue, 4 Feb 2025 10:49:22 +0100 Subject: [PATCH 1/4] added users edit form --- src/App.tsx | 4 +++- src/users/UserEdit.tsx | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/users/UserEdit.tsx diff --git a/src/App.tsx b/src/App.tsx index c57d01b..a09b69f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -12,6 +12,7 @@ import { Box, Typography } from "@mui/material"; import { GameShow } from "./games/GameShow"; import { Route } from "react-router"; import { UserList } from "./users/UserList"; +import { UserEdit } from "./users/UserEdit"; const instanceUrl = import.meta.env.VITE_SUPABASE_API_URL || "http://127.0.0.1:54321"; @@ -67,8 +68,9 @@ const App = () => { options={{ label: "Games" }} > diff --git a/src/users/UserEdit.tsx b/src/users/UserEdit.tsx new file mode 100644 index 0000000..0f051ff --- /dev/null +++ b/src/users/UserEdit.tsx @@ -0,0 +1,22 @@ +import { + Edit, + SimpleForm, + TextInput, + EmailField, + ReferenceInput, + AutocompleteInput, +} from "react-admin"; + +export const UserEdit = () => ( + + + + + + + + + + + +); From d61a1acc2e0d21430fdf02a152e601254cc7c0a8 Mon Sep 17 00:00:00 2001 From: Julien MAIRE Date: Tue, 4 Feb 2025 10:54:48 +0100 Subject: [PATCH 2/4] Added sql migration: cascade on games when deleting users. --- ...0240204105200_cascade_users_delete_on_games.sql | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 supabase/migrations/20240204105200_cascade_users_delete_on_games.sql diff --git a/supabase/migrations/20240204105200_cascade_users_delete_on_games.sql b/supabase/migrations/20240204105200_cascade_users_delete_on_games.sql new file mode 100644 index 0000000..75d288a --- /dev/null +++ b/supabase/migrations/20240204105200_cascade_users_delete_on_games.sql @@ -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; \ No newline at end of file From 6a37ed567d3916a0fd359ea7c7147a2cad767b83 Mon Sep 17 00:00:00 2001 From: Julien MAIRE Date: Tue, 4 Feb 2025 12:15:32 +0100 Subject: [PATCH 3/4] change email input. Used redirect. fix ressource name --- src/App.tsx | 2 +- src/users/UserDataProvider.tsx | 0 src/users/UserEdit.tsx | 16 ++++++++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 src/users/UserDataProvider.tsx diff --git a/src/App.tsx b/src/App.tsx index a09b69f..2188c72 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -68,7 +68,7 @@ const App = () => { options={{ label: "Games" }} > ({ + "name@ilike": `%${searchText}%`, +}); + export const UserEdit = () => ( - + - + - + From 57165bccb191916363c684dd57f93e179a88cd56 Mon Sep 17 00:00:00 2001 From: Julien MAIRE Date: Tue, 4 Feb 2025 12:59:13 +0100 Subject: [PATCH 4/4] remove the ability to select row in lists --- src/games/GameList.tsx | 2 +- src/users/UserList.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/games/GameList.tsx b/src/games/GameList.tsx index 42b1404..08f6ca2 100644 --- a/src/games/GameList.tsx +++ b/src/games/GameList.tsx @@ -31,7 +31,7 @@ const postFilters = [ export const GameList = () => ( - + false}> diff --git a/src/users/UserList.tsx b/src/users/UserList.tsx index 87a3d10..ed7fe70 100644 --- a/src/users/UserList.tsx +++ b/src/users/UserList.tsx @@ -22,7 +22,7 @@ const postFilters = [ export const UserList = () => ( - + false}>