Skip to content

Commit

Permalink
fix: minor error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
NivedhaSV committed Nov 2, 2023
1 parent d5544ae commit 5f76c7b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
9 changes: 9 additions & 0 deletions apps/web-app/components/projects/action-buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ export default function ActionButtons(){
}
errors['projectURLs'][index]['text'] = 'Link text is required';
}
if(!link.url && link.text){
if(!errors['projectURLs']){
errors['projectURLs'] = new Array(inputs.projectURLs.length).fill(null);
}
if(!errors['projectURLs'][index]){
errors['projectURLs'][index] = {};
}
errors['projectURLs'][index]['url'] = 'Link url is required';
}
if(link.url && !link.url.match(urlRE)){
if(!errors['projectURLs']){
errors['projectURLs'] = new Array(inputs.projectURLs.length).fill(null);
Expand Down
1 change: 0 additions & 1 deletion apps/web-app/components/projects/add-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ export default function AddForm() {
required={true}
name="name"
label="Project Name"
pattern="^[a-zA-Z\s]*$"
maxLength={64}
value={addProjectsState.inputs.name}
onChange={onInputChange}
Expand Down
4 changes: 2 additions & 2 deletions apps/web-app/components/projects/details/readme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default function AdditionalDetails({ project }) {
isTeamOftheProject
&& <span>
<span className='text-[#156FF7] cursor-pointer'
onClick={onEditAction}>Click Here</span>
onClick={onEditAction}> Click Here </span>
to add additional details (markdown supported).
</span>
}
Expand All @@ -87,7 +87,7 @@ export default function AdditionalDetails({ project }) {
</div>
{
showEditor && <div>
<MdEditor modelValue={text} onChange={setText} language={'en-US'} onSave={onSaveAction} toolbarsExclude={['catalog', 'github', 'save', 'htmlPreview']} />
<MdEditor modelValue={text} onChange={setText} language={'en-US'} toolbarsExclude={['catalog', 'github', 'save', 'htmlPreview']} />
</div>
}

Expand Down
4 changes: 2 additions & 2 deletions apps/web-app/components/projects/url.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function URLDetails({ onInputChange, urlFieldArray, setURLField }
placeholder="Enter Link Text"
className="custom-grey custom-outline-none border"
/>
<InputError content={addProjectsState.errors?.projectURLs?.[index]['text']}/>
<InputError content={addProjectsState.errors?.projectURLs?.[index]?.['text']}/>
</div>
<div className="w-[340px]">
<InputField
Expand All @@ -62,7 +62,7 @@ export default function URLDetails({ onInputChange, urlFieldArray, setURLField }
placeholder="Enter Link"
className="custom-grey custom-outline-none border"
/>
<InputError content={addProjectsState.errors?.projectURLs?.[index]['url']}/>
<InputError content={addProjectsState.errors?.projectURLs?.[index]?.['url']}/>
</div>
<div className="cursor-pointer" onClick={() => {
deleteURLRow(field.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function TeamProfileProjects({ projects, userInfo, team }) {

{
projects.length === 0 && isTeamLead && <div className="p-[16px] max-h-96 overflow-y-auto rounded-xl shadow-[0px_0px_2px_rgba(15,23,42,0.16),0px_2px_2px_rgba(15,23,42,0.04)] focus-within:outline-none focus:outline-none focus-visible:outline-none">
You have not added any projects. <span className="text-[#156FF7] cursor-pointer" onClick={() => { router.push('/directory/projects/add?teamUid='+team.uid) }}>Click Here</span> to add a new project.
You have not added any projects. <span className="text-[#156FF7] cursor-pointer" onClick={() => { router.push('/directory/projects/add?teamUid='+team.id) }}>Click Here</span> to add a new project.
</div>
}
{
Expand Down
7 changes: 6 additions & 1 deletion apps/web-app/pages/directory/teams/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,12 @@ export const getServerSideProps: GetServerSideProps<TeamProps> = async (ctx) =>

const { getTeamsProject } = ProjectsService;

const teamsProjectList = await getTeamsProject(id);
let teamsProjectList = [];
try{
teamsProjectList = await getTeamsProject(id);
}catch(err){
console.log(err);
}

// Redirects user to the 404 page when we're unable to fetch
// a valid team with the provided ID
Expand Down

0 comments on commit 5f76c7b

Please sign in to comment.