Skip to content
This repository was archived by the owner on Jul 2, 2022. It is now read-only.

Commit 045acd5

Browse files
committed
feat: listen for applicant changes
1 parent dde41e3 commit 045acd5

File tree

6 files changed

+82
-149
lines changed

6 files changed

+82
-149
lines changed

client/src/components/StudentList.jsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import React, { useState } from 'react';
2-
import { useStudents, useStudentList } from '@/hooks';
2+
import { useStudents, useStudentList, useApplicantSubscription } from '@/hooks';
33
import Filters from './Filters';
44
import StudentCard from './StudentCard';
55

66
import styles from '../assets/styles/dashboard.module.css';
77

88
const StudentList = ({ showOnly }) => {
9+
useApplicantSubscription();
910
const { applicants, isLoading: applicantsLoading } = useStudentList();
1011
const { students, isLoading } = useStudents();
1112
const [filtered, setFiltered] = useState([]);

client/src/hooks/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export { default as useApplicantSubscription } from './useApplicantSubscription';
12
export { default as useAuth } from './useAuth';
23
export { default as useStudents } from './useStudents';
34
export { default as useSuggestions } from './useSuggestions';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { useSubscription } from 'urql';
2+
import { subscriptions } from 'common';
3+
4+
export default function useApplicantSubscription() {
5+
const [{ result, fetching }] = useSubscription({ query: subscriptions.APPLICANTS_CHANGED });
6+
7+
console.log(result);
8+
return null;
9+
}

package-lock.json

+23-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/prisma/seed.ts

+37-37
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,45 @@ const prisma = new PrismaClient();
66
async function main() {
77
console.log('seeding...');
88

9-
// for (let i = 0; i < 10; i++) {
10-
// await prisma.user.upsert({
11-
// where: { email: faker.internet.email() },
12-
// update: {},
13-
// create: {
14-
// uuid: faker.datatype.uuid(),
15-
// email: faker.internet.email(),
16-
// firstname: faker.name.firstName(),
17-
// lastname: faker.name.lastName(),
18-
// role: Math.random() < 0.5 ? Role.COACH : Role.USER
19-
// }
20-
// });
9+
for (let i = 0; i < 10; i++) {
10+
// await prisma.user.upsert({
11+
// where: { email: faker.internet.email() },
12+
// update: {},
13+
// create: {
14+
// uuid: faker.datatype.uuid(),
15+
// email: faker.internet.email(),
16+
// firstname: faker.name.firstName(),
17+
// lastname: faker.name.lastName(),
18+
// role: Math.random() < 0.5 ? Role.COACH : Role.USER
19+
// }
20+
// });
2121

22-
// const genders = ['male', 'female', 'nonbinary'];
22+
const genders = ['male', 'female', 'nonbinary'];
2323

24-
// await prisma.applicant.upsert({
25-
// where: { email: faker.internet.email() },
26-
// update: {},
27-
// create: {
28-
// uuid: faker.datatype.uuid(),
29-
// email: faker.internet.email(),
30-
// firstname: faker.name.firstName(),
31-
// lastname: faker.name.lastName(),
32-
// gender: genders[Math.floor(Math.random() * genders.length)],
33-
// nationality: 'Belgian',
34-
// phone: faker.phone.phoneNumber(),
35-
// address: {
36-
// create: {
37-
// addressLine: faker.address.streetAddress(),
38-
// city: faker.address.cityName(),
39-
// postalCode: faker.address.zipCode(),
40-
// state: faker.address.state(),
41-
// country: faker.address.country()
42-
// }
43-
// },
44-
// isAlumni: Math.random() < 0.5
45-
// }
46-
// });
47-
// }
24+
await prisma.applicant.upsert({
25+
where: { email: faker.internet.email() },
26+
update: {},
27+
create: {
28+
uuid: faker.datatype.uuid(),
29+
email: faker.internet.email(),
30+
firstname: faker.name.firstName(),
31+
lastname: faker.name.lastName(),
32+
gender: genders[Math.floor(Math.random() * genders.length)],
33+
nationality: 'Belgian',
34+
phone: faker.phone.phoneNumber(),
35+
address: {
36+
create: {
37+
addressLine: faker.address.streetAddress(),
38+
city: faker.address.cityName(),
39+
postalCode: faker.address.zipCode(),
40+
state: faker.address.state(),
41+
country: faker.address.country()
42+
}
43+
},
44+
isAlumni: Math.random() < 0.5
45+
}
46+
});
47+
}
4848
}
4949

5050
main()

server/src/schema.gql

+10-104
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
# THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY)
33
# ------------------------------------------------------
44

5-
type Skillset {
6-
id: Int!
7-
name: String!
8-
level: String!
9-
}
10-
115
type Address {
126
id: Int!
137
addressLine: String!
@@ -17,6 +11,13 @@ type Address {
1711
country: String!
1812
}
1913

14+
type Profile {
15+
id: Float!
16+
name: String!
17+
image_url: String
18+
applicants: [Applicant!]
19+
}
20+
2021
type User {
2122
id: Int!
2223
uuid: String!
@@ -39,11 +40,6 @@ A date-time string at UTC, such as 2019-12-03T09:54:33Z, compliant with the date
3940
"""
4041
scalar DateTime
4142

42-
type Skill {
43-
id: Int!
44-
name: String!
45-
}
46-
4743
type Project {
4844
id: Int!
4945
uuid: String!
@@ -54,20 +50,10 @@ type Project {
5450
leadCoach: User
5551
coaches: [User!]
5652
applicants: [Applicant!]
57-
profiles: [Profile!]
58-
skills: [Skill!]
5953
createdAt: DateTime!
6054
updatedAt: DateTime!
6155
}
6256

63-
type Profile {
64-
id: Float!
65-
name: String!
66-
image_url: String
67-
applicants: [Applicant!]
68-
projects: [Project!]
69-
}
70-
7157
type Suggestion {
7258
id: Int!
7359
status: String!
@@ -93,14 +79,11 @@ type Applicant {
9379
suggestions: [Suggestion!]
9480
projects: [Project!]
9581
profiles: [Profile!]
96-
skillset: [Skillset!]
9782
}
9883

9984
type Query {
100-
applicants(where: FilterApplicantInput): [Applicant!]!
85+
applicants: [Applicant!]!
10186
applicant(uuid: String!): Applicant!
102-
skills: [Skill!]!
103-
skill(id: Float!): Skill!
10487
users: [User!]!
10588
user(uuid: String!): User!
10689
suggestions: [Suggestion!]!
@@ -112,86 +95,12 @@ type Query {
11295
logout: User
11396
}
11497

115-
input FilterApplicantInput {
116-
AND: [FilterApplicantInput!]
117-
OR: [FilterApplicantInput!]
118-
NOT: [FilterApplicantInput!]
119-
email: StringFilter
120-
firstname: StringFilter
121-
lastname: StringFilter
122-
callname: StringFilter
123-
gender: StringFilter
124-
phone: StringFilter
125-
nationality: StringFilter
126-
address: FilterAddressInput
127-
isAlumni: Boolean
128-
profiles_every: FilterProfileInput
129-
projects_every: FilterProjectInput
130-
suggestions_every: FilterSuggestionInput
131-
skills_every: FilterSkillInput
132-
}
133-
134-
input StringFilter {
135-
equals: String
136-
in: [String!]
137-
notIn: [String!]
138-
lt: String
139-
lte: String
140-
gt: String
141-
gte: String
142-
contains: String
143-
startsWith: String
144-
endsWith: String
145-
}
146-
147-
input FilterAddressInput {
148-
AND: FilterAddressInput
149-
OR: FilterAddressInput
150-
NOT: FilterAddressInput
151-
addressLine: StringFilter
152-
postalCode: StringFilter
153-
city: StringFilter
154-
state: StringFilter
155-
country: StringFilter
156-
}
157-
158-
input FilterProfileInput {
159-
AND: [FilterProfileInput!]
160-
OR: [FilterProfileInput!]
161-
NOT: [FilterProfileInput!]
162-
name: StringFilter
163-
}
164-
165-
input FilterProjectInput {
166-
AND: FilterProjectInput
167-
OR: FilterProjectInput
168-
NOT: FilterProjectInput
169-
name: StringFilter
170-
client: StringFilter
171-
leadCoachId: Float
172-
}
173-
174-
input FilterSuggestionInput {
175-
AND: FilterSuggestionInput
176-
OR: FilterSuggestionInput
177-
NOT: FilterSuggestionInput
178-
status: StringFilter
179-
}
180-
181-
input FilterSkillInput {
182-
AND: FilterSkillInput
183-
OR: FilterSkillInput
184-
NOT: FilterSkillInput
185-
name: StringFilter
186-
}
187-
18898
type Mutation {
18999
createApplicant(input: CreateApplicantInput!): Applicant!
190100
updateApplicant(input: UpdateApplicantInput!, uuid: String!): Applicant!
191101
deleteApplicant(uuid: String!): Boolean!
192102
addApplicantToProject(projectId: Int!, applicantId: Int!): Boolean!
193103
removeApplicantFromProject(projectId: Int!, applicantId: Int!): Boolean!
194-
addSkillToApplicant(level: String!, skill: String!, applicantId: Int!): Boolean!
195104
updateUser(input: UpdateUserInput!, uuid: String!): User!
196105
deleteUser(uuid: String!): Boolean!
197106
addUserToProject(projectId: Int!, userId: Int!): Boolean!
@@ -202,14 +111,11 @@ type Mutation {
202111
createProject(input: CreateProjectInput!): Project!
203112
updateProject(input: UpdateProjectInput!, uuid: String!): Project!
204113
deleteProject(uuid: String!): Boolean!
205-
addSkillToProject(skill: String!, projectId: Int!): Boolean!
206114
createProfile(input: CreateProfileInput!): Profile!
207115
updateProfile(input: UpdateProfileInput!, id: Float!): Profile!
208116
deleteProfile(id: Float!): Boolean!
209-
addProfileToApplicant(profileId: Int!, applicantId: Int!): Boolean!
210-
removeProfileToApplicant(profileId: Int!, applicantId: Int!): Boolean!
211-
addProfileToProject(profileId: Int!, projectId: Int!): Boolean!
212-
removeProfileToProject(profileId: Int!, projectId: Int!): Boolean!
117+
addProfileToApplicant(projectId: Int!, applicantId: Int!): Boolean!
118+
removeProfileToApplicant(projectId: Int!, applicantId: Int!): Boolean!
213119
}
214120

215121
input CreateApplicantInput {

0 commit comments

Comments
 (0)