Skip to content

Commit

Permalink
Admin server volledig doorgelopen
Browse files Browse the repository at this point in the history
  • Loading branch information
BartWtje committed Dec 22, 2023
1 parent 6416acf commit 7f600be
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 108 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
2 changes: 2 additions & 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,8 @@ export default function useArea(projectId?: string) {
},
body: JSON.stringify({ name: name, polygon: JSON.parse(polygon) }),
});
const data = await res.json();
return data;
}

return { ...areasSwr, createArea };
Expand Down
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,12 @@ 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`);
}
}

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
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
70 changes: 0 additions & 70 deletions apps/api-server/seeds/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,6 @@ module.exports = async function seed(config, db) {
summary: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque a sollicitudin velit, ac vehicula nibh.',
description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque a sollicitudin velit, ac vehicula nibh. Sed nec est convallis, interdum ex id, tempus mauris. Nulla facilisi. Quisque placerat condimentum est. Sed condimentum ex a orci dignissim ultrices. Nulla aliquam placerat ornare. Nulla condimentum, risus id commodo finibus, leo mauris tincidunt purus, non viverra augue ligula et sapien. Nunc pulvinar, eros at feugiat facilisis, quam tellus elementum metus, a sodales neque nibh non magna. Integer iaculis, nisl aliquet tempor hendrerit, lacus quam sollicitudin lectus, sed consectetur eros turpis sit amet nunc. Aenean eu neque at libero eleifend fringilla. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec quis posuere lacus, vitae eleifend magna. Nunc egestas sollicitudin ipsum, maximus tincidunt leo facilisis at. In rhoncus eget libero sit amet aliquam.',
images: [ { src: `${process.env.IMAGE_APP_URL}/image/zand.01.jpg`} ],
location: {
type: 'Point',
coordinates: [
52.3710476 + ( Math.random() * .03 - .015 ),
4.9005494 + ( Math.random() * .03 - .015 )
]
},
startDate: db.sequelize.fn('now'),
publishDate: db.sequelize.fn('now'),
});
Expand All @@ -172,13 +165,6 @@ module.exports = async function seed(config, db) {
summary: 'Etiam euismod odio ac augue blandit, quis ultricies ipsum ultrices. Nulla ornare odio et nisi.',
description: 'Etiam euismod odio ac augue blandit, quis ultricies ipsum ultrices. Nulla ornare odio et nisi tempor rhoncus. Maecenas et venenatis arcu. Proin efficitur neque sit amet enim suscipit laoreet. Mauris vehicula tristique lorem, eu imperdiet erat ornare eget. Quisque consectetur interdum tincidunt. Vestibulum ultricies arcu eleifend pharetra finibus. Fusce nec justo magna. Aliquam erat volutpat. Vivamus sollicitudin a sapien a auctor. Aenean id augue quis ex laoreet sodales.',
images: [ { src: `${process.env.IMAGE_APP_URL}/image/zand.02.jpg`} ],
location: {
type: 'Point',
coordinates: [
52.3710476 + ( Math.random() * .03 - .015 ),
4.9005494 + ( Math.random() * .03 - .015 )
]
},
startDate: db.sequelize.fn('now'),
publishDate: db.sequelize.fn('now'),
});
Expand All @@ -190,13 +176,6 @@ module.exports = async function seed(config, db) {
summary: 'Quisque et viverra nisi. Nullam augue sapien, feugiat finibus erat a, varius congue dolor. Integer.',
description: 'Quisque et viverra nisi. Nullam augue sapien, feugiat finibus erat a, varius congue dolor. Integer arcu urna, porta eget lacus a, imperdiet mattis ex. Curabitur eu urna eu nisl blandit scelerisque sed nec diam. Maecenas et sapien risus. Duis eget iaculis massa, et tempor tellus. Ut diam est, euismod in enim in, commodo rhoncus sapien.',
images: [ { src: `${process.env.IMAGE_APP_URL}/image/zand.03.jpg`} ],
location: {
type: 'Point',
coordinates: [
52.3710476 + ( Math.random() * .03 - .015 ),
4.9005494 + ( Math.random() * .03 - .015 )
]
},
startDate: db.sequelize.fn('now'),
publishDate: db.sequelize.fn('now'),
});
Expand All @@ -208,13 +187,6 @@ module.exports = async function seed(config, db) {
summary: 'Ut eu porttitor odio. Aliquam nec volutpat diam. Etiam eget tempor lacus, sed aliquet lectus.',
description: 'Ut eu porttitor odio. Aliquam nec volutpat diam. Etiam eget tempor lacus, sed aliquet lectus. Nullam sollicitudin urna ex, eget tempor leo ullamcorper non. Nullam dapibus et libero consequat euismod. Donec dui est, tempor ut lobortis ac, euismod quis nibh. In hac habitasse platea dictumst. Quisque malesuada ex mauris, ut aliquam lectus tristique id. Sed a ultrices arcu. Cras velit enim, euismod vel dictum eu, sodales eu tellus. In sit amet tristique purus, ac mollis turpis. Aliquam erat volutpat. Integer sit amet nisi tempus, maximus arcu a, venenatis urna.',
images: [ { src: `${process.env.IMAGE_APP_URL}/image/zand.04.jpg`} ],
location: {
type: 'Point',
coordinates: [
52.3710476 + ( Math.random() * .03 - .015 ),
4.9005494 + ( Math.random() * .03 - .015 )
]
},
startDate: db.sequelize.fn('now'),
publishDate: db.sequelize.fn('now'),
});
Expand All @@ -226,13 +198,6 @@ module.exports = async function seed(config, db) {
summary: 'Pellentesque consectetur eros at tempus viverra. In hac habitasse platea dictumst. Aenean egestas urna sapien.',
description: 'Pellentesque consectetur eros at tempus viverra. In hac habitasse platea dictumst. Aenean egestas urna sapien, porttitor pretium ante pharetra ut. Curabitur gravida ex sed felis vestibulum imperdiet. Pellentesque rutrum posuere tortor non placerat. Aliquam ornare massa id lacus vulputate, a rutrum sapien mattis. Proin purus nisl, lacinia in porttitor a, vulputate at diam. Sed fermentum augue in ipsum interdum, nec molestie diam placerat.',
images: [ { src: `${process.env.IMAGE_APP_URL}/image/zand.05.jpg`} ],
location: {
type: 'Point',
coordinates: [
52.3710476 + ( Math.random() * .03 - .015 ),
4.9005494 + ( Math.random() * .03 - .015 )
]
},
startDate: db.sequelize.fn('now'),
publishDate: db.sequelize.fn('now'),
});
Expand All @@ -244,13 +209,6 @@ module.exports = async function seed(config, db) {
summary: 'Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Fusce ornare.',
description: 'Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Fusce ornare felis id lacinia sodales. Vivamus augue ligula, ullamcorper ac volutpat non, scelerisque at neque. Nulla laoreet, sapien ac iaculis sodales, massa lacus auctor felis, consequat gravida lorem erat sed metus. Fusce lacus mauris, cursus id magna ullamcorper, lacinia eleifend mauris. Etiam scelerisque molestie dui congue eleifend. Phasellus a tortor nibh. Ut vestibulum ut risus at finibus.',
images: [ { src: `${process.env.IMAGE_APP_URL}/image/forum.romanum.01.jpg`} ],
location: {
type: 'Point',
coordinates: [
52.3710476 + ( Math.random() * .03 - .015 ),
4.9005494 + ( Math.random() * .03 - .015 )
]
},
startDate: db.sequelize.fn('now'),
publishDate: db.sequelize.fn('now'),
});
Expand All @@ -262,13 +220,6 @@ module.exports = async function seed(config, db) {
summary: 'Nulla laoreet pretium tortor at placerat. Sed in est vulputate, ullamcorper nisi id, elementum enim.',
description: 'Nulla laoreet pretium tortor at placerat. Sed in est vulputate, ullamcorper nisi id, elementum enim. Nulla ac nisl id nibh auctor ullamcorper. In suscipit porttitor mi at sodales. Pellentesque diam elit, ornare in aliquam eget, dictum a libero. Donec sagittis dictum elit sit amet varius. Maecenas eget mauris ultricies, ullamcorper nibh sit amet, luctus ex. Cras rhoncus dolor dolor, at porta ligula bibendum sit amet. Proin hendrerit efficitur tortor eget consectetur. Curabitur vitae dictum velit. Praesent scelerisque, dui quis elementum sodales, nisi erat porttitor quam, quis feugiat erat augue vehicula dui. Praesent ultrices suscipit tellus, sit amet consectetur enim accumsan ac. Suspendisse ac porta velit.',
images: [ { src: `${process.env.IMAGE_APP_URL}/image/forum.romanum.02.jpg`} ],
location: {
type: 'Point',
coordinates: [
52.3710476 + ( Math.random() * .03 - .015 ),
4.9005494 + ( Math.random() * .03 - .015 )
]
},
startDate: db.sequelize.fn('now'),
publishDate: db.sequelize.fn('now'),
});
Expand All @@ -280,13 +231,6 @@ module.exports = async function seed(config, db) {
summary: 'Aliquam ut magna eget ante tempor consectetur non nec nibh. Etiam id tellus eget turpis.',
description: 'Aliquam ut magna eget ante tempor consectetur non nec nibh. Etiam id tellus eget turpis porta egestas. Sed maximus sed nisi vel ornare. Aliquam erat volutpat. Phasellus lobortis nibh in convallis eleifend. Morbi nunc nisi, consequat nec odio a, efficitur congue ipsum. Donec nec leo id urna scelerisque rutrum. Donec pulvinar nunc nisl, at dignissim purus dapibus at. Phasellus pellentesque sem turpis, et facilisis nisl tempus at.',
images: [ { src: `${process.env.IMAGE_APP_URL}/image/forum.romanum.03.jpg`} ],
location: {
type: "Point",
coordinates: [
52.3710476 + ( Math.random() * .03 - .015 ),
4.9005494 + ( Math.random() * .03 - 015 )
]
},
startDate: db.sequelize.fn('now'),
publishDate: db.sequelize.fn('now'),
});
Expand All @@ -298,13 +242,6 @@ module.exports = async function seed(config, db) {
summary: 'Etiam ultricies dui non justo laoreet convallis. Aenean odio erat, molestie et odio in, imperdiet.',
description: 'Etiam ultricies dui non justo laoreet convallis. Aenean odio erat, molestie et odio in, imperdiet consectetur mauris. Pellentesque lobortis lacus sodales, volutpat turpis vel, posuere purus. Aliquam non elementum dolor. Ut vel dolor nec purus hendrerit molestie. Sed tortor erat, facilisis vitae orci sit amet, maximus viverra diam. Ut non sem mollis, facilisis libero id, sollicitudin felis. Donec at orci fermentum, pretium nunc a, dictum mauris. In tristique quis sapien sed faucibus. Quisque posuere purus tortor, quis gravida mauris cursus ac. Integer semper turpis quis magna consectetur, blandit placerat tellus lobortis. Morbi commodo sem iaculis nunc ornare, vel lobortis enim lacinia. Sed vitae lacus ex.',
images: [ { src: `${process.env.IMAGE_APP_URL}/image/forum.romanum.04.jpg`} ],
location: {
type: "Point",
coordinates: [
52.3710476 + ( Math.random() * .03 - .015 ),
4.9005494 + ( Math.random() * .03 - 015 )
]
},
startDate: db.sequelize.fn('now'),
publishDate: db.sequelize.fn('now'),
});
Expand All @@ -316,13 +253,6 @@ module.exports = async function seed(config, db) {
summary: 'Nullam dignissim tincidunt urna, non vehicula enim convallis vitae. Nulla enim nibh, semper et metus.',
description: 'Nullam dignissim tincidunt urna, non vehicula enim convallis vitae. Nulla enim nibh, semper et metus quis, venenatis eleifend nisi. Phasellus sed erat est. Donec ac lobortis turpis. Nulla facilisi. Pellentesque sit amet nisi id ante maximus consequat non sit amet nisl. Sed diam metus, malesuada ac aliquet in, pulvinar ac elit. Sed feugiat a dui sit amet luctus. Morbi sit amet dignissim neque, eget blandit lorem. Suspendisse ultrices mauris felis, in fermentum metus vestibulum a. Integer congue pharetra risus a interdum. Vivamus fringilla justo ac elementum tempor. Quisque ultrices fringilla lobortis. Aliquam ullamcorper ligula eu ipsum imperdiet vestibulum. Maecenas pretium, mi eget blandit tincidunt, justo lorem ornare lorem, in vulputate diam quam mollis ligula. Etiam viverra, nisl et laoreet tristique, dui sapien volutpat leo, in euismod diam dui nec orci. ',
images: [ { src: `${process.env.IMAGE_APP_URL}/image/forum.romanum.05.jpg`} ],
location: {
type: "Point",
coordinates: [
52.3710476 + ( Math.random() * .03 - .015 ),
4.9005494 + ( Math.random() * .03 - .015 )
]
},
startDate: db.sequelize.fn('now'),
publishDate: db.sequelize.fn('now'),
});
Expand Down

0 comments on commit 7f600be

Please sign in to comment.