Skip to content

Commit

Permalink
Merge pull request #35 from gt-ospo/optional_case
Browse files Browse the repository at this point in the history
Made contact emails and contribution guidelines optional
  • Loading branch information
jyoung3131 authored Sep 27, 2024
2 parents f3783a5 + 35c621a commit 23473b0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
24 changes: 15 additions & 9 deletions src/components/ProjectFormPage/ProjectForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ const ProjectForm = forwardRef((props, ref) => {
newErrors.projectAbstract = formData.projectAbstract ? '' : 'Please enter an abstract on the project';

newErrors.projectUrl = formData.projectUrl ? (isUrl(formData.projectUrl) ? '' : 'URL is not in a valid format') : 'Please enter a URL to the project page';
newErrors.guidelinesUrl = formData.guidelinesUrl ? (isUrl(formData.guidelinesUrl) ? '' : 'URL is not in a valid format') : 'Please enter a URL to the project contribution guidelines';
newErrors.guidelinesUrl = formData.guidelinesUrl ? (isUrl(formData.guidelinesUrl) ? '' : 'URL is not in a valid format') : '';

newErrors.contacts = formData.contacts.map(contact => {
let contactError = {};
contactError.name = contact.name ? '' : 'Please enter a name';
contactError.email = contact.email ? (emailRegex.test(contact.email) ? '' : 'Contact email is not in valid email format') : 'Please enter an email';
contactError.email = contact.email ? (emailRegex.test(contact.email) ? '' : 'Contact email is not in valid email format') : '';
return contactError;
});

Expand Down Expand Up @@ -206,7 +206,7 @@ const ProjectForm = forwardRef((props, ref) => {

<div className="sm:col-span-2">
<label htmlFor="projectName" className="block font-semibold leading-6 text-gtblack">
Project Name
Project Name <span className="text-red-500">*</span>
</label>

<div className="mt-2.5">
Expand All @@ -227,7 +227,7 @@ const ProjectForm = forwardRef((props, ref) => {

<div className="sm:col-span-2">
<label htmlFor="projectAbstract" className="block font-semibold leading-6 text-gtblack">
Project Abstract
Project Abstract <span className="text-red-500">*</span>
</label>

<div className="mt-2.5">
Expand All @@ -247,7 +247,7 @@ const ProjectForm = forwardRef((props, ref) => {

<div className="sm:col-span-2">
<label htmlFor="projectAreas" className="block font-semibold leading-6 text-gtblack">
Project Areas
Project Areas <span className="text-red-500">*</span>
</label>

<Select
Expand Down Expand Up @@ -275,7 +275,7 @@ const ProjectForm = forwardRef((props, ref) => {

<div className="sm:col-span-2">
<label htmlFor="projectLicenses" className="block font-semibold leading-6 text-gtblack">
Project Licenses
Project Licenses <span className="text-red-500">*</span>
</label>

<Select
Expand All @@ -292,11 +292,11 @@ const ProjectForm = forwardRef((props, ref) => {

<div className="sm:col-span-2 grid grid-cols-1 gap-y-4">
<label className="block font-semibold leading-6 text-gtblack">
Primary Contact(s)
Primary Contact(s) <span className="text-red-500">*</span>
</label>

{formData.contacts.map((contact, index) => (
<div key={index} className="grid grid-cols-1 gap-x-8 gap-y-3 sm:grid-cols-2">
<div key={index} className="grid grid-cols-1 gap-x-8 sm:grid-cols-2">

<div className="col-span-2 flex items-center">
<div className="block text-sm font-semibold leading-6 text-gtblack">Contact {index + 1}</div>
Expand All @@ -314,6 +314,9 @@ const ProjectForm = forwardRef((props, ref) => {
</div>

<div>
<label className="block font-semibold text-xs leading-6 text-gtblack">
Name <span className="text-red-500">*</span>
</label>
<input
className="block w-full rounded-md border-0 px-3.5 py-2 text-gtblack shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-indigo-600 sm:text-sm"
type="text"
Expand All @@ -326,6 +329,9 @@ const ProjectForm = forwardRef((props, ref) => {
</div>

<div>
<label className="block font-semibold text-xs leading-6 text-gtblack">
Email
</label>
<input
className="block w-full rounded-md border-0 px-3.5 py-2 text-gtblack shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-indigo-600 sm:text-sm"
type="text"
Expand Down Expand Up @@ -360,7 +366,7 @@ const ProjectForm = forwardRef((props, ref) => {

<div className="sm:col-span-2">
<label htmlFor="projectUrl" className="block font-semibold leading-6 text-gtblack">
Project Page URL
Project Page URL <span className="text-red-500">*</span>
</label>

<div className="relative mt-2.5">
Expand Down
8 changes: 5 additions & 3 deletions src/components/ProjectTable/ProjectTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,19 @@ const ProjectTable = ({ columnFilters, showForm, onShowForm }) => {
{row.original.contacts.map((contact, index) => {
return (
<li className="mb-2 break-all">
{index + 1}. {contact.name} ({contact.email})
{index + 1}. {contact.name} {contact.email && `(${contact.email})`}
</li>
)
})}
</ul>
</div>

<div className="w-1/3">
<h3 className="text-center mb-2 font-semibold">URLs</h3>
<h3 className="text-center mb-2 font-semibold">URL(s)</h3>
<p className="font-medium">Project URL: <a href={row.original.projectUrl} className="font-normal break-all">{row.original.projectUrl}</a></p>
<p className="font-medium">Guidelines URL: <a href={row.original.guidelinesUrl} className="font-normal break-all">{row.original.guidelinesUrl}</a></p>
{row.original.guidelinesUrl && (
<p className="font-medium">Guidelines URL: <a href={row.original.guidelinesUrl} className="font-normal break-all">{row.original.guidelinesUrl}</a></p>
)}
</div>
</div>
</td>
Expand Down

0 comments on commit 23473b0

Please sign in to comment.