Skip to content

Commit

Permalink
chore: remove opportunity status filter 🧼 (#700)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiAbdou authored Jan 16, 2025
1 parent fe1236e commit af71536
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 60 deletions.
60 changes: 3 additions & 57 deletions apps/member-profile/app/routes/_profile.opportunities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import dayjs from 'dayjs';
import { sql } from 'kysely';
import { jsonBuildObject } from 'kysely/helpers/postgres';
import { Bookmark, Calendar, Circle, Tag, Zap } from 'react-feather';
import { Bookmark, Calendar, Tag, Zap } from 'react-feather';

import { track } from '@oyster/core/mixpanel';
import { db } from '@oyster/db';
Expand Down Expand Up @@ -179,14 +179,14 @@ async function listOpportunities(
searchParams: URLSearchParams,
{ limit, page, memberId }: ListOpportunitiesOptions
) {
const { bookmarked, company, since, status } =
Object.fromEntries(searchParams);
const { bookmarked, company, since } = Object.fromEntries(searchParams);

const tags = searchParams.getAll('tag');

const query = db
.selectFrom('opportunities')
.leftJoin('companies', 'companies.id', 'opportunities.companyId')
.where('opportunities.expiresAt', '>', new Date())
.$if(!!bookmarked, (qb) => {
return qb.where((eb) => {
return eb.exists(() => {
Expand Down Expand Up @@ -216,19 +216,6 @@ async function listOpportunities(

return qb.where('opportunities.createdAt', '>=', date);
})
.$if(!!status, (qb) => {
const regex = new RegExp(status as string, 'i');

if (regex.test('open')) {
return qb.where('opportunities.expiresAt', '>', new Date());
}

if (regex.test('expired')) {
return qb.where('opportunities.expiresAt', '<', new Date());
}

return qb;
})
.$if(!!tags.length, (qb) => {
return qb.where((eb) => {
const conditions = tags.map((tag) => {
Expand Down Expand Up @@ -346,7 +333,6 @@ export default function OpportunitiesPage() {
selectedCompany={appliedCompany}
/>
<DatePostedFilter />
<StatusFilter />
</div>

<ClearFiltersButton />
Expand Down Expand Up @@ -648,43 +634,3 @@ function DatePostedFilter() {
</FilterRoot>
);
}

function StatusFilter() {
const [searchParams] = useSearchParams();

const status = searchParams.get('status');

const options: FilterValue[] = [
{ color: 'orange-100', label: 'Open', value: 'open' },
{ color: 'red-100', label: 'Expired', value: 'expired' },
];

const selectedValues = options.filter((option) => {
return status === option.value;
});

return (
<FilterRoot>
<FilterButton icon={<Circle />} popover selectedValues={selectedValues}>
Status
</FilterButton>

<FilterPopover>
<ul>
{options.map((option) => {
return (
<FilterItem
checked={status === option.value}
color={option.color}
key={option.value}
label={option.label}
name="status"
value={option.value}
/>
);
})}
</ul>
</FilterPopover>
</FilterRoot>
);
}
2 changes: 0 additions & 2 deletions apps/member-profile/app/routes/_profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export default function ProfileLayout() {
/>
<Dashboard.NavigationLink
icon={<DollarSign />}
isNew
label="Offers"
pathname={Route['/offers']}
prefetch="intent"
Expand Down Expand Up @@ -117,7 +116,6 @@ export default function ProfileLayout() {
/>
<Dashboard.NavigationLink
icon={<MessageCircle />}
isNew
label="Ask AI"
pathname={Route['/ask-ai']}
prefetch="intent"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/modules/opportunities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ async function createOpportunity({
.values({
createdAt: new Date(),
description: 'N/A',
expiresAt: dayjs().add(3, 'months').toDate(),
expiresAt: dayjs().add(1, 'month').toDate(),
id: id(),
postedBy: slackMessage.studentId,
slackChannelId,
Expand Down

0 comments on commit af71536

Please sign in to comment.