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

Location Modal #505

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
128 changes: 74 additions & 54 deletions frontend/src/components/LocationModal/LocationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const LocationModal = ({
const { name, address, info } = errors;

const modalTitle = existingLocation ? 'Edit Location' : 'Add a Location';
const submitButtonText = existingLocation ? 'Save' : 'Add';
const submitButtonText = existingLocation ? 'Save' : 'Add Location';

const openModal = () => {
setIsOpen(true);
Expand Down Expand Up @@ -97,64 +97,84 @@ const LocationModal = ({
<Modal title={modalTitle} isOpen={isOpen} onClose={closeModal}>
<form onSubmit={handleSubmit(onSubmit)}>
<div className={styles.inputContainer}>
<Label htmlFor="name">Name</Label>
<Input
name="name"
type="text"
id="name"
defaultValue={existingLocation?.name}
className={styles.input}
ref={register({ required: true })}
aria-required="true"
/>
{name && <p className={styles.errorMsg}>Please enter a name</p>}
<Label htmlFor="address">Address</Label>
<Input
name="address"
type="text"
id="address"
defaultValue={existingLocation?.address}
className={styles.input}
aria-required="true"
ref={register({ required: true })}
/>
{address && <p className={styles.errorMsg}>{address.message}</p>}
<Label htmlFor="info">Pickup/Dropoff Info</Label>
<Input
name="info"
type="text"
id="info"
defaultValue={existingLocation?.info}
className={styles.input}
ref={register({ required: true })}
aria-required="true"
/>
{info && (
<p className={styles.errorMsg}>
Please enter pickup/dropoff info
</p>
)}
<Label htmlFor="tag">Tag</Label>
<select
name="tag"
id="tag"
defaultValue={existingLocation?.tag}
ref={register({ required: true })}
className={styles.inputContainer}
aria-required="true"
>
{Object.values(Tag).map((value) =>
value === 'custom' ? null : (
<option key={value} value={value}>
{value}
</option>
)
<div style={{ gridArea: 'name' }}>
<Label htmlFor="name">Name</Label>
<Input
name="name"
type="text"
id="name"
defaultValue={existingLocation?.name}
className={styles.input}
ref={register({ required: true })}
aria-required="true"
/>
{name && <p className={styles.errorMsg}>Please enter a name</p>}
</div>

<div style={{ gridArea: 'address' }}>
<Label htmlFor="address">Address</Label>
<Input
name="address"
type="text"
id="address"
defaultValue={existingLocation?.address}
className={styles.input}
aria-required="true"
ref={register({ required: true })}
/>
{address && <p className={styles.errorMsg}>{address.message}</p>}
</div>

<div style={{ gridArea: 'info' }}>
<Label htmlFor="info">Pickup / Dropoff Information</Label>
<Input
name="info"
type="text"
id="info"
defaultValue={existingLocation?.info}
className={styles.input}
ref={register({ required: true })}
aria-required="true"
/>
{info && (
<p className={styles.errorMsg}>
Please enter pickup/dropoff info
</p>
)}
</select>
</div>

<div style={{ gridArea: 'tag' }}>
<Label htmlFor="tag">Tag</Label>
<select
name="tag"
id="tag"
defaultValue={existingLocation?.tag}
ref={register({ required: true })}
className={styles.inputContainer}
aria-required="true"
>
{Object.values(Tag).map((value) =>
value === 'custom' ? null : (
<option key={value} value={value}>
{value}
</option>
)
)}
</select>
</div>

<div>
<Button className={styles.submit} type="submit">
{submitButtonText}
</Button>

<Button className={styles.clearButton} type="submit">
raissaji marked this conversation as resolved.
Show resolved Hide resolved
Clear All
</Button>

<Button className={styles.backButton} type="submit">
Back
</Button>
</div>
</div>
</form>
Expand Down
48 changes: 41 additions & 7 deletions frontend/src/components/LocationModal/locationmodal.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,23 @@
margin-bottom: 0.5rem;
}

input[name='info'] {
height: 103px;
}

input[name='address'] {
width: 298px;
}

.label,
.input {
font-size: 1.5rem;
min-height: 40px;
width: 280px;
border-radius: 6px;
border: 1px solid #808080;
display: flex;
flex-direction: column;
font-size: 0.875rem;
height: 31px;
width: 224px;
raissaji marked this conversation as resolved.
Show resolved Hide resolved
}

.errorMsg {
Expand All @@ -19,14 +32,35 @@
padding: 0.2rem;
}

div > Button {
float: right;
margin-left: 10px;
}

.submit {
float: right;
}

.inputContainer {
min-height: 40px;
width: 280px;
font-size: 1.5rem;
display: block;
font-size: 0.875rem;
display: grid;
grid-template-columns: 1fr 1fr auto;

row-gap: 30px;

grid-template-areas:
'name address'
'info tag'
'buttons buttons';

margin-bottom: 0.75rem;
}

.inputContainer select {
width: 124px;
height: 31px;
}

.inputContainer > div:last-child {
grid-area: buttons;
}
8 changes: 7 additions & 1 deletion frontend/src/components/Modal/modal.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
padding: 2rem 2.25rem;
border-radius: 1rem;
z-index: 1010;

/* This fixes the height and width of every modal, which may be necessary. However, location, rider, employee modals have different dimensions, which wil pose a problem later. */
height: 386px;
width: 616px;
}

.title {
Expand All @@ -25,16 +29,18 @@
}

.closeBtn {
outline: none;
border: none;
cursor: pointer;
background: none;
padding: 0;
margin-left: 0.75rem;
}

.closeBtn:focus {
.closeBtn:active {
outline: 3px solid black;
}

.topContainer {
display: flex;
justify-content: space-between;
Expand Down
Loading