Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Habeebah157 committed Dec 11, 2024
2 parents 2f60fff + c6334f5 commit 4f3ed2f
Show file tree
Hide file tree
Showing 127 changed files with 912 additions and 122 deletions.
96 changes: 96 additions & 0 deletions apps/member-profile/app/routes/_profile.resources.$id_.delete.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import {
type ActionFunctionArgs,
json,
type LoaderFunctionArgs,
redirect,
} from '@remix-run/node';
import {
Form,
useActionData,
useLoaderData,
useSearchParams,
} from '@remix-run/react';

import { deleteResource } from '@oyster/core/resources/server';
import { db } from '@oyster/db';
import { Button, ErrorMessage, getErrors, Modal } from '@oyster/ui';

import { Route } from '@/shared/constants';
import {
commitSession,
ensureUserAuthenticated,
toast,
user,
} from '@/shared/session.server';

export async function loader({ params, request }: LoaderFunctionArgs) {
const session = await ensureUserAuthenticated(request);

const resource = await db
.selectFrom('resources')
.select(['title'])
.where('id', '=', params.id as string)
.where('postedBy', '=', user(session))
.executeTakeFirst();

if (!resource) {
throw new Response(null, {
status: 404,
statusText: 'The resource you are looking for does not exist.',
});
}

return json(resource);
}

export async function action({ params, request }: ActionFunctionArgs) {
const session = await ensureUserAuthenticated(request);

await deleteResource(params.id as string);

toast(session, {
message: 'Resource deleted successfully.',
});

const url = new URL(request.url);

url.pathname = Route['/resources'];

return redirect(url.toString(), {
headers: {
'Set-Cookie': await commitSession(session),
},
});
}

export default function DeleteResourceModal() {
const { title } = useLoaderData<typeof loader>();
const { error } = getErrors(useActionData<typeof action>());
const [searchParams] = useSearchParams();

return (
<Modal
onCloseTo={{
pathname: Route['/resources'],
search: searchParams.toString(),
}}
>
<Modal.Header>
<Modal.Title>Delete Resource</Modal.Title>
<Modal.CloseButton />
</Modal.Header>

<Modal.Description>
Are you sure you want to delete "{title}"? This action cannot be undone.
</Modal.Description>

<Form className="form" method="post">
<ErrorMessage>{error}</ErrorMessage>

<Button.Group>
<Button.Submit color="error">Delete</Button.Submit>
</Button.Group>
</Form>
</Modal>
);
}
15 changes: 14 additions & 1 deletion apps/member-profile/app/routes/_profile.resources.$id_.edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
} from '@remix-run/node';
import {
Form,
generatePath,
Link,
useActionData,
useLoaderData,
useSearchParams,
Expand All @@ -21,6 +23,7 @@ import {
Button,
Divider,
ErrorMessage,
getButtonCn,
getErrors,
Modal,
validateForm,
Expand All @@ -47,6 +50,7 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
const record = await getResource({
select: [
'resources.description',
'resources.id',
'resources.link',
'resources.title',
'resources.type',
Expand Down Expand Up @@ -170,8 +174,17 @@ export default function EditResourceModal() {

<ErrorMessage>{error}</ErrorMessage>

<Button.Group>
<Button.Group flexDirection="row-reverse" spacing="between">
<Button.Submit>Save</Button.Submit>

<Link
className={getButtonCn({ color: 'error', variant: 'secondary' })}
to={generatePath(Route['/resources/:id/delete'], {
id: resource.id,
})}
>
Delete
</Link>
</Button.Group>
</Form>
</Modal>
Expand Down
2 changes: 2 additions & 0 deletions apps/member-profile/app/routes/_profile.resources.add.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
ResourceDescriptionField,
ResourceLinkField,
ResourceProvider,
ResourceSearchConfirmationField,
ResourceTagsField,
ResourceTitleField,
ResourceTypeField,
Expand Down Expand Up @@ -121,6 +122,7 @@ export default function AddResourceModal() {

<Form className="form" method="post" encType="multipart/form-data">
<ResourceProvider>
<ResourceSearchConfirmationField name="confirmation" />
<ResourceTitleField error={errors.title} name={keys.title} />
<ResourceDescriptionField
error={errors.description}
Expand Down
2 changes: 1 addition & 1 deletion apps/member-profile/app/routes/_profile.resume.review.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
type ResumeFeedback,
reviewResume,
ReviewResumeInput,
} from '@oyster/core/resume-review';
} from '@oyster/core/resume-reviews';
import {
Button,
cx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function EthnicityMultiCombobox({
</MultiComboboxDisplay>

{!!countries.length && (
<ComboboxPopover>
<ComboboxPopover side="top">
<ul>
{countries.map((country) => {
const label = `${country.flagEmoji} ${country.demonym}`;
Expand Down
13 changes: 13 additions & 0 deletions apps/member-profile/app/shared/components/resource-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import React, {

import { ResourceType } from '@oyster/core/resources';
import {
Checkbox,
ComboboxPopover,
Field,
type FieldProps,
Expand Down Expand Up @@ -138,6 +139,18 @@ export function ResourceLinkField({
);
}

export function ResourceSearchConfirmationField({ name }: FieldProps<boolean>) {
return (
<Checkbox
label="I have searched for this resource and it does not exist."
id={name}
name={name}
required
value="1"
/>
);
}

export function ResourceTagsField({
defaultValue,
error,
Expand Down
1 change: 1 addition & 0 deletions apps/member-profile/app/shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const ROUTES = [
'/recap/:date/reviews',
'/resources',
'/resources/add',
'/resources/:id/delete',
'/resources/:id/edit',
'/resume/review',
'/resume-books/:id',
Expand Down
32 changes: 16 additions & 16 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
"./admin-dashboard/ui": "./src/admin-dashboard.ui.ts",
"./member-profile/server": "./src/member-profile.server.ts",
"./member-profile/ui": "./src/member-profile.ui.ts",
"./admins": "./src/modules/admin/admin.ts",
"./admins/types": "./src/modules/admin/admin.types.ts",
"./admins/ui": "./src/modules/admin/admin.ui.tsx",
"./applications": "./src/modules/application/application.ts",
"./applications/types": "./src/modules/application/application.types.ts",
"./applications/ui": "./src/modules/application/application.ui.tsx",
"./admins": "./src/modules/admins/admins.ts",
"./admins/types": "./src/modules/admins/admins.types.ts",
"./admins/ui": "./src/modules/admins/admins.ui.tsx",
"./applications": "./src/modules/applications/applications.ts",
"./applications/types": "./src/modules/applications/applications.types.ts",
"./applications/ui": "./src/modules/applications/applications.ui.tsx",
"./bull": "./src/infrastructure/bull.ts",
"./education": "./src/modules/education/education.ts",
"./education/types": "./src/modules/education/education.types.ts",
"./education/ui": "./src/modules/education/education.ui.tsx",
"./employment": "./src/modules/employment/index.ts",
"./employment/server": "./src/modules/employment/index.server.ts",
"./events": "./src/modules/event/event.ts",
"./events": "./src/modules/events/events.ts",
"./gamification": "./src/modules/gamification/gamification.ts",
"./gamification/types": "./src/modules/gamification/gamification.types.ts",
"./gamification/ui": "./src/modules/gamification/gamification.ui.tsx",
Expand All @@ -37,16 +37,16 @@
"./mixpanel": "./src/infrastructure/mixpanel.ts",
"./offers": "./src/modules/compensation/offers.ts",
"./offers/ui": "./src/modules/compensation/offers.ui.tsx",
"./opportunities": "./src/modules/opportunity.ts",
"./referrals": "./src/modules/referral/referral.ts",
"./referrals/ui": "./src/modules/referral/referral.ui.tsx",
"./opportunities": "./src/modules/opportunities.ts",
"./referrals": "./src/modules/referrals/referrals.ts",
"./referrals/ui": "./src/modules/referrals/referrals.ui.tsx",
"./remix": "./src/shared/utils/remix.ts",
"./resources": "./src/modules/resource/index.ts",
"./resources/server": "./src/modules/resource/index.server.ts",
"./resume-books": "./src/modules/resume-book/resume-book.ts",
"./resume-books/types": "./src/modules/resume-book/resume-book.types.ts",
"./resume-books/ui": "./src/modules/resume-book/resume-book.ui.tsx",
"./resume-review": "./src/modules/resume-review.ts",
"./resources": "./src/modules/resources/index.ts",
"./resources/server": "./src/modules/resources/index.server.ts",
"./resume-books": "./src/modules/resume-books/resume-books.ts",
"./resume-books/types": "./src/modules/resume-books/resume-books.types.ts",
"./resume-books/ui": "./src/modules/resume-books/resume-books.ui.tsx",
"./resume-reviews": "./src/modules/resume-reviews.ts",
"./s3": "./src/infrastructure/s3.ts",
"./slack": "./src/modules/slack/slack.ts",
"./slack/server": "./src/modules/slack/index.server.ts"
Expand Down
28 changes: 14 additions & 14 deletions packages/core/src/admin-dashboard.server.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
export { getGoogleAuthUri } from './modules/authentication/shared/oauth.utils';
export { sendOneTimeCode } from './modules/authentication/use-cases/send-one-time-code';
export { verifyOneTimeCode } from './modules/authentication/use-cases/verify-one-time-code';
export { getEvent } from './modules/event/queries/get-event';
export { listEvents } from './modules/event/queries/list-events';
export { addEventRecordingLink } from './modules/event/use-cases/add-event-recording-link';
export { createEvent } from './modules/event/use-cases/create-event';
export { getFeatureFlag } from './modules/feature-flag/queries/get-feature-flag';
export { listFeatureFlags } from './modules/feature-flag/queries/list-feature-flags';
export { createFeatureFlag } from './modules/feature-flag/use-cases/create-feature-flag';
export { deleteFeatureFlag } from './modules/feature-flag/use-cases/delete-feature-flag';
export { editFeatureFlag } from './modules/feature-flag/use-cases/edit-feature-flag';
export { addIcebreakerPrompt } from './modules/icebreaker/use-cases/add-icebreaker-prompt';
export { activateMember } from './modules/member/use-cases/activate-member';
export { updateMemberEmail } from './modules/member/use-cases/update-member-email';
export { addOnboardingSessionAttendees } from './modules/onboarding-session/use-cases/add-onboarding-session-attendees';
export { uploadOnboardingSession } from './modules/onboarding-session/use-cases/upload-onboarding-session';
export { getEvent } from './modules/events/queries/get-event';
export { listEvents } from './modules/events/queries/list-events';
export { addEventRecordingLink } from './modules/events/use-cases/add-event-recording-link';
export { createEvent } from './modules/events/use-cases/create-event';
export { getFeatureFlag } from './modules/feature-flags/queries/get-feature-flag';
export { listFeatureFlags } from './modules/feature-flags/queries/list-feature-flags';
export { createFeatureFlag } from './modules/feature-flags/use-cases/create-feature-flag';
export { deleteFeatureFlag } from './modules/feature-flags/use-cases/delete-feature-flag';
export { editFeatureFlag } from './modules/feature-flags/use-cases/edit-feature-flag';
export { addIcebreakerPrompt } from './modules/icebreakers/use-cases/add-icebreaker-prompt';
export { activateMember } from './modules/members/use-cases/activate-member';
export { updateMemberEmail } from './modules/members/use-cases/update-member-email';
export { addOnboardingSessionAttendees } from './modules/onboarding-sessions/use-cases/add-onboarding-session-attendees';
export { uploadOnboardingSession } from './modules/onboarding-sessions/use-cases/upload-onboarding-session';
export { parseCsv } from './shared/utils/csv';
8 changes: 4 additions & 4 deletions packages/core/src/admin-dashboard.ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export {
CreateSchoolInput,
EducationLevel,
} from './modules/education/education.types';
export { AddEventRecordingLinkInput } from './modules/event/event.types';
export { AddEventRecordingLinkInput } from './modules/events/events.types';
export {
CreateFeatureFlagInput,
EditFeatureFlagInput,
} from './modules/feature-flag/feature-flag.types';
export { AddIcebreakerPromptInput } from './modules/icebreaker/icebreaker.types';
export { OnboardingSession } from './modules/onboarding-session/onboarding-session.types';
} from './modules/feature-flags/feature-flags.types';
export { AddIcebreakerPromptInput } from './modules/icebreakers/icebreakers.types';
export { OnboardingSession } from './modules/onboarding-sessions/onboarding-sessions.types';
export { Environment, ListSearchParams } from './shared/types';
18 changes: 9 additions & 9 deletions packages/core/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ dayjs.extend(utc);
dayjs.extend(timezone);

import { airtableWorker } from './modules/airtable';
import { applicationWorker } from './modules/application/application';
import { applicationWorker } from './modules/applications/applications';
import { oneTimeCodeWorker } from './modules/authentication/one-time-code.worker';
import { offerWorker } from './modules/compensation/offers';
import { eventWorker } from './modules/event/event.worker';
import { eventWorker } from './modules/events/events.worker';
import { feedWorker } from './modules/feed';
import { gamificationWorker } from './modules/gamification/gamification';
import { mailchimpWorker } from './modules/mailchimp';
import { memberEmailWorker } from './modules/member/member-email.worker';
import { memberWorker } from './modules/member/member.worker';
import { profileWorker } from './modules/member/profile.worker';
import { notificationWorker } from './modules/notification/notification.worker';
import { onboardingSessionWorker } from './modules/onboarding-session/onboarding-session.worker';
import { opportunityWorker } from './modules/opportunity';
import { resumeReviewWorker } from './modules/resume-review';
import { memberEmailWorker } from './modules/members/member-emails.worker';
import { memberWorker } from './modules/members/members.worker';
import { profileWorker } from './modules/members/profile.worker';
import { notificationWorker } from './modules/notifications/notifications.worker';
import { onboardingSessionWorker } from './modules/onboarding-sessions/onboarding-sessions.worker';
import { opportunityWorker } from './modules/opportunities';
import { resumeReviewWorker } from './modules/resume-reviews';
import { slackWorker } from './modules/slack/slack.worker';
import { twilioWorker } from './modules/twilio/twilio.worker';

Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/infrastructure/bull.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
ActivityType,
CompletedActivity,
} from '@/modules/gamification/gamification.types';
import { OnboardingSession } from '@/modules/onboarding-session/onboarding-session.types';
import { OnboardingSession } from '@/modules/onboarding-sessions/onboarding-sessions.types';
import {
SlackChannel,
SlackMessage,
Expand Down Expand Up @@ -587,6 +587,10 @@ export const StudentBullJob = z.discriminatedUnion('name', [
studentId: Student.shape.id,
}),
}),
z.object({
name: z.literal('student.anniversary.email'),
data: z.object({}),
}),
z.object({
name: z.literal('student.birthdate.daily'),
data: z.object({}),
Expand Down
Loading

0 comments on commit 4f3ed2f

Please sign in to comment.