-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create team page #3
Conversation
…base schema changes
if (!exists) { | ||
return knex.schema.createTable('TeamMembers', (table) => { | ||
table.increments('id').unsigned().primary(); | ||
table.integer('team_id').unsigned().notNullable(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are missing something on this line.
return knex.schema.createTable('TeamMembers', (table) => { | ||
table.increments('id').unsigned().primary(); | ||
table.integer('team_id').unsigned().notNullable(); | ||
table.integer('employee_id').unsigned().notNullable(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think you are missing something here.
// }); | ||
// } | ||
|
||
// connectToDatabase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this file commented out?
@@ -16,6 +16,8 @@ module.exports = { | |||
directory: path.join(__dirname, '/seeds/development'), | |||
}, | |||
}, | |||
// Existing code... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??
function CreateTeam() { | ||
const [teamName, setTeamName] = useState(''); | ||
const [firstName, setFirstName] = useState(''); | ||
const [lastName, setLasttName] = useState(''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you have a typo in the setter
const [lastName, setLasttName] = useState(''); | ||
const [email, setEmail] = useState(''); | ||
const [teamMembers, setTeamMembers] = useState([]); | ||
const [employees] = useState([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could just do it like this:
const [employees] = useState([ | |
const employees = [<!-- data -->] |
email, | ||
}; | ||
|
||
teamMembers.push(newMember); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When adding new members to the team, you directly manipulate the DOM with teamMembers.push()
. React prefers immutability, so it's better to create a new array and then update the state.
} | ||
}; | ||
|
||
const addExcistingMember = (e) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check for typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left a few comments for you.
As I recommended earlier, it would be beneficial to break PRs
into smaller ones. For instance, having a separate PR for adding the migrations and another for CreateTeamPage
. Additionally, consider breaking down the component into smaller components to better separate concerns.
Description
This pull request introduces the CreateTeamPage component, allowing users to create new teams. Key features include:
Form Input:
Users can input a team name and add team members by providing their details or selecting existing employees.
Validation and Alerts:
The form includes validation checks and alerts for missing information or duplicate team members.
Dynamic Member List:
Added team members dynamically appear below the form for easy management.
How to test?
use the command "npm start"