Skip to content
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

Feature/alexzhang1618/group drop confirm #92

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 81 additions & 52 deletions client/src/components/CreateGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const fieldsReducer = (prevFields, { type, payload }) => {
function CreateGroup({ onConfirm, onCancel, editGroup, onDelete }) {
const [groupName, setGroupName] = useState("");
const [groupNameInvalid, setGroupNameInvalid] = useState(false);
const [confirmDelete, setConfirmDelete] = useState(false);

/**
* `fields` is an array of objects representing the group's fields. Each object has a `name` and
Expand Down Expand Up @@ -124,65 +125,93 @@ function CreateGroup({ onConfirm, onCancel, editGroup, onDelete }) {

return (
<div className="modal-background">
<div className="modal-view">
<form
className="group-form"
onSubmit={(event) => {
tryConfirm(groupName, fields);
event.preventDefault();
}}
>
<h1 className="group-first-header">{!editGroup ? "Create New Group" : "Edit Group"}</h1>
<h2 className="group-second-header">Group Name</h2>
<input
className={nameInputClass}
value={groupName}
onChange={(event) => setGroupName(event.target.value)}
/>
<h2 className="group-second-header">Fields</h2>
<h3 className="group-third-header">
List the fields you want associated with this group...
</h3>
<div className={fieldsListDivClass}>
{fields.map(({ name, type, invalid }, index) => (
<CreateGroupFieldRow
key={index}
index={index}
fieldName={name}
fieldType={type}
invalid={invalid}
changeDispatch={dispatch}
/>
))}
</div>
<button
className="add-field-button"
type="button"
onClick={() => dispatch({ type: "ADD_ROW" })}
>
<img src={AddFieldIcon} className="add-field-svg" alt="add field button icon" />
Add new field
</button>
<div className="group-submit-div">
<button className="group-modal-submit" type="submit">
{editGroup ? "Save" : "Create"}
</button>
{editGroup && (
{confirmDelete ? (
<div className="modal-view confirm-delete">
<div className="confirm-delete-div">
<h1 className="confirm-delete-header">Are you sure you want to delete this field?</h1>
<p className="confirm-delete-body">
Deleting this field will delete the data in its column. We recommend that you download
a CSV before deleting to save your data.
</p>
<div className="confirm-delete-buttons-div">
<button
className="group-modal-cancel"
className="group-modal-cancel confirm-delete"
type="button"
onClick={() => onDelete(editGroup.id)}
style={{ marginLeft: "20px" }}
>
Delete
</button>
)}
<button className="group-modal-cancel" type="button" onClick={onCancel}>
Cancel
</button>
<button
className="group-modal-cancel confirm-cancel"
type="button"
onClick={onCancel}
>
Cancel
</button>
</div>
</div>
</form>
</div>
</div>
) : (
<div className="modal-view">
<form
className="group-form"
onSubmit={(event) => {
tryConfirm(groupName, fields);
event.preventDefault();
}}
>
<h1 className="group-first-header">{!editGroup ? "Create New Group" : "Edit Group"}</h1>
<h2 className="group-second-header">Group Name</h2>
<input
className={nameInputClass}
value={groupName}
onChange={(event) => setGroupName(event.target.value)}
/>
<h2 className="group-second-header">Fields</h2>
<h3 className="group-third-header">
List the fields you want associated with this group...
</h3>
<div className={fieldsListDivClass}>
{fields.map(({ name, type, invalid }, index) => (
<CreateGroupFieldRow
key={index}
index={index}
fieldName={name}
fieldType={type}
invalid={invalid}
changeDispatch={dispatch}
/>
))}
</div>
<button
className="add-field-button"
type="button"
onClick={() => dispatch({ type: "ADD_ROW" })}
>
<img src={AddFieldIcon} className="add-field-svg" alt="add field button icon" />
Add new field
</button>
<div className="group-submit-div">
<button className="group-modal-submit" type="submit">
{editGroup ? "Save" : "Create"}
</button>
{editGroup && (
<button
className="group-modal-cancel"
type="button"
onClick={() => setConfirmDelete(true)}
style={{ marginLeft: "20px" }}
>
Delete
</button>
)}
<button className="group-modal-cancel" type="button" onClick={onCancel}>
Cancel
</button>
</div>
</form>
</div>
)}
</div>
);
}
Expand Down
50 changes: 50 additions & 0 deletions client/src/css/CreateGroup.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
height: 500px;
}

.modal-view.confirm-delete {
display: flex;
justify-content: center;
align-items: center;
height: 350px;
width: 475px;
padding: 0px;
}
.group-first-header {
font-size: 25px;
font-weight: bold;
Expand Down Expand Up @@ -138,3 +146,45 @@
color: #05204a;
cursor: pointer;
}

.confirm-delete-div {
width: 370px;
}

.confirm-delete-header {
font-weight: 500;
font-size: 24px;
line-height: 36px;
text-align: center;
margin: 0px;
margin-bottom: 10px;
}

.confirm-delete-body {
font-weight: 400;
font-size: 16px;
line-height: 24px;
text-align: center;
color: #353535;
margin-bottom: 30px;
}

.confirm-delete-buttons-div {
width: 270px;
height: 40px;
margin-top: 30px;
margin-left: 50px;
}
.group-modal-cancel.confirm-delete {
float: left;
margin: 0px;
background: #05204a;
color: #ffffff;
}

.group-modal-cancel.confirm-cancel {
float: right;
background: #ffffff;
border: 2px solid #949494;
color: #949494;
}