Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
0fe3fbe
fix: make dropdown menus scrollable
imdeaconu Sep 6, 2024
4ca1a44
fix: truncate overflowing table columns
imdeaconu Sep 6, 2024
921aa13
Merge branch 'commitglobal:main' into main
imdeaconu Sep 6, 2024
e5a2869
Merge branch 'commitglobal:main' into main
imdeaconu Sep 6, 2024
7866a67
Merge branch 'commitglobal:main' into main
imdeaconu Sep 9, 2024
9ea6c42
Merge branch 'commitglobal:main' into main
imdeaconu Sep 10, 2024
1bd449d
Merge branch 'commitglobal:main' into main
imdeaconu Sep 11, 2024
c9874d1
Squashed commit of the following:
imdeaconu Sep 11, 2024
b7715f3
Merge branch 'commitglobal:main' into main
imdeaconu Sep 12, 2024
0facf65
Squashed commit of the following:
imdeaconu Sep 13, 2024
67f681d
chore: remove unused import
imdeaconu Sep 13, 2024
8d73252
chore: delete duplicated / unused classes
imdeaconu Sep 16, 2024
63b21b9
Merge branch 'commitglobal:main' into main
imdeaconu Sep 17, 2024
1892e6e
Merge branch 'commitglobal:main' into main
imdeaconu Sep 18, 2024
abb7c01
feature: add searching to MonitoringObserversTagFilter
imdeaconu Sep 19, 2024
9d0b8ae
Merge branch 'commitglobal:main' into main
imdeaconu Sep 20, 2024
c9fcd3e
chore: update config files
imdeaconu Sep 20, 2024
333ba49
Revert "[NGO Admin] Rewrite the tag selector component (#675)"
imdeaconu Sep 23, 2024
580b68e
Merge branch 'main' of https://github.com/commitglobal/votemonitor
imdeaconu Sep 23, 2024
ba2dad9
Merge branch 'commitglobal:main' into main
imdeaconu Sep 25, 2024
eea4faa
Merge branch 'main' of https://github.com/commitglobal/votemonitor in…
imdeaconu Sep 26, 2024
29b8163
Merge branch 'main' of https://github.com/commitglobal/votemonitor in…
imdeaconu Sep 26, 2024
68a44ee
Merge branch 'commitglobal-main'
imdeaconu Sep 26, 2024
7cf3244
Merge branch 'main' of https://github.com/commitglobal/votemonitor in…
imdeaconu Oct 1, 2024
b6abee7
Merge branch 'commitglobal-main-s1'
imdeaconu Oct 1, 2024
cc71856
Merge branch 'commitglobal:main' into main
imdeaconu Oct 2, 2024
e45ea22
Merge branch 'commitglobal:main' into main
imdeaconu Oct 2, 2024
50d15b6
Merge branch 'commitglobal:main' into main
imdeaconu Oct 2, 2024
1ed8e99
Merge branch 'commitglobal:main' into main
imdeaconu Oct 3, 2024
c2f1395
Merge branch 'commitglobal:main' into main
imdeaconu Oct 7, 2024
2c6d5f0
Merge branch 'commitglobal:main' into main
imdeaconu Oct 9, 2024
8c8e18f
Merge branch 'commitglobal:main' into main
imdeaconu Oct 9, 2024
db46a6d
Merge branch 'commitglobal:main' into main
imdeaconu Oct 10, 2024
d4b0263
Merge branch 'commitglobal:main' into main
imdeaconu Oct 12, 2024
79864cd
Merge branch 'commitglobal:main' into main
imdeaconu Oct 14, 2024
5ae7edf
Merge branch 'commitglobal:main' into main
imdeaconu Oct 15, 2024
c0fe98a
Merge branch 'commitglobal:main' into main
imdeaconu Oct 17, 2024
b7b3c5c
Merge branch 'commitglobal:main' into main
imdeaconu Oct 18, 2024
a892349
Merge branch 'commitglobal:main' into main
imdeaconu Oct 19, 2024
2d98793
Merge branch 'commitglobal:main' into main
imdeaconu Oct 20, 2024
66ba8d0
Merge branch 'commitglobal:main' into main
imdeaconu Oct 21, 2024
a86608d
Merge branch 'commitglobal:main' into main
imdeaconu Oct 22, 2024
aa1745c
Merge branch 'commitglobal:main' into main
imdeaconu Oct 23, 2024
9942029
Merge branch 'commitglobal:main' into main
imdeaconu Oct 23, 2024
d855c24
Merge branch 'commitglobal:main' into main
imdeaconu Oct 25, 2024
5a2b99d
Merge branch 'commitglobal:main' into main
imdeaconu Oct 28, 2024
e9ea9a3
Merge branch 'commitglobal:main' into main
imdeaconu Oct 29, 2024
fdaba4b
Merge branch 'commitglobal:main' into main
imdeaconu Oct 29, 2024
777ab43
Merge branch 'commitglobal:main' into main
imdeaconu Nov 4, 2024
15101d6
Merge branch 'commitglobal:main' into main
imdeaconu Nov 6, 2024
9289b11
Merge branch 'commitglobal:main' into main
imdeaconu Nov 28, 2024
a82ea16
Merge branch 'commitglobal:main' into main
imdeaconu Nov 30, 2024
914fc58
Merge branch 'commitglobal:main' into main
imdeaconu Dec 10, 2024
b696453
WIP: add search and filtering to NGO list
imdeaconu Jan 18, 2025
e274f04
WIP: add views for NGO Details
imdeaconu Jan 19, 2025
ee6150e
WIP: add NGO activation / deactivation
imdeaconu Jan 20, 2025
b3b613b
WIP: implement NGO delete
imdeaconu Jan 20, 2025
a23346e
WIP: add NGO create modal
imdeaconu Jan 21, 2025
9cfc757
WIP: add modal for adding admins to NGOs
imdeaconu Jan 22, 2025
23b9c03
WIP: add CRUD for NGO admins
imdeaconu Jan 22, 2025
59b797f
WIP: add ngo admin details view
imdeaconu Jan 23, 2025
14ee4a1
WIP: fix back buttons
imdeaconu Jan 24, 2025
a285659
WIP: fix breadcrumbs
imdeaconu Jan 27, 2025
a6f1112
WIP: fix undefined ngo name in breadcrumbs
imdeaconu Jan 27, 2025
a967107
Merge branch 'commitglobal:main' into implement-super-admin-for-ngos
imdeaconu Jan 27, 2025
09adafe
WIP: add form for editing NGO admins
imdeaconu Jan 27, 2025
9b52974
Merge branch 'implement-super-admin-for-ngos' of https://github.com/i…
imdeaconu Jan 27, 2025
8c2a06d
Merge branch 'commitglobal:main' into implement-super-admin-for-ngos
imdeaconu Jan 27, 2025
23e2608
WIPȘ fix NGO name disappearing from breadcrumbs
imdeaconu Jan 28, 2025
0c5206e
WIP: add new NGO data to table and details view
imdeaconu Jan 28, 2025
802ba2f
WIP: add password field for admin creation
imdeaconu Jan 28, 2025
24d24b0
WIP: move admin queries to a separate hook
imdeaconu Jan 29, 2025
36322f7
Merge branch 'commitglobal:main' into implement-super-admin-for-ngos
imdeaconu Jan 29, 2025
a849a00
WIP: refactor NGOs query logic
imdeaconu Jan 29, 2025
7ac49e9
WIP: refactor debounced search & query params handling
imdeaconu Jan 30, 2025
45831fb
WIP: add NGO editing
imdeaconu Jan 30, 2025
7396f91
WIP: create Base zod search schemas for search params
imdeaconu Jan 30, 2025
3e1a759
WIP: remove console.log
imdeaconu Jan 31, 2025
858f0f7
WIP: remove incomplete subtitle
imdeaconu Jan 31, 2025
b81b39b
Merge branch 'commitglobal:main' into implement-super-admin-for-ngos
imdeaconu Feb 10, 2025
6c1a7c7
Merge remote-tracking branch 'upstream/main' into implement-super-adm…
imdeaconu Feb 18, 2025
c1b713e
fix missing imports
imdeaconu Feb 18, 2025
7cb2191
WIP: remove ID column and rename ngo queries file
imdeaconu Feb 18, 2025
8dfe47d
WIP: remove zod schema extension
imdeaconu Feb 18, 2025
688592d
WIP: change auth check for NGO routes to PlatformAdmin
imdeaconu Feb 18, 2025
ad9b8c2
WIP: remove div wrapper
imdeaconu Feb 18, 2025
cd1cba9
WIP: remove URL generator function
imdeaconu Feb 18, 2025
260ee1f
WIP: remove NGO admin from NGO creation
imdeaconu Feb 18, 2025
e794258
WIP: remove translation strings
imdeaconu Feb 18, 2025
833f3bd
WIP: remove unused var
imdeaconu Feb 18, 2025
75d08cc
fix build
imdeaconu Feb 18, 2025
f6dc67a
bugfixes, improvements and cleanup
idormenco Feb 20, 2025
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
6 changes: 3 additions & 3 deletions api/src/Vote.Monitor.Api.Feature.Ngo/Create/Endpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Vote.Monitor.Api.Feature.Ngo.Create;

public class Endpoint(IRepository<NgoAggregate> repository) :
Endpoint<Request, Results<Ok<NgoModel>, Conflict<ProblemDetails>>>
Endpoint<Request, Results<Ok<NgoModel>, ProblemDetails>>
{
public override void Configure()
{
Expand All @@ -14,7 +14,7 @@ public override void Configure()
Policies(PolicyNames.PlatformAdminsOnly);
}

public override async Task<Results<Ok<NgoModel>, Conflict<ProblemDetails>>> ExecuteAsync(Request req,
public override async Task<Results<Ok<NgoModel>, ProblemDetails>> ExecuteAsync(Request req,
CancellationToken ct)
{
var specification = new GetNgoByNameSpecification(req.Name);
Expand All @@ -23,7 +23,7 @@ public override async Task<Results<Ok<NgoModel>, Conflict<ProblemDetails>>> Exec
if (hasNgoWithSameName)
{
AddError(r => r.Name, "A Ngo with same name already exists");
return TypedResults.Conflict(new ProblemDetails(ValidationFailures));
return new ProblemDetails(ValidationFailures);
}

var ngo = new NgoAggregate(req.Name);
Expand Down
10 changes: 5 additions & 5 deletions api/src/Vote.Monitor.Api.Feature.NgoAdmin/Create/Endpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Vote.Monitor.Api.Feature.NgoAdmin.Create;
public class Endpoint(
UserManager<ApplicationUser> userManager,
IRepository<NgoAdminAggregate> repository)
: Endpoint<Request, Results<Ok<NgoAdminModel>, Conflict<ProblemDetails>>>
: Endpoint<Request, Results<Ok<NgoAdminModel>, ProblemDetails>>
{
public override void Configure()
{
Expand All @@ -18,14 +18,14 @@ public override void Configure()
Policies(PolicyNames.PlatformAdminsOnly);
}

public override async Task<Results<Ok<NgoAdminModel>, Conflict<ProblemDetails>>> ExecuteAsync(Request req,
public override async Task<Results<Ok<NgoAdminModel>, ProblemDetails>> ExecuteAsync(Request req,
CancellationToken ct)
{
var user = await userManager.FindByEmailAsync(req.Email);
if (user is not null)
{
AddError(r => r.Email, "A ngo admin with same login already exists");
return TypedResults.Conflict(new ProblemDetails(ValidationFailures));
AddError(r => r.Email, "A user with same login already exists");
return new ProblemDetails(ValidationFailures);
}

var applicationUser =
Expand All @@ -35,7 +35,7 @@ public override async Task<Results<Ok<NgoAdminModel>, Conflict<ProblemDetails>>>
if (!result.Succeeded)
{
AddError(r => r.Email, result.GetAllErrors());
return TypedResults.Conflict(new ProblemDetails(ValidationFailures));
return new ProblemDetails(ValidationFailures);
}

var ngoAdmin = new NgoAdminAggregate(req.NgoId, applicationUser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public override async Task<Results<NoContent, NotFound, ValidationProblem>> Exec
}

ngoAdmin.ApplicationUser.UpdateDetails(req.FirstName, req.LastName, req.PhoneNumber);
ngoAdmin.ApplicationUser.UpdateStatus(req.Status);
var result = await userManager.UpdateAsync(ngoAdmin.ApplicationUser);

if (!result.Succeeded)
Expand Down
2 changes: 0 additions & 2 deletions api/src/Vote.Monitor.Api.Feature.NgoAdmin/Update/Request.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ public class Request
public string FirstName { get; set; }
public string LastName { get; set; }
public string? PhoneNumber { get; set; }

public UserStatus Status { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ await repository
.AddAsync(Arg.Is<NgoAggregate>(x => x.Name == ngoName));

result
.Should().BeOfType<Results<Ok<NgoModel>, Conflict<ProblemDetails>>>()!
.Should().BeOfType<Results<Ok<NgoModel>, ProblemDetails>>()!
.Which!
.Result.Should().BeOfType<Ok<NgoModel>>()!
.Which!.Value!.Name.Should().Be(ngoName);
Expand All @@ -53,8 +53,8 @@ public async Task ShouldReturnConflict_WhenNgoWithSameNameExists()

// Assert
result
.Should().BeOfType<Results<Ok<NgoModel>, Conflict<ProblemDetails>>>()
.Should().BeOfType<Results<Ok<NgoModel>, ProblemDetails>>()
.Which
.Result.Should().BeOfType<Conflict<ProblemDetails>>();
.Result.Should().BeOfType<ProblemDetails>();
}
}
9 changes: 9 additions & 0 deletions web/src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,3 +410,12 @@ export interface FormBase {
numberOfQuestions: number;
languagesTranslationStatus: LanguagesTranslationStatus;
}

export interface ProblemDetails {
type: string;
title: string;
status: number;
detail: string;
instance?: string;
errors?: { name: string; reason: string }[]; // Maps field names to error messages
}
15 changes: 15 additions & 0 deletions web/src/common/zod-schemas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { z } from 'zod';
import { SortOrder } from './types';

export const PageParametersBaseSchema = z.object({
pageNumber: z.number().catch(1),
pageSize: z.number().catch(10),
});

export const SortParamsBaseSchema = z.object({
sortColumnName: z.string().catch(''),
searchText: z.coerce.string().optional(),
sortOrder: z.nativeEnum(SortOrder).catch(SortOrder.asc),
});

export const DefaultSearchParamsSchema = PageParametersBaseSchema.merge(SortParamsBaseSchema);
19 changes: 7 additions & 12 deletions web/src/components/layout/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,10 @@ const Header = (): FunctionComponent => {
const navigate = useNavigate();
const [selectedElectionRound, setSelectedElection] = useState<ElectionEvent>();
const router = useRouter();
const {
setCurrentElectionRoundId,
currentElectionRoundId,
} = useCurrentElectionRoundStore((s) => s);
const { setCurrentElectionRoundId, currentElectionRoundId } = useCurrentElectionRoundStore((s) => s);

const handleSelectElectionRound = async (electionRound?: ElectionEvent): Promise<void> => {
if (electionRound && selectedElectionRound?.id != electionRound.id ) {
if (electionRound && selectedElectionRound?.id != electionRound.id) {
setSelectedElection(electionRound);
setCurrentElectionRoundId(electionRound.id);

Expand Down Expand Up @@ -149,7 +146,9 @@ const Header = (): FunctionComponent => {
</div>

<div className='items-center hidden gap-2 md:flex'>
{userRole !== 'NgoAdmin'? <></> : status === 'pending' ? (
{userRole !== 'NgoAdmin' ? (
<></>
) : status === 'pending' ? (
<Skeleton className='w-[360px] h-[26px] mr-2 rounded-lg bg-secondary-300 text-secondary-900 hover:bg-secondary-300/90' />
) : (
<DropdownMenu>
Expand All @@ -173,9 +172,7 @@ const Header = (): FunctionComponent => {
<DropdownMenuLabel> Upcomming elections </DropdownMenuLabel>

{activeElections?.map((electionRound) => (
<DropdownMenuRadioItem
key={electionRound.id}
value={electionRound.id}>
<DropdownMenuRadioItem key={electionRound.id} value={electionRound.id}>
<div className='flex items-center gap-2'>
{electionRound?.status === ElectionRoundStatus.NotStarted ? (
<PauseCircleIcon className='w-4 h-4 text-slate-700' />
Expand All @@ -192,9 +189,7 @@ const Header = (): FunctionComponent => {
<DropdownMenuSeparator />
<DropdownMenuLabel> Archived elections </DropdownMenuLabel>
{archivedElections?.map((electionRound) => (
<DropdownMenuRadioItem
key={electionRound.id}
value={electionRound.id}>
<DropdownMenuRadioItem key={electionRound.id} value={electionRound.id}>
<div className='flex items-center gap-2'>
<StopCircleIcon className='w-4 h-4 text-yellow-700' />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function CitizenNotificationMessageForm(): FunctionComponent {

const form = useForm<z.infer<typeof createPushMessageSchema>>({
resolver: zodResolver(createPushMessageSchema),
mode: 'all',
defaultValues: {
title: '',
messageBody: '',
Expand Down
1 change: 1 addition & 0 deletions web/src/features/auth/AcceptInvite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function AcceptInvite() {

const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
mode: 'all',
defaultValues: {
password: '',
confirmPassword: '',
Expand Down
1 change: 1 addition & 0 deletions web/src/features/auth/ForgotPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface ForgotPasswordRequest {
function ForgotPassword() {
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
mode: 'all',
defaultValues: {
email: '',
},
Expand Down
1 change: 1 addition & 0 deletions web/src/features/auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function Login() {
const navigate = useNavigate();
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
mode: 'all',
defaultValues: {
email: '',
password: '',
Expand Down
1 change: 1 addition & 0 deletions web/src/features/auth/ResetPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function ResetPassword(): FunctionComponent {

const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
mode: 'all',
defaultValues: {
email: '',
password: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export default function AddGuideForm({

const form = useForm<NewGuideType>({
resolver: zodResolver(newGuideFormSchema),
mode: 'all',
defaultValues: {
guideType: guideType,
title: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export default function EditGuideForm({
type EditGuideType = z.infer<typeof editGuideFormSchema>;
const form = useForm<EditGuideType>({
resolver: zodResolver(editGuideFormSchema),
mode: 'all',
defaultValues: {
guidePageType: guidePageType,
guideType: guideType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function ElectionRoundForm({ electionRound, children, onSubmit }: ElectionRoundF

const form = useForm<ElectionRoundRequest>({
resolver: zodResolver(electionRoundSchema),
mode: 'all',
defaultValues: {
countryId: electionRound?.countryId ?? '',
title: electionRound?.title ?? '',
Expand Down
20 changes: 18 additions & 2 deletions web/src/features/filtering/hooks/useFilteringContainer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useSetPrevSearch } from '@/common/prev-search-store';
import { useNavigate, useSearch } from '@tanstack/react-router';
import { useCallback, useMemo } from 'react';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { HIDDEN_FILTERS } from '../common';
import { FILTER_KEY } from '../filtering-enums';

Expand All @@ -19,6 +19,12 @@ export function useFilteringContainer() {
.some(([_, value]) => !!value);
}, [queryParams]);

const [isFilteringContainerVisible, setIsFilteringContainerVisible] = useState(filteringIsActive);

useEffect(() => {
setIsFilteringContainerVisible(filteringIsActive);
}, [filteringIsActive]);

const navigateHandler = useCallback(
(search: Record<string, any | undefined>) => {
navigate({
Expand All @@ -37,6 +43,8 @@ export function useFilteringContainer() {
[navigate, setPrevSearch]
);

const toggleFilteringContainerVisibility = () => setIsFilteringContainerVisible((prev) => !prev);

const resetFilters = () => {
navigate({
to: '.',
Expand All @@ -46,5 +54,13 @@ export function useFilteringContainer() {
setPrevSearch(filterObject(queryParams, HIDDEN_FILTERS));
};

return { queryParams, filteringIsActive, navigate, navigateHandler, resetFilters };
return {
queryParams,
filteringIsActive,
isFilteringContainerVisible,
toggleFilteringContainerVisibility,
navigate,
navigateHandler,
resetFilters,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default function EditObserver() {

const form = useForm<z.infer<typeof editObserverFormSchema>>({
resolver: zodResolver(editObserverFormSchema),
mode: 'all',
defaultValues: {
status: monitoringObserver.status,
tags: monitoringObserver.tags,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function CreateMonitoringObserverDialog({ open, onOpenChange }: CreateMonitoring
type ObserverFormData = z.infer<typeof newObserverSchema>;

const form = useForm<ObserverFormData>({
mode: 'all',
resolver: zodResolver(newObserverSchema),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ function PushMessageForm(): FunctionComponent {

const form = useForm<z.infer<typeof createPushMessageSchema>>({
resolver: zodResolver(createPushMessageSchema),
mode: 'all',
defaultValues: {
title: '',
messageBody: '',
Expand Down
Loading