Skip to content

Commit

Permalink
Merge pull request #105 from openstad/fix/minor-admin-server-fixes
Browse files Browse the repository at this point in the history
Admin server volledig doorgelopen
  • Loading branch information
BartWtje authored Jan 2, 2024
2 parents dbeff51 + ab045df commit 251fc25
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 211 deletions.
2 changes: 1 addition & 1 deletion apps/admin-server/src/components/resource-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const formSchema = z.object({
.optional(),
modBreakDate: z.date().optional(),

location: z.string(),
location: z.string().optional(),
images: z.string().array().default([]),

extraData: z
Expand Down
10 changes: 0 additions & 10 deletions apps/admin-server/src/components/ui/sidenav-project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,6 @@ export function SidenavProject({ className }: { className?: string }) {
<span className="truncate">Anonimiseer gebruikers</span>
</Button>
</Link>
<Link href={`/projects/${project}/settings/themes`}>
<Button
variant={
location.includes('/settings/themes') ? 'secondary' : 'ghost'
}
size="default"
className="w-full flex justify-start pl-8">
<span className="truncate">Themas en gebieden</span>
</Button>
</Link>
<Link href={`/projects/${project}/settings/notifications`}>
<Button
variant={
Expand Down
1 change: 1 addition & 0 deletions apps/admin-server/src/hooks/use-area.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default function useArea(projectId?: string) {
},
body: JSON.stringify({ name: name, polygon: JSON.parse(polygon) }),
});
return await res.json();
}

return { ...areasSwr, createArea };
Expand Down
11 changes: 9 additions & 2 deletions apps/admin-server/src/pages/projects/[project]/areas/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { Heading } from '@/components/ui/typography';
import { Separator } from '@/components/ui/separator';
import { useRouter } from 'next/router';
import useArea from '@/hooks/use-area';
import toast from 'react-hot-toast';

const formSchema = z.object({
name: z.string(),
Expand All @@ -37,8 +38,14 @@ export default function ProjectAreaCreate() {
defaultValues: {},
});

function onSubmit(values: z.infer<typeof formSchema>) {
createArea(values.name, values.polygon);
async function onSubmit(values: z.infer<typeof formSchema>) {
const area = await createArea(values.name, values.polygon);
if (area) {
toast.success('Gebied aangemaakt!');
router.push(`/projects/${projectId}/areas`);
} else {
toast.error('De polygoon die is meegegeven lijkt niet helemaal te kloppen.')
}
}

return (
Expand Down
10 changes: 6 additions & 4 deletions apps/admin-server/src/pages/projects/[project]/duplicate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@ export default function ProjectDuplicate() {
}
]}
>
<div className='container mx-auto py-10 w-1/2 float-left'>
<div className='container py-6'>
<div className='p-6 bg-white rounded-md'>
<Form {...form}>
<Heading size="xl" className="mb-4">
Instellingen • Algemeen
<Heading size="xl">
Dupliceren
</Heading>
<Separator className="mb-4" />
<Separator className="my-4" />
<form onSubmit={form.handleSubmit(duplicate)} className="space-y-4">
<p>Gebruik deze knop om de gegevens van je project te dupliceren.</p>
<p>Bij het dupliceren van je project zal er een compleet identieke versie van het project aangemaakt worden in de database.</p>
Expand All @@ -101,6 +102,7 @@ export default function ProjectDuplicate() {
<br/>
</Form>
</div>
</div>
</PageLayout>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,26 @@ const formSchema = z.object({
displayTheme: z.boolean(),
displayNeighbourhood: z.boolean(),
displayModbreak: z.boolean(),
image: z.string().optional(),
reactionSettings: z.array(z.string()).refine((value) => value.some((item) => item))
reactionSettings: z.string().array()
});

export default function ProjectSettingsResourceGeneral() {
const category = 'resources';

const { data, isLoading, updateProject } = useProject();
const defaults = () => ({
canAddNewResources: data?.config?.[category]?.canAddNewResources || null,
canAddNewResources: data?.config?.[category]?.canAddNewResources || false,
minimumYesVotes: data?.config?.[category]?.minimumYesVotes || null,
titleMinLength: data?.config?.[category]?.titleMinLength || null,
titleMaxLength: data?.config?.[category]?.titleMaxLength || null,
summaryMinLength: data?.config?.[category]?.summaryMinLength || null,
summaryMaxLength: data?.config?.[category]?.summaryMaxLength || null,
descriptionMinLength: data?.config?.[category]?.descriptionMinLength || null,
descriptionMaxLength: data?.config?.[category]?.descriptionMaxLength || null,
displayLocation: data?.config?.[category]?.displayLocation || null,
displayTheme: data?.config?.[category]?.displayTheme || null,
displayNeighbourhood: data?.config?.[category]?.displayNeighbourhood || null,
displayModbreak: data?.config?.[category]?.displayModbreak || null,
image: data?.config?.[category]?.image || null,
displayLocation: data?.config?.[category]?.displayLocation || false,
displayTheme: data?.config?.[category]?.displayTheme || false,
displayNeighbourhood: data?.config?.[category]?.displayNeighbourhood || false,
displayModbreak: data?.config?.[category]?.displayModbreak || false,
reactionSettings: data?.config?.[category]?.reactionSettings || [],
});

Expand All @@ -106,7 +104,6 @@ export default function ProjectSettingsResourceGeneral() {
summaryMaxLength: values.summaryMaxLength,
descriptionMinLength: values.descriptionMinLength,
descriptionMaxLength: values.descriptionMaxLength,
image: values.image,
displayLocation: values.displayLocation,
displayTheme: values.displayTheme,
displayNeighbourhood: values.displayNeighbourhood,
Expand Down Expand Up @@ -355,21 +352,6 @@ export default function ProjectSettingsResourceGeneral() {
</FormItem>
)}
/>
<FormField
control={form.control}
name="image"
render={({ field }) => (
<FormItem className="col-span-1">
<FormLabel>
Standaard afbeelding
</FormLabel>
<FormControl>
<Input type='file' {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="reactionSettings"
Expand Down
93 changes: 0 additions & 93 deletions apps/admin-server/src/pages/projects/[project]/settings/themes.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function ProjectSettingsVoting() {
const { project } = router.query;
const { data, isLoading, updateProject } = useProject();
const defaults = () => ({
isViewable: data?.config?.[category]?.isViewable || null,
isViewable: data?.config?.[category]?.isViewable || false,
isActive: data?.config?.[category]?.isActive || false,
withExisting: data?.config?.[category]?.withExisting || null,
requiredUserRole: data?.config?.[category]?.requiredUserRole || null,
Expand Down
6 changes: 0 additions & 6 deletions apps/admin-server/src/pages/projects/[project]/votes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ export default function ProjectResources() {
<Paragraph className="hidden lg:flex truncate lg:col-span-1 -mr-16">
{vote.userId}
</Paragraph>
<Paragraph className="flex">
<ChevronRight
strokeWidth={1.5}
className="w-5 h-5 my-auto ml-auto"
/>
</Paragraph>
</li>
))}
</ul>
Expand Down
Loading

0 comments on commit 251fc25

Please sign in to comment.