Skip to content

Commit

Permalink
Merge branch 'main' into e-2413-languages
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoxAzrot committed Nov 14, 2024
2 parents b2a664c + b795aa2 commit b90d19c
Show file tree
Hide file tree
Showing 87 changed files with 950 additions and 361 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { AvatarLabelGroup } from "@/design-system/molecules/avatar-label-group";
import { SortDirection } from "@/design-system/molecules/table-sort";

import { TABLE_CELL_SIZE } from "@/shared/constants/table";
import { CellCategories } from "@/shared/features/table/cell/cell-categories/cell-categories";
import { CellEcosystems } from "@/shared/features/table/cell/cell-ecosystems/cell-ecosystems";
import { CellEmpty } from "@/shared/features/table/cell/cell-empty/cell-empty";
import { CellLanguages } from "@/shared/features/table/cell/cell-languages/cell-languages";
Expand Down Expand Up @@ -97,13 +98,9 @@ export function useFilterColumns() {
enableSorting: false,
header: () => <Translate token={"data:deepDive.contributorsTable.columns.categories"} />,
cell: info => {
const categories = info.getValue();
const categories = info.getValue() ?? [];

if (!categories?.length) {
return <CellEmpty />;
}

return <TableCellKpi>{categories.map(category => category.name).join(", ")}</TableCellKpi>;
return <CellCategories categories={categories} />;
},
}),
languages: columnHelper.accessor("languages", {
Expand All @@ -127,6 +124,7 @@ export function useFilterColumns() {
country: columnHelper.accessor("country", {
enableSorting: false,
size: TABLE_CELL_SIZE.SM,
minSize: TABLE_CELL_SIZE.SM,
header: () => <Translate token={"data:deepDive.contributorsTable.columns.country"} />,
cell: info => {
const country = info.getValue();
Expand Down Expand Up @@ -162,7 +160,8 @@ export function useFilterColumns() {
},
}),
contributionCount: columnHelper.accessor("contributionCount", {
size: TABLE_CELL_SIZE.SM,
size: TABLE_CELL_SIZE.MD,
minSize: TABLE_CELL_SIZE.MD,
header: () => <Translate token={"data:deepDive.contributorsTable.columns.contributionCount"} />,
cell: info => {
const { value, trend } = info.getValue() ?? {};
Expand All @@ -174,6 +173,7 @@ export function useFilterColumns() {
}),
prCount: columnHelper.accessor("prCount", {
size: TABLE_CELL_SIZE.SM,
minSize: TABLE_CELL_SIZE.SM,
header: () => <Translate token={"data:deepDive.contributorsTable.columns.prCount"} />,
cell: info => {
const { value, trend } = info.getValue() ?? {};
Expand All @@ -186,6 +186,7 @@ export function useFilterColumns() {
rewardCount: columnHelper.accessor("rewardCount", {
enableSorting: false,
size: TABLE_CELL_SIZE.SM,
minSize: TABLE_CELL_SIZE.SM,
header: () => <Translate token={"data:deepDive.contributorsTable.columns.rewardCount"} />,
cell: info => {
const { value, trend } = info.getValue() ?? {};
Expand All @@ -198,6 +199,7 @@ export function useFilterColumns() {
engagementStatus: columnHelper.accessor("engagementStatus", {
enableSorting: false,
size: TABLE_CELL_SIZE.MD,
minSize: TABLE_CELL_SIZE.MD,
header: () => <Translate token={"data:deepDive.contributorsTable.columns.engagementStatuses"} />,
cell: info => {
const engagementStatuses = info.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { AvatarLabelGroup } from "@/design-system/molecules/avatar-label-group";
import { SortDirection } from "@/design-system/molecules/table-sort";

import { TABLE_CELL_SIZE } from "@/shared/constants/table";
import { CellBadge } from "@/shared/features/table/cell/cell-badge/cell-badge";
import { CellBudget } from "@/shared/features/table/cell/cell-budget/cell-budget";
import { CellCategories } from "@/shared/features/table/cell/cell-categories/cell-categories";
import { CellEcosystems } from "@/shared/features/table/cell/cell-ecosystems/cell-ecosystems";
import { CellEmpty } from "@/shared/features/table/cell/cell-empty/cell-empty";
import { CellLanguages } from "@/shared/features/table/cell/cell-languages/cell-languages";
Expand Down Expand Up @@ -108,8 +108,9 @@ export function useFilterColumns() {
enableSorting: false,
header: () => <Translate token={"data:deepDive.projectsTable.columns.categories"} />,
cell: info => {
const categories = info.getValue();
return <CellBadge items={categories?.map(category => category.name)} />;
const categories = info.getValue() ?? [];

return <CellCategories categories={categories} />;
},
}),
languages: columnHelper.accessor("languages", {
Expand Down Expand Up @@ -149,6 +150,7 @@ export function useFilterColumns() {
}),
percentUsedBudget: columnHelper.accessor("percentUsedBudget", {
size: TABLE_CELL_SIZE.MD,
minSize: TABLE_CELL_SIZE.MD,
header: () => <Translate token={"data:deepDive.projectsTable.columns.percentUsedBudget"} />,
cell: info => {
const value = info.getValue();
Expand Down Expand Up @@ -195,7 +197,8 @@ export function useFilterColumns() {
},
}),
onboardedContributorCount: columnHelper.accessor("onboardedContributorCount", {
size: TABLE_CELL_SIZE.SM,
size: TABLE_CELL_SIZE.MD,
minSize: TABLE_CELL_SIZE.MD,
header: () => <Translate token={"data:deepDive.projectsTable.columns.onboardedContributorCount"} />,
cell: info => {
const { value, trend } = info.getValue() ?? {};
Expand All @@ -206,7 +209,8 @@ export function useFilterColumns() {
},
}),
activeContributorCount: columnHelper.accessor("activeContributorCount", {
size: TABLE_CELL_SIZE.SM,
size: TABLE_CELL_SIZE.MD,
minSize: TABLE_CELL_SIZE.MD,
header: () => <Translate token={"data:deepDive.projectsTable.columns.activeContributorCount"} />,
cell: info => {
const { value, trend } = info.getValue() ?? {};
Expand All @@ -218,6 +222,7 @@ export function useFilterColumns() {
}),
prCount: columnHelper.accessor("prCount", {
size: TABLE_CELL_SIZE.SM,
minSize: TABLE_CELL_SIZE.SM,
header: () => <Translate token={"data:deepDive.projectsTable.columns.prCount"} />,
cell: info => {
const { value, trend } = info.getValue() ?? {};
Expand All @@ -228,7 +233,8 @@ export function useFilterColumns() {
},
}),
rewardCount: columnHelper.accessor("rewardCount", {
size: TABLE_CELL_SIZE.SM,
size: TABLE_CELL_SIZE.MD,
minSize: TABLE_CELL_SIZE.MD,
header: () => <Translate token={"data:deepDive.projectsTable.columns.rewardCount"} />,
cell: info => {
const { value, trend } = info.getValue() ?? {};
Expand All @@ -239,7 +245,8 @@ export function useFilterColumns() {
},
}),
contributionCount: columnHelper.accessor("contributionCount", {
size: TABLE_CELL_SIZE.SM,
size: TABLE_CELL_SIZE.MD,
minSize: TABLE_CELL_SIZE.MD,
header: () => <Translate token={"data:deepDive.projectsTable.columns.contributionCount"} />,
cell: info => {
const { value, trend } = info.getValue() ?? {};
Expand All @@ -252,6 +259,7 @@ export function useFilterColumns() {
engagementStatus: columnHelper.accessor("engagementStatus", {
enableSorting: false,
size: TABLE_CELL_SIZE.MD,
minSize: TABLE_CELL_SIZE.MD,
header: () => <Translate token={"data:deepDive.projectsTable.columns.engagementStatuses"} />,
cell: info => {
const engagementStatuses = info.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export function ProgramsTable({ onAllocateClick }: ProgramsTableProps) {
columnHelper.accessor("projectCount", {
enableSorting: false,
size: TABLE_CELL_SIZE.SM,
minSize: TABLE_CELL_SIZE.SM,
header: () => <Translate token={"financials:details.programs.table.columns.projects"} />,
cell: info => {
return <TableCellKpi>{info.getValue()}</TableCellKpi>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export function useFilterColumns() {
id: "select",
enableResizing: false,
size: TABLE_CELL_SIZE.XS,
minSize: TABLE_CELL_SIZE.XS,
header: ({ table }) => (
<Checkbox
onNativeEventChange={table.getToggleAllRowsSelectedHandler()}
Expand Down Expand Up @@ -182,6 +183,7 @@ export function useFilterColumns() {
country: columnHelper.accessor("country", {
enableSorting: false,
size: TABLE_CELL_SIZE.SM,
minSize: TABLE_CELL_SIZE.SM,
header: () => <Translate token={"manageProjects:detail.contributorsTable.columns.country"} />,
cell: info => {
const country = info.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export function useFilterColumns({ projectId }: { projectId: string }) {
const columnMap: Partial<Record<TableColumns, object>> = {
requestedAt: columnHelper.accessor("requestedAt", {
size: TABLE_CELL_SIZE.SM,
minSize: TABLE_CELL_SIZE.SM,
header: () => <Translate token={"manageProjects:detail.rewardsTable.columns.date"} />,
cell: info => {
const requestedAt = info.getValue();
Expand All @@ -82,6 +83,7 @@ export function useFilterColumns({ projectId }: { projectId: string }) {
id: columnHelper.accessor("id", {
enableSorting: false,
size: TABLE_CELL_SIZE.SM,
minSize: TABLE_CELL_SIZE.SM,
header: () => <Translate token={"manageProjects:detail.rewardsTable.columns.id"} />,
cell: info => {
const id = info.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useEffect } from "react";
import { useLocalStorage } from "react-use";

import { bootstrap } from "@/core/bootstrap";
import { MeProjectListItemInterface } from "@/core/domain/me/models/me-projects-model";
import { MeMaintainerProjectsInterface } from "@/core/domain/me/models/me-maintainer-projects-model";

import { Button } from "@/design-system/atoms/button/variants/button-default";
import { TableCellKpi } from "@/design-system/atoms/table-cell-kpi";
Expand All @@ -20,7 +20,7 @@ import { TableColumns } from "./filter-columns.types";

export function useFilterColumns() {
const moneyKernelPort = bootstrap.getMoneyKernelPort();
const columnHelper = createColumnHelper<MeProjectListItemInterface>();
const columnHelper = createColumnHelper<MeMaintainerProjectsInterface>();

const [selectedIds, setSelectedIds] = useLocalStorage<Array<TableColumns>>("manage-projects-table-columns");

Expand Down Expand Up @@ -77,6 +77,7 @@ export function useFilterColumns() {
contributorCount: columnHelper.accessor("contributorCount", {
enableSorting: false,
size: TABLE_CELL_SIZE.SM,
minSize: TABLE_CELL_SIZE.SM,
header: () => <Translate token={"manageProjects:list.projectsTable.columns.members"} />,
cell: info => {
const contributorCount = info.getValue();
Expand Down Expand Up @@ -145,7 +146,7 @@ export function useFilterColumns() {
// Loop on object keys to keep column order
const columns = columnMapKeys
.map(key => (selectedIds?.includes(key) ? columnMap[key] : null))
.filter(Boolean) as ColumnDef<MeProjectListItemInterface>[];
.filter(Boolean) as ColumnDef<MeMaintainerProjectsInterface>[];

return { columns, selectedIds, setSelectedIds };
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function ProjectsTable() {
const router = useRouter();

const { data, isLoading, isError, hasNextPage, fetchNextPage, isFetchingNextPage } =
MeReactQueryAdapter.client.useGetMeProjects({});
MeReactQueryAdapter.client.useGetMyProjectsAsMaintainer({});
const projects = useMemo(() => data?.pages.flatMap(page => page.projects) ?? [], [data]);
const totalItemNumber = useMemo(() => data?.pages[0].totalItemNumber, [data]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ function Column({
onOpenContribution(id: string): void;
} & Partial<KanbanColumnProps>) {
const { githubUserId } = useAuthUser();
const applicantIds = githubUserId ? [githubUserId] : [];
const contributorIds = githubUserId ? [githubUserId] : [];
const ids = type == ContributionActivityStatus.NOT_ASSIGNED ? { applicantIds } : { contributorIds };
const statuses = [type];

const { data, hasNextPage, fetchNextPage, isPending, isFetchingNextPage } =
ContributionReactQueryAdapter.client.useGetContributions({
queryParams: {
...queryParams,
statuses: [type],
contributorIds: githubUserId ? [githubUserId] : [],
...ids,
statuses,
},
options: {
enabled: Boolean(githubUserId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export function useFilterColumns() {
const columnMap: Partial<Record<TableColumns, object>> = {
requestedAt: columnHelper.accessor("requestedAt", {
size: TABLE_CELL_SIZE.SM,
minSize: TABLE_CELL_SIZE.SM,
header: () => <Translate token={"myDashboard:detail.rewardsTable.columns.date"} />,
cell: info => {
const requestedAt = info.getValue();
Expand All @@ -73,6 +74,7 @@ export function useFilterColumns() {
id: columnHelper.accessor("id", {
enableSorting: false,
size: TABLE_CELL_SIZE.SM,
minSize: TABLE_CELL_SIZE.SM,
header: () => <Translate token={"myDashboard:detail.rewardsTable.columns.id"} />,
cell: info => {
const id = info.getValue();
Expand Down Expand Up @@ -126,12 +128,13 @@ export function useFilterColumns() {
header: () => <Translate token={"myDashboard:detail.rewardsTable.columns.status"} />,
cell: info => {
const status = info.getValue();
const billingProfileId = info.row.original.billingProfileId;

if (!status) {
return <CellEmpty />;
}

return <PayoutStatus status={status} />;
return <PayoutStatus status={status} billingProfileId={billingProfileId} shouldRedirect={true} />;
},
}),
} as const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export function ProjectsTable({ programId }: { programId: string }) {
columnHelper.accessor("percentUsedBudget", {
enableSorting: false,
size: TABLE_CELL_SIZE.MD,
minSize: TABLE_CELL_SIZE.MD,
header: () => <Translate token={"programs:details.projects.table.columns.budgetUsed"} />,
cell: info => {
const value = info.getValue() ?? 0;
Expand All @@ -168,7 +169,8 @@ export function ProjectsTable({ programId }: { programId: string }) {

columnHelper.accessor("mergedPrCount", {
enableSorting: false,
size: TABLE_CELL_SIZE.SM,
size: TABLE_CELL_SIZE.MD,
minSize: TABLE_CELL_SIZE.MD,
header: () => <Translate token={"programs:details.projects.table.columns.prsMerged"} />,
cell: info => {
const { value, trend } = info.getValue() ?? {};
Expand All @@ -179,7 +181,8 @@ export function ProjectsTable({ programId }: { programId: string }) {

columnHelper.accessor("newContributorsCount", {
enableSorting: false,
size: TABLE_CELL_SIZE.SM,
size: TABLE_CELL_SIZE.MD,
minSize: TABLE_CELL_SIZE.MD,
header: () => <Translate token={"programs:details.projects.table.columns.onboardedDevs"} />,
cell: info => {
const { value, trend } = info.getValue() ?? {};
Expand All @@ -189,7 +192,8 @@ export function ProjectsTable({ programId }: { programId: string }) {
}),
columnHelper.accessor("activeContributorsCount", {
enableSorting: false,
size: TABLE_CELL_SIZE.SM,
size: TABLE_CELL_SIZE.MD,
minSize: TABLE_CELL_SIZE.MD,
header: () => <Translate token={"programs:details.projects.table.columns.activeDevs"} />,
cell: info => {
const { value, trend } = info.getValue() ?? {};
Expand Down
1 change: 1 addition & 0 deletions app/programs/_features/programs-table/programs-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function ProgramsTable() {
columnHelper.accessor("projectCount", {
enableSorting: false,
size: TABLE_CELL_SIZE.SM,
minSize: TABLE_CELL_SIZE.SM,
header: () => <Translate token={"programs:list.content.table.columns.projects"} />,
cell: info => {
return <TableCellKpi>{info.getValue()}</TableCellKpi>;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { useQuery } from "@tanstack/react-query";

import {
UseQueryFacadeParams,
useQueryAdapter,
} from "@/core/application/react-query-adapter/helpers/use-query-adapter";
import { bootstrap } from "@/core/bootstrap";
import { GetBillingProfileInvoiceableRewardsModel } from "@/core/domain/billing-profile/billing-profile-contract.types";
import { BillingProfileFacadePort } from "@/core/domain/billing-profile/input/billing-profile-facade-port";

export function useGetBillingProfileInvoiceableRewards({
pathParams,
options,
}: UseQueryFacadeParams<
BillingProfileFacadePort["getBillingProfileInvoiceableRewards"],
GetBillingProfileInvoiceableRewardsModel
>) {
const billingProfileStoragePort = bootstrap.getBillingProfileStoragePortForClient();

return useQuery(
useQueryAdapter({
...billingProfileStoragePort.getBillingProfileInvoiceableRewards({ pathParams }),
options,
})
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useQuery } from "@tanstack/react-query";

import {
UseQueryFacadeParams,
useQueryAdapter,
} from "@/core/application/react-query-adapter/helpers/use-query-adapter";
import { bootstrap } from "@/core/bootstrap";
import { GetMeBillingProfilesModel } from "@/core/domain/billing-profile/billing-profile-contract.types";
import { BillingProfileFacadePort } from "@/core/domain/billing-profile/input/billing-profile-facade-port";

export function useGetMyBillingProfiles({
options,
}: UseQueryFacadeParams<BillingProfileFacadePort["getMyBillingProfiles"], GetMeBillingProfilesModel>) {
const billingProfileStoragePort = bootstrap.getBillingProfileStoragePortForClient();

return useQuery(
useQueryAdapter({
...billingProfileStoragePort.getMyBillingProfiles({}),
options,
})
);
}
3 changes: 2 additions & 1 deletion core/application/react-query-adapter/me/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export * from "./use-set-me";
export * from "./use-get-my-profile";
export * from "./use-set-my-profile";
export * from "./use-replace-my-profile";
export * from "./use-get-me-projects";
export * from "./use-get-my-projects-as-maintainer";
export * from "./use-get-my-projects-as-contributor";
Loading

0 comments on commit b90d19c

Please sign in to comment.