Skip to content

Commit

Permalink
Append mailto to job contactInfo if email, order jobs and listings by…
Browse files Browse the repository at this point in the history
… id in reverse (#258)

* Append mailto: if contactInfo is an email

* Order jobs and listings by id in reverse

* Removed log
  • Loading branch information
namedotget authored Nov 25, 2024
1 parent 329bd6a commit 71efaad
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions ui/components/subscription/LatestJobs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function LatestJobs({
async function getLatestJobs() {
const now = Math.floor(Date.now() / 1000)
const tableName = await jobTableContract.call('getTableName')
const statement = `SELECT * FROM ${tableName} WHERE (endTime = 0 OR endTime >= ${now}) ORDER BY timestamp ASC LIMIT 25`
const statement = `SELECT * FROM ${tableName} WHERE (endTime = 0 OR endTime >= ${now}) ORDER BY id DESC LIMIT 25`
const latestJobsRes = await fetch(
`${TABLELAND_ENDPOINT}?statement=${statement}`
)
Expand All @@ -33,7 +33,7 @@ export default function LatestJobs({
])
return teamExpiration.toNumber() > now
})
setLatestJobs(validJobs.reverse())
setLatestJobs(validJobs)
}
if (teamContract && jobTableContract) {
getLatestJobs()
Expand Down
4 changes: 2 additions & 2 deletions ui/components/subscription/NewMarketplaceListings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function NewMarketplaceListings({
async function getNewMarketplaceListings() {
const now = Math.floor(Date.now() / 1000)
const tableName = await marketplaceTableContract.call('getTableName')
const statement = `SELECT * FROM ${tableName} WHERE (startTime = 0 OR startTime <= ${now}) AND (endTime = 0 OR endTime >= ${now}) ORDER BY timestamp ASC LIMIT 25`
const statement = `SELECT * FROM ${tableName} WHERE (startTime = 0 OR startTime <= ${now}) AND (endTime = 0 OR endTime >= ${now}) ORDER BY id DESC LIMIT 25`
const allListingsRes = await fetch(
`${TABLELAND_ENDPOINT}?statement=${statement}`
)
Expand All @@ -37,7 +37,7 @@ export default function NewMarketplaceListings({
return teamExpiration.toNumber() > now
}
)
setNewListings(validListings.reverse())
setNewListings(validListings)
}
if (teamContract && marketplaceTableContract) {
getNewMarketplaceListings()
Expand Down
15 changes: 13 additions & 2 deletions ui/components/subscription/TeamJobModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ export default function TeamJobModal({

const cleanedData = cleanData(jobData)

//Check if the contact info is an email and append mailto: if needed
let formattedContactInfo
if (
cleanedData.contactInfo.includes('@') &&
!cleanedData.contactInfo.startsWith('mailto:')
) {
formattedContactInfo = `mailto:${cleanedData.contactInfo}`
} else {
formattedContactInfo = cleanedData.contactInfo
}

try {
if (edit) {
await jobTableContract.call('updateTable', [
Expand All @@ -106,7 +117,7 @@ export default function TeamJobModal({
'',
endTime,
currTime,
cleanedData.contactInfo,
formattedContactInfo,
])
} else {
await jobTableContract?.call('insertIntoTable', [
Expand All @@ -117,7 +128,7 @@ export default function TeamJobModal({
'',
endTime,
currTime,
cleanedData.contactInfo,
formattedContactInfo,
])
}

Expand Down
2 changes: 1 addition & 1 deletion ui/pages/jobs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export async function getStaticProps() {

const jobBoardTableName = await jobTableContract.call('getTableName')

const statement = `SELECT * FROM ${jobBoardTableName} WHERE (endTime = 0 OR endTime >= ${now})`
const statement = `SELECT * FROM ${jobBoardTableName} WHERE (endTime = 0 OR endTime >= ${now}) ORDER BY id DESC`

const allJobsRes = await fetch(`${TABLELAND_ENDPOINT}?statement=${statement}`)
const allJobs = await allJobsRes.json()
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/marketplace/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export async function getStaticProps() {
'getTableName'
)

const statement = `SELECT * FROM ${marketplaceTableName} WHERE (startTime = 0 OR startTime <= ${now}) AND (endTime = 0 OR endTime >= ${now})`
const statement = `SELECT * FROM ${marketplaceTableName} WHERE (startTime = 0 OR startTime <= ${now}) AND (endTime = 0 OR endTime >= ${now}) ORDER BY id DESC`

const allListingsRes = await fetch(
`${TABLELAND_ENDPOINT}?statement=${statement}`
Expand Down

0 comments on commit 71efaad

Please sign in to comment.