Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: more fixes
Browse files Browse the repository at this point in the history
userMeh committed Jul 23, 2024

Verified

This commit was signed with the committer’s verified signature.
1 parent 00b9891 commit 28cad0c
Showing 11 changed files with 53 additions and 23 deletions.
2 changes: 1 addition & 1 deletion apps/admin/app/ui/dashboard/addresses/AddAddress.tsx
Original file line number Diff line number Diff line change
@@ -223,7 +223,7 @@ function addAddress({ addresses, setAddresses }: Props): JSX.Element {
</div>
</div>
<div className="flex gap-4 mt-4">
<Button type="submit" className="w-full">
<Button type="submit" className="w-full" disabled={form.formState.isSubmitting}>
Créer
</Button>
<Button variant="secondary" type="button" onClick={() => setOpen(false)} className="w-full">
4 changes: 3 additions & 1 deletion apps/admin/app/ui/dashboard/addresses/EditForm.tsx
Original file line number Diff line number Diff line change
@@ -196,7 +196,9 @@ function EditForm(props: EditFormProps): JSX.Element {
</div>
</div>
<div className="flex gap-4 mt-4">
<Button type="submit">Modifier</Button>
<Button type="submit" disabled={form.formState.isSubmitting}>
Modifier
</Button>
<Button
variant="secondary"
onClick={(e) => {
14 changes: 7 additions & 7 deletions apps/admin/app/ui/dashboard/tournaments/AddTournaments.tsx
Original file line number Diff line number Diff line change
@@ -54,8 +54,8 @@ function AddTournaments({ tournaments, setTournaments, addresses, sports }: Prop
team_capacity: z.coerce
.number({ message: 'Le champ doit contenir un nombre' })
.min(1, { message: "La capacité de l'équipe ne peut être inférieur à 1" }),
id_address: z.coerce.number().min(1).optional(),
id_sport: z.coerce.number().min(1).optional(),
id_address: z.coerce.number().optional(),
id_sport: z.coerce.number().optional(),
rules: z.string().optional(),
prize: z.string().optional(),
image: z
@@ -75,8 +75,8 @@ function AddTournaments({ tournaments, setTournaments, addresses, sports }: Prop
default_match_length: undefined,
max_participants: 1,
team_capacity: 1,
id_address: undefined,
id_sport: undefined,
id_address: -1,
id_sport: -1,
rules: '',
prize: '',
},
@@ -88,8 +88,8 @@ function AddTournaments({ tournaments, setTournaments, addresses, sports }: Prop
if (values.default_match_length) formData.append('default_match_length', values.default_match_length.toString());
formData.append('max_participants', values.max_participants.toString());
formData.append('team_capacity', values.team_capacity.toString());
if (values.id_address) formData.append('id_address', values.id_address.toString());
if (values.id_sport) formData.append('id_sport', values.id_sport.toString());
if (values.id_address !== -1 && values.id_address) formData.append('id_address', values.id_address.toString());
if (values.id_sport !== -1 && values.id_sport) formData.append('id_sport', values.id_sport.toString());
if (values.rules) formData.append('rules', values.rules);
if (values.prize) formData.append('prize', values.prize);
formData.append('image', values.image[0]);
@@ -312,7 +312,7 @@ function AddTournaments({ tournaments, setTournaments, addresses, sports }: Prop
</div>
</div>
<div className="flex gap-4 mt-4">
<Button type="submit" className="w-full">
<Button type="submit" className="w-full" disabled={form.formState.isSubmitting}>
Créer
</Button>
<Button variant="secondary" type="button" onClick={() => setOpen(false)} className="w-full">
1 change: 1 addition & 0 deletions apps/admin/app/ui/dashboard/tournaments/EditForm.tsx
Original file line number Diff line number Diff line change
@@ -281,6 +281,7 @@ function EditForm(props: EditFormProps): JSX.Element {
e.preventDefault();
props.closeDialog();
}}
disabled={form.formState.isSubmitting}
>
Annuler
</Button>
2 changes: 1 addition & 1 deletion apps/admin/app/ui/dashboard/votes/AddPoll.tsx
Original file line number Diff line number Diff line change
@@ -262,7 +262,7 @@ function AddPoll({ polls, setPolls, assemblies }: Props) {
</Button>
</div>
<div className="flex gap-4 mt-4">
<Button type="submit" className="w-full">
<Button type="submit" className="w-full" disabled={form.formState.isSubmitting}>
Créer
</Button>
<Button variant="secondary" type="button" onClick={() => setOpen(false)} className="w-full">
2 changes: 1 addition & 1 deletion apps/admin/app/ui/dashboard/votes/EditPoll.tsx
Original file line number Diff line number Diff line change
@@ -191,7 +191,7 @@ function EditPoll({ poll, setter, assemblies }: Props) {
/>
</div>
<div className="flex gap-4 mt-4">
<Button type="submit" className="w-full">
<Button type="submit" className="w-full" disabled={form.formState.isSubmitting}>
Modifier
</Button>
<Button variant="secondary" type="button" className="w-full">
5 changes: 3 additions & 2 deletions apps/api/src/handlers/tournaments.ts
Original file line number Diff line number Diff line change
@@ -88,8 +88,9 @@ tournaments.openapi(getTournamentById, async (c) => {
});

tournaments.openapi(createTournament, async (c) => {
const { name, default_match_length, max_participants, team_capacity, rules, prize, id_address, image } =
const { name, default_match_length, max_participants, team_capacity, rules, prize, id_address, id_sport, image } =
c.req.valid('form');

if (image === null) {
return c.json({ error: 'You must provide an image' }, 400);
}
@@ -99,7 +100,7 @@ tournaments.openapi(createTournament, async (c) => {

const { data, error } = await supabase
.from('TOURNAMENTS')
.insert({ name, default_match_length, max_participants, team_capacity, rules, prize, id_address })
.insert({ name, default_match_length, max_participants, team_capacity, rules, prize, id_address, id_sport })
.select()
.single();

2 changes: 1 addition & 1 deletion apps/api/src/validators/tournaments.ts
Original file line number Diff line number Diff line change
@@ -22,8 +22,8 @@ export const createTournamentSchema = z.object({
rules: z.string().optional(),
prize: z.string().optional(),
id_address: z.coerce.number().min(1).optional(),
description: z.string().optional(),
id_sport: z.coerce.number().min(1).optional(),
description: z.string().optional(),
image: z.instanceof(File),
});

1 change: 0 additions & 1 deletion apps/client/app/(withNavbar)/blog/myposts/page.tsx
Original file line number Diff line number Diff line change
@@ -33,7 +33,6 @@ export default function Page(): JSX.Element {
}, [router]);

function fetchPosts(user: User | null) {
console.log('user : ', user);
fetch(`${process.env.NEXT_PUBLIC_API_URL}/blog/posts?skip=0&take=20&userId=${user?.id}`)
.then((r) => {
return r.json();
12 changes: 4 additions & 8 deletions packages/types/src/database.ts
Original file line number Diff line number Diff line change
@@ -313,7 +313,7 @@ export type Database = {
};
Relationships: [
{
foreignKeyName: 'public_ADDRESS_id_lease_fkey';
foreignKeyName: 'ADDRESSES_id_lease_fkey';
columns: ['id_lease'];
isOneToOne: false;
referencedRelation: 'LEASE';
@@ -1589,7 +1589,7 @@ export type Database = {
foreignKeyName: 'TOURNAMENTS_id_address_fkey';
columns: ['id_address'];
isOneToOne: false;
referencedRelation: 'TOURNAMENTS';
referencedRelation: 'ADDRESSES';
referencedColumns: ['id'];
},
{
@@ -1718,14 +1718,14 @@ export type Database = {
};
Relationships: [
{
foreignKeyName: 'public_USERS_TEAMS_id_team_fkey';
foreignKeyName: 'USERS_TEAMS_id_team_fkey';
columns: ['id_team'];
isOneToOne: false;
referencedRelation: 'TEAMS';
referencedColumns: ['id'];
},
{
foreignKeyName: 'public_USERS_TEAMS_id_user_fkey';
foreignKeyName: 'USERS_TEAMS_id_user_fkey';
columns: ['id_user'];
isOneToOne: false;
referencedRelation: 'USERS';
@@ -2056,10 +2056,6 @@ export type Database = {
updated_at: string;
}[];
};
operation: {
Args: Record<PropertyKey, never>;
Returns: string;
};
search: {
Args: {
prefix: string;
31 changes: 31 additions & 0 deletions supabase/migrations/20240723130722_cascade_delete.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
alter table "public"."ADDRESSES" drop constraint "public_ADDRESS_id_lease_fkey";

alter table "public"."USERS_TEAMS" drop constraint "public_USERS_TEAMS_id_team_fkey";

alter table "public"."USERS_TEAMS" drop constraint "public_USERS_TEAMS_id_user_fkey";

alter table "public"."ROUNDS" drop constraint "ROUNDS_id_tournament_fkey";

alter table "public"."TOURNAMENTS" drop constraint "TOURNAMENTS_id_address_fkey";

alter table "public"."ADDRESSES" add constraint "ADDRESSES_id_lease_fkey" FOREIGN KEY (id_lease) REFERENCES "LEASE"(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;

alter table "public"."ADDRESSES" validate constraint "ADDRESSES_id_lease_fkey";

alter table "public"."USERS_TEAMS" add constraint "USERS_TEAMS_id_team_fkey" FOREIGN KEY (id_team) REFERENCES "TEAMS"(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;

alter table "public"."USERS_TEAMS" validate constraint "USERS_TEAMS_id_team_fkey";

alter table "public"."USERS_TEAMS" add constraint "USERS_TEAMS_id_user_fkey" FOREIGN KEY (id_user) REFERENCES "USERS"(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;

alter table "public"."USERS_TEAMS" validate constraint "USERS_TEAMS_id_user_fkey";

alter table "public"."ROUNDS" add constraint "ROUNDS_id_tournament_fkey" FOREIGN KEY (id_tournament) REFERENCES "TOURNAMENTS"(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;

alter table "public"."ROUNDS" validate constraint "ROUNDS_id_tournament_fkey";

alter table "public"."TOURNAMENTS" add constraint "TOURNAMENTS_id_address_fkey" FOREIGN KEY (id_address) REFERENCES "ADDRESSES"(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;

alter table "public"."TOURNAMENTS" validate constraint "TOURNAMENTS_id_address_fkey";


0 comments on commit 28cad0c

Please sign in to comment.