Skip to content

Commit

Permalink
Merge branch 'main' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelfact committed Oct 24, 2024
2 parents 6114aaf + 32d45ae commit 3ab39c9
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 169 deletions.
20 changes: 0 additions & 20 deletions api-client/resources/me/fetch/update-my-application.ts

This file was deleted.

1 change: 0 additions & 1 deletion api-client/resources/me/mutations/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from "./use-update-my-committee-assignment-project";
export * from "./use-logout-user";
export * from "./use-post-my-application";
export * from "./use-update-my-application";
export * from "./use-delete-banner-by-id";
33 changes: 0 additions & 33 deletions api-client/resources/me/mutations/use-update-my-application.ts

This file was deleted.

3 changes: 0 additions & 3 deletions api-client/resources/me/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ export interface GetMyOnboardingResponse extends MyOnboardingResponse {}
export type PostProjectApplicationCreateRequest = components["schemas"]["ProjectApplicationCreateRequest"];
export type PostProjectApplicationCreateResponse = components["schemas"]["ProjectApplicationCreateResponse"];

export type ProjectApplicationUpdateRequest = components["schemas"]["ProjectApplicationUpdateRequest"];
export type ProjectApplicationUpdatePathParams = operations["updateProjectApplication"]["parameters"]["path"];

/* --------------------------------- My Banners -------------------------------- */

export type CloseBannerPathParams = operations["closeBanner"]["parameters"]["path"];
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,11 @@ export function ContributorDetails({ githubId, applicationId }: TContributorDeta
<Flex className="w-full flex-col gap-3">
<Typography
variant={"body-m-bold"}
translate={{ token: "v2.pages.project.details.applicationDetails.profile.motivations.motivation" }}
translate={{ token: "v2.pages.project.details.applicationDetails.profile.motivations.comment" }}
/>
<Paper size={"m"} container={"3"} border={"none"}>
<Typography variant="body-m" className="min-h-5 text-greyscale-200">
{application?.motivation}
</Typography>
</Paper>
</Flex>
<Flex className="w-full flex-col gap-3">
<Typography
variant={"body-m-bold"}
translate={{ token: "v2.pages.project.details.applicationDetails.profile.motivations.approach" }}
/>
<Paper size={"m"} container={"3"} border={"none"}>
<Typography variant="body-m" className="min-h-5 text-greyscale-200">
{application?.problemSolvingApproach}
{application?.githubComment}
</Typography>
</Paper>
</Flex>
Expand Down
4 changes: 2 additions & 2 deletions app/p/[slug]/components/apply-issue-card/apply-issue-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export function ApplyIssueCard({ container = "2", iconProps, titleProps, childre
return (
<Paper container={container} border={"none"} classNames={{ base: className }}>
<header className={"flex items-center gap-1 text-text-1"}>
<Icon {...iconProps} size={16} />
<Typo {...titleProps} size={"xs"} weight={"medium"} />
{iconProps ? <Icon {...iconProps} size={16} /> : null}
<Typo size={"xs"} weight={"medium"} {...titleProps} />
</header>
{children}
</Paper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { TIcon } from "components/layout/icon/icon.types";
export namespace TApplyIssueCard {
export interface Props extends PropsWithChildren {
container?: PaperPort<"article">["container"];
iconProps: TIcon.Props;
iconProps?: TIcon.Props;
titleProps: TypoPort<"span">;
className?: string;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
export const ApplyIssuesPrefillLabels = [
"Can I take this issue?",
"I'd love to work on this!",
"Can I be assigned to this?",
"Can I handle this task?",
"I'd like to take this issue.",
"Can I tackle this one?",
"Let me try this one!",
"May I pick this up?",
"I'd love to give this a go.",
"Can I work on this, please?",
"Is this issue still available?",
"Could I take a shot at this?",
"May I take care of this?",
"Can I jump on this task?",
"Let me handle this issue!",
"I'd be happy to do this.",
"Could I try solving this?",
"Can I contribute to this one?",
"Is it okay if I take this?",
"May I try my hand at this?",
"I’d like to resolve this.",
"Could I take on this issue?",
"Can I start working on this?",
"May I take this issue on?",
"I’d like to work on this.",
"Mind if I take this issue?",
"Could I grab this task?",
"I’m interested in this one.",
"Can I attempt this issue?",
"Would love to tackle this!",
"May I be assigned to this?",
"I'd like to handle this task.",
"Can I try solving this issue?",
"Mind if I try this one?",
"I’d like to help with this.",
"Can I take this from here?",
"Can I take care of this issue?",
"Could I be assigned to this?",
"May I handle this issue?",
"I’d love to work on this task.",
"Is it okay if I tackle this?",
"Could I take over this issue?",
];
61 changes: 16 additions & 45 deletions components/features/apply-issue-drawer/apply-issue-drawer.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { FetchError } from "src/api/query.type";
import { HttpStatusStrings } from "src/api/query.utils";
import useMutationAlert from "src/api/useMutationAlert";

import { ApplyIssuesPrefillLabels } from "components/features/apply-issue-drawer/apply-issue-drawer.constants";
import { TApplyIssueDrawer } from "components/features/apply-issue-drawer/apply-issue-drawer.types";
import { usePublicRepoScope } from "components/features/grant-permission/hooks/use-public-repo-scope";

Expand Down Expand Up @@ -43,15 +44,6 @@ export function useApplyIssueDrawer({ state }: Pick<TApplyIssueDrawer.Props, "st
projectId: currentProjectId ?? "",
});

const { mutateAsync: updateAsync, ...updateApplication } = meApiClient.mutations.useUpdateMyApplication(
{
pathParams: {
applicationId,
},
},
currentProjectId ?? ""
);

const { mutateAsync: deleteAsync, ...deleteApplication } = applicationsApiClient.mutations.useDeleteApplication(
{
pathParams: {
Expand All @@ -71,31 +63,17 @@ export function useApplyIssueDrawer({ state }: Pick<TApplyIssueDrawer.Props, "st
},
});

useMutationAlert({
mutation: updateApplication,
success: {
message: T("v2.features.projects.applyIssueDrawer.toaster.updateSuccess"),
},
error: {
default: true,
},
});

const form = useForm<TApplyIssueDrawer.form>({
resolver: zodResolver(TApplyIssueDrawer.validation),
defaultValues: {
motivations: application?.motivation ?? "",
problemSolvingApproach: application?.problemSolvingApproach ?? "",
githubComment: application?.githubComment ?? "",
},
});

useEffect(() => {
if (application) {
form.reset({
motivations: application.motivation ?? "",
problemSolvingApproach: application.problemSolvingApproach ?? "",
});
}
form.reset({
githubComment: application?.githubComment ?? "",
});
}, [application]);

async function getPermissionsOnError(err: FetchError) {
Expand All @@ -110,8 +88,7 @@ export function useApplyIssueDrawer({ state }: Pick<TApplyIssueDrawer.Props, "st
createAsync({
projectId: currentProjectId,
issueId,
motivation: values.motivations,
problemSolvingApproach: values.problemSolvingApproach,
githubComment: values.githubComment,
})
.then(() => {
setState(prevState => ({ ...prevState, isOpen: false }));
Expand All @@ -121,21 +98,10 @@ export function useApplyIssueDrawer({ state }: Pick<TApplyIssueDrawer.Props, "st
});
}

function handleUpdate(values: TApplyIssueDrawer.form) {
updateAsync({
motivation: values.motivations,
problemSolvingApproach: values.problemSolvingApproach,
function handleCancel(deleteComment: boolean) {
deleteAsync({
deleteGithubComment: deleteComment,
})
.then(() => {
setState(prevState => ({ ...prevState, isOpen: false }));
})
.catch(async (err: FetchError) => {
await getPermissionsOnError(err);
});
}

function handleCancel() {
deleteAsync({})
.then(() => {
setState(prevState => ({ ...prevState, isOpen: false }));
setTimeout(() => {
Expand All @@ -155,10 +121,8 @@ export function useApplyIssueDrawer({ state }: Pick<TApplyIssueDrawer.Props, "st
application,
getApplication,
createApplication,
updateApplication,
deleteApplication,
handleCreate,
handleUpdate,
handleCancel,
};
}
Expand All @@ -168,3 +132,10 @@ export function useApplyIssueDrawerState() {
isOpen: false,
});
}

export function useApplyIssuePrefillLabel() {
const arrayOfLabels = ApplyIssuesPrefillLabels;
const randomIndex = Math.floor(Math.random() * arrayOfLabels.length);

return arrayOfLabels[randomIndex];
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ export function ApplyIssueDrawerLoading() {
<SkeletonEl width={"auto"} height={84} className={"col-span-3"} variant={"rounded"} />
<SkeletonEl width={"auto"} height={84} className={"col-span-3"} variant={"rounded"} />

<SkeletonEl width={"auto"} height={84} className={"col-span-2"} variant={"rounded"} />
<SkeletonEl width={"auto"} height={84} className={"col-span-2"} variant={"rounded"} />
<SkeletonEl width={"auto"} height={84} className={"col-span-2"} variant={"rounded"} />

<SkeletonEl width={"auto"} height={300} className={"col-span-full"} variant={"rounded"} />
Expand Down
Loading

0 comments on commit 3ab39c9

Please sign in to comment.