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

Append mailto to job contactInfo if email, order jobs and listings by id in reverse #258

Merged
merged 3 commits into from
Nov 25, 2024
Merged
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
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
4 changes: 3 additions & 1 deletion ui/pages/marketplace/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,15 @@ 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}`
)
const allListings = await allListingsRes.json()

console.log('allListings', allListings)
namedotget marked this conversation as resolved.
Show resolved Hide resolved

const validListings = allListings.filter(async (listing: TeamListingType) => {
const teamExpiration = await teamContract.call('expiresAt', [
listing.teamId,
Expand Down
Loading