Skip to content

Commit b72b1f6

Browse files
committed
Adapt database schema with the demo + fix contact creation
1 parent d51da2a commit b72b1f6

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

packages/demo/db-seed.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async function main() {
6262
});
6363
const { data: persistedContacts, error: errorContacts } = await supabase
6464
.from('contacts')
65-
.insert(contacts)
65+
.insert(contacts.map(({ id, ...contact }) => contact))
6666
.select();
6767

6868
if (errorContacts) {

packages/demo/src/contacts/ContactInputs.tsx

+12-3
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,31 @@ import {
44
ReferenceInput,
55
AutocompleteInput,
66
BooleanInput,
7+
required,
78
} from 'react-admin';
89
import { Divider, Box } from '@mui/material';
910

1011
export const ContactInputs = () => {
1112
return (
1213
<Box flex="1" mt={-1}>
1314
<Box display="flex" width={430}>
14-
<TextInput source="first_name" fullWidth />
15+
<TextInput
16+
source="first_name"
17+
validate={required()}
18+
fullWidth
19+
/>
1520
<Spacer />
16-
<TextInput source="last_name" fullWidth />
21+
<TextInput source="last_name" validate={required()} fullWidth />
1722
</Box>
1823
<Box display="flex" width={430}>
1924
<TextInput source="title" fullWidth />
2025
<Spacer />
2126
<ReferenceInput source="company_id" reference="companies">
22-
<AutocompleteInput optionText="name" fullWidth />
27+
<AutocompleteInput
28+
optionText="name"
29+
fullWidth
30+
validate={required()}
31+
/>
2332
</ReferenceInput>
2433
</Box>
2534
<Divider />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
alter table "public"."companies" alter column "address" drop not null;
2+
alter table "public"."companies" alter column "city" drop not null;
3+
alter table "public"."companies" alter column "created_at" drop not null;
4+
alter table "public"."companies" alter column "linkedIn" drop not null;
5+
alter table "public"."companies" alter column "logo" drop not null;
6+
alter table "public"."companies" alter column "phone_number" drop not null;
7+
alter table "public"."companies" alter column "sales_id" drop not null;
8+
alter table "public"."companies" alter column "sector" drop not null;
9+
alter table "public"."companies" alter column "size" drop not null;
10+
alter table "public"."companies" alter column "stateAbbr" drop not null;
11+
alter table "public"."companies" alter column "website" drop not null;
12+
alter table "public"."companies" alter column "zipcode" drop not null;
13+
alter table "public"."contacts" alter column "acquisition" drop not null;
14+
alter table "public"."contacts" alter column "background" drop not null;
15+
alter table "public"."contacts" alter column "email" drop not null;
16+
alter table "public"."contacts" alter column "first_seen" drop not null;
17+
alter table "public"."contacts" alter column "gender" drop not null;
18+
alter table "public"."contacts" alter column "last_seen" drop not null;
19+
alter table "public"."contacts" alter column "phone_number1" drop not null;
20+
alter table "public"."contacts" alter column "phone_number2" drop not null;
21+
alter table "public"."contacts" alter column "sales_id" drop not null;
22+
alter table "public"."contacts" alter column "status" drop not null;
23+
alter table "public"."contacts" alter column "title" drop not null;
24+
alter table "public"."deals" alter column "amount" drop not null;
25+
alter table "public"."deals" alter column "contact_ids" drop not null;
26+
alter table "public"."deals" alter column "created_at" drop not null;
27+
alter table "public"."deals" alter column "description" drop not null;
28+
alter table "public"."deals" alter column "sales_id" drop not null;
29+
alter table "public"."deals" alter column "start_at" drop not null;
30+
alter table "public"."deals" alter column "type" drop not null;
31+
alter table "public"."deals" alter column "updated_at" drop not null;

0 commit comments

Comments
 (0)