Skip to content

Commit

Permalink
🐛 bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 committed Nov 11, 2021
1 parent e161add commit 8c045fa
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion packages/api/src/controllers/admin/manage/Businesses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { prisma } from "../../../lib/prisma";
import { IsAuth } from "../../../middlewares";

@UseBeforeEach(IsAuth)
@Controller("/businesses-admin")
@Controller("/admin/manage/businesses")
export class ManageBusinessesController {
@Get("/")
async getBusinesses() {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/controllers/admin/manage/CadSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { UseBefore } from "@tsed/common";
import { Socket } from "../../../services/SocketService";
import { nanoid } from "nanoid";

@Controller("/cad-settings")
@Controller("/admin/manage/cad-settings")
export class ManageCitizensController {
private socket: Socket;
constructor(socket: Socket) {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/controllers/admin/manage/Citizens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { prisma } from "../../../lib/prisma";
import { IsAuth } from "../../../middlewares";

@UseBeforeEach(IsAuth)
@Controller("/citizens")
@Controller("/admin/manage/citizens")
export class ManageCitizensController {
@Get("/")
async getCitizens() {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/controllers/admin/manage/Units.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { IsAuth } from "../../../middlewares";
const include = unitProperties;

@UseBeforeEach(IsAuth)
@Controller("/units")
@Controller("/admin/manage/units")
export class ManageUnitsController {
@Get("/")
async getUnits() {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/controllers/admin/manage/Users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { nanoid } from "nanoid";
import { genSaltSync, hashSync } from "bcrypt";

@UseBeforeEach(IsAuth)
@Controller("/users")
@Controller("/admin/manage/users")
export class ManageUsersController {
private socket: Socket;
constructor(socket: Socket) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { prisma } from "../../lib/prisma";
import { EmployeeAsEnum, MiscCadSettings, WhitelistStatus } from ".prisma/client";

@UseBeforeEach(IsAuth)
@Controller("/")
@Controller("/businesses")
export class BusinessController {
@Get("/")
async getBusinessesByUser(@Context() ctx: Context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { prisma } from "../../lib/prisma";
import { EmployeeAsEnum, WhitelistStatus } from ".prisma/client";

@UseBeforeEach(IsAuth)
@Controller("/employees")
@Controller("/businesses/employees")
export class BusinessEmployeeController {
@Put("/:businessId/:id")
async updateEmployee(
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/controllers/business/PostsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { BadRequest, Forbidden, NotFound } from "@tsed/exceptions";
import { prisma } from "../../lib/prisma";

@UseBeforeEach(IsAuth)
@Controller("/posts")
@Controller("/businesses/posts")
export class BusinessPostsController {
@Post("/:id")
async createPost(
Expand Down
2 changes: 0 additions & 2 deletions packages/api/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ const rootDir = __dirname;
},
mount: {
"/v1": [`${rootDir}/controllers/**/*.ts`],
"/v1/admin/manage": [`${rootDir}/controllers/admin/manage/*.ts`],
"/v1/businesses": [`${rootDir}/controllers/business/*.ts`],
},
statics: {
"/static": [
Expand Down
2 changes: 2 additions & 0 deletions packages/client/locales/en/business.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"pendingEmployees": "Pending Employees",
"noPendingEmployees": "There are no employees pending access.",
"businessIsWhitelisted": "This business is whitelisted. You will be able to view it once you're accepted.",
"postTitle": "Post Title",
"postBody": "Post Body",
"alert_fireEmployee": "Are you sure you want to fire <span>{employee}</span>? This action cannot be undone.",
"alert_deletePost": "Are you sure you want to delete this post? This action cannot be undone.",
"alert_deleteBusiness": "Are you sure you want to delete \"<span>{business}</span>\"? This action cannot be undone."
Expand Down
5 changes: 2 additions & 3 deletions packages/client/src/components/business/ManagePostModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const ManageBusinessPostModal = ({ onClose, onCreate, onUpdate, post }: P
const { state, execute } = useFetch();
const common = useTranslations("Common");
const t = useTranslations("Business");
const bleeter = useTranslations("Bleeter");

if (!currentBusiness || !currentEmployee) {
return null;
Expand Down Expand Up @@ -82,7 +81,7 @@ export const ManageBusinessPostModal = ({ onClose, onCreate, onUpdate, post }: P
<Formik validate={validate} onSubmit={onSubmit} initialValues={INITIAL_VALUES}>
{({ handleChange, errors, values, isValid }) => (
<Form>
<FormField fieldId="title" label={bleeter("bleetTitle")}>
<FormField fieldId="title" label={t("postTitle")}>
<Input
id="title"
onChange={handleChange}
Expand All @@ -92,7 +91,7 @@ export const ManageBusinessPostModal = ({ onClose, onCreate, onUpdate, post }: P
<Error>{errors.title}</Error>
</FormField>

<FormField fieldId="body" label={bleeter("bleetBody")}>
<FormField fieldId="body" label={t("postBody")}>
<Textarea
id="body"
onChange={handleChange}
Expand Down
5 changes: 3 additions & 2 deletions packages/client/src/context/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const AuthProvider = ({ initialData, children }: ProviderProps) => {

if ((!NO_LOADING_ROUTES.includes(router.pathname) && !user) || isForbidden) {
return (
<div id="unauthorized" className="fixed inset-0 grid place-items-center bg-transparent">
<div id="unauthorized" className="fixed inset-0 grid bg-transparent place-items-center">
<span aria-label="loading...">
<Loader className="w-14 h-14 border-[3px]" />
</span>
Expand All @@ -121,7 +121,7 @@ export const AuthProvider = ({ initialData, children }: ProviderProps) => {

if (cad && !isEnabled) {
return (
<main className="grid place-items-center h-screen">
<main className="grid h-screen place-items-center">
<p>Feature is not enabled.</p>
</main>
);
Expand Down Expand Up @@ -178,6 +178,7 @@ function isDarkModeSupportedForPage(pathname: string) {
"/dispatch",
"/admin/values/driverslicense-category",
"/admin/values/penal-code",
"/admin/manage/businesses",
];

return routes.includes(pathname);
Expand Down
12 changes: 6 additions & 6 deletions packages/client/src/pages/admin/manage/businesses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function ManageBusinesses({ businesses: data }: Props) {
}, [data]);

return (
<AdminLayout>
<AdminLayout className="dark:text-white">
<Head>
<title>{t("MANAGE_BUSINESSES")}</title>
</Head>
Expand All @@ -81,13 +81,13 @@ export default function ManageBusinesses({ businesses: data }: Props) {
<ul className="mt-5">
{businesses.map((business, idx) => (
<li
className="my-1 bg-gray-200 p-2 px-4 rounded-md w-full flex flex-col"
className="flex flex-col w-full p-2 px-4 my-1 bg-gray-200 rounded-md dark:bg-gray-2"
key={business.id}
>
<Disclosure>
<div className="flex items-center justify-between">
<div>
<span className="select-none text-gray-500">{idx + 1}.</span>
<span className="text-gray-500 select-none">{idx + 1}.</span>
<span className="ml-2">{business.name}</span>
</div>

Expand Down Expand Up @@ -139,7 +139,7 @@ export default function ManageBusinesses({ businesses: data }: Props) {
</FormField>
</div>

<div className="mt-2 flex gap-2 items-center justify-end">
<div className="flex items-center justify-end gap-2 mt-2">
<Button
variant="cancel"
disabled={state === "loading"}
Expand All @@ -153,7 +153,7 @@ export default function ManageBusinesses({ businesses: data }: Props) {
variant="danger"
onClick={handleDelete}
>
{state === "loading" ? <Loader className="border-red-200 mr-2" /> : null}{" "}
{state === "loading" ? <Loader className="mr-2 border-red-200" /> : null}{" "}
{common("delete")}
</Button>
</div>
Expand All @@ -163,7 +163,7 @@ export default function ManageBusinesses({ businesses: data }: Props) {
}

export const getServerSideProps: GetServerSideProps = async ({ locale, req }) => {
const [data] = await requestAll(req, [["/admin/manage/businesses-admin", []]]);
const [data] = await requestAll(req, [["/admin/manage/businesses", []]]);

return {
props: {
Expand Down
10 changes: 5 additions & 5 deletions packages/client/src/pages/business/[id]/[employeeId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function BusinessId(props: Props) {
async function handlePostDeletion() {
if (!tempPost) return;

const { json } = await execute(`/businesses/${currentBusiness?.id}/posts/${tempPost.id}`, {
const { json } = await execute(`/businesses/posts/${currentBusiness?.id}/${tempPost.id}`, {
method: "DELETE",
data: { employeeId: currentEmployee?.id },
});
Expand Down Expand Up @@ -107,15 +107,15 @@ export default function BusinessId(props: Props) {
</div>
</header>

<main className="flex flex-col sm:flex-row mt-5">
<main className="flex flex-col mt-5 sm:flex-row">
<section className="w-full mr-5">
<ul className="space-y-3">
{posts.map((post) => {
const publishedBy = currentBusiness.employees.find((em) => em.id === post.employeeId);

return (
<li className="bg-gray-100 dark:bg-gray-2 overflow-hidden rounded-md" key={post.id}>
<header className="p-4 flex items-center justify-between">
<li className="overflow-hidden bg-gray-100 rounded-md dark:bg-gray-2" key={post.id}>
<header className="flex items-center justify-between p-4">
<h3 className="text-2xl font-semibold">{post.title}</h3>

{post.employeeId === currentEmployee.id ? (
Expand All @@ -140,7 +140,7 @@ export default function BusinessId(props: Props) {
</main>

{publishedBy ? (
<footer className="bg-gray-200/30 dark:bg-gray-3 px-4 py-2">
<footer className="px-4 py-2 bg-gray-200/30 dark:bg-gray-3">
<span className="font-semibold">{t("publishedBy")}: </span>
<span>
{publishedBy?.citizen.name} {publishedBy?.citizen.surname}
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/pages/citizen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default function CitizenPage({ citizens }: Props) {
}
>
{citizens.length <= 0 ? (
<p className="font-medium text-gray-600">{t("userNoCitizens")}</p>
<p className="font-medium text-gray-600 dark:text-gray-300">{t("userNoCitizens")}</p>
) : (
citizens.map((citizen) => (
<li
Expand Down

0 comments on commit 8c045fa

Please sign in to comment.