Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix crash when name field is deleted in Airtable
  • Loading branch information
imadibrahimk committed Nov 16, 2023
commit daf7b5ac0b79ad7fea01f359235525f0adb0ceb4
4 changes: 1 addition & 3 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ function App() {
const fetchRecords = async () => {
try {
// Fetch data from the server
// const response = await fetch('http://localhost:8000/records');
const response = await fetch('https://tinker-backend-bbjncdnbpby9.deno.dev/records');

const response = await fetch('https://tinker-backend-bbjncdnbpby9.deno.dev/records');

// Throw an error if the response is not ok
if (!response.ok) {
Expand Down
26 changes: 21 additions & 5 deletions frontend/src/components/Cards/Cards.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "slick-carousel/slick/slick-theme.css";
// Function to truncate a string to a certain length
function truncate(str, length) {
if (str === undefined) {
return 'Anonymous';
return null;
} else {
if (str.length > length) {
const end = str.lastIndexOf(' ', 12);
Expand Down Expand Up @@ -46,11 +46,19 @@ function Cards(props) {

// Function to render mentor card
const renderCardMentor = (data) => {

// If the name is not present, return null
if (!data.fields['First name (from Your name)']) {
return null;
}

let url;
if (
data.fields &&
data.fields["Enter your Photo (from Your name)"] &&
data.fields["Enter your Photo (from Your name)"].length > 0
data.fields["Enter your Photo (from Your name)"].length > 0 &&
data.fields["Enter your Photo (from Your name)"][0].thumbnails &&
data.fields["Enter your Photo (from Your name)"][0].thumbnails.large
) {
url = data.fields["Enter your Photo (from Your name)"][0].thumbnails.large.url;
}
Expand All @@ -64,7 +72,7 @@ function Cards(props) {
<h2 className="w-[150px] h-[24px] text-[20px] font-bold">{truncate(data.fields['First name (from Your name)'][0], 11)}</h2>
<hr className=' border-t-[2px]' style={{borderColor: '#876100'}} />
<p className="w-[150px] h-[22px] text-[18px]">{data.fields["Enter the domain that you will be working on."] ? truncate(data.fields["Enter the domain that you will be working on."],10) : 'Undefined' }</p>
<p className="w-[150px] h-[22px] text-[18px]" style={{color: '#876100'}}>{truncate(data.fields["What will you be doing at the space today?"],19)}</p>
<p className="w-[150px] h-[22px] text-[18px]" style={{color: '#876100'}}>{data.fields["What will you be doing at the space today?"] ? truncate(data.fields["What will you be doing at the space today?"],19) : 'Undefined'}</p>
</div>
</div>
</div>
Expand All @@ -74,11 +82,19 @@ function Cards(props) {

// Function to render mentee card
const renderCardMentee = (data) => {

// If the name is not present, return null
if (!data.fields['First name (from Your name)']) {
return null;
}

let url;
if (
data.fields &&
data.fields["Enter your Photo (from Your name)"] &&
data.fields["Enter your Photo (from Your name)"].length > 0
data.fields["Enter your Photo (from Your name)"].length > 0 &&
data.fields["Enter your Photo (from Your name)"][0].thumbnails &&
data.fields["Enter your Photo (from Your name)"][0].thumbnails.large
) {
url = data.fields["Enter your Photo (from Your name)"][0].thumbnails.large.url;
}
Expand All @@ -92,7 +108,7 @@ const renderCardMentee = (data) => {
<h2 className="w-[117.66px] h-[13px] text-[15.69px] font-bold">{truncate(data.fields['First name (from Your name)'][0], 11)}</h2>
<hr className=' border-t-[1px]' style={{borderColor: '#876100'}} />
<p className="w-[117.66px] h-[8px] text-[14.12px]">{data.fields["Enter the domain that you will be working on."] ? truncate(data.fields["Enter the domain that you will be working on."],10) : 'Undefined' }</p>
<p className="w-[117.66px] h-[17px] text-[14.12px]" style={{color: '#876100'}}>{truncate(data.fields["What will you be doing at the space today?"],19)}</p>
<p className="w-[117.66px] h-[17px] text-[14.12px]" style={{color: '#876100'}}>{data.fields["What will you be doing at the space today?"] ? truncate(data.fields["What will you be doing at the space today?"],19) : 'Undefined'}</p>
</div>
</div>
</div>
Expand Down