-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into feat/anon-company-rev…
…iews
- Loading branch information
Showing
96 changed files
with
2,559 additions
and
1,655 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,3 +44,8 @@ | |
- Habeebah157 | ||
- bryanansong | ||
- nathanallen242 | ||
- Soogz | ||
- poughe | ||
- katlj | ||
- rafa1510 | ||
- Meron-b |
94 changes: 94 additions & 0 deletions
94
apps/admin-dashboard/app/routes/_dashboard.admins.$id.remove.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { | ||
type ActionFunctionArgs, | ||
json, | ||
type LoaderFunctionArgs, | ||
redirect, | ||
} from '@remix-run/node'; | ||
import { | ||
Form as RemixForm, | ||
useActionData, | ||
useLoaderData, | ||
} from '@remix-run/react'; | ||
|
||
import { getAdmin, removeAdmin } from '@oyster/core/admins'; | ||
import { Button, Form, Modal } from '@oyster/ui'; | ||
|
||
import { Route } from '@/shared/constants'; | ||
import { | ||
commitSession, | ||
ensureUserAuthenticated, | ||
toast, | ||
user, | ||
} from '@/shared/session.server'; | ||
|
||
export async function loader({ params, request }: LoaderFunctionArgs) { | ||
await ensureUserAuthenticated(request); | ||
|
||
const admin = await getAdmin({ | ||
select: ['admins.firstName', 'admins.lastName'], | ||
where: { id: params.id as string }, | ||
}); | ||
|
||
if (!admin) { | ||
throw new Response(null, { status: 404 }); | ||
} | ||
|
||
return json({ | ||
admin, | ||
}); | ||
} | ||
|
||
export async function action({ params, request }: ActionFunctionArgs) { | ||
const session = await ensureUserAuthenticated(request); | ||
|
||
const result = await removeAdmin({ | ||
actor: user(session), | ||
id: params.id as string, | ||
}); | ||
|
||
if (!result.ok) { | ||
return json({ error: result.error }, { status: result.code }); | ||
} | ||
|
||
toast(session, { | ||
message: 'Removed admin.', | ||
}); | ||
|
||
return redirect(Route['/admins'], { | ||
headers: { | ||
'Set-Cookie': await commitSession(session), | ||
}, | ||
}); | ||
} | ||
|
||
export default function RemoveAdminPage() { | ||
const { admin } = useLoaderData<typeof loader>(); | ||
const actionData = useActionData<typeof action>(); | ||
|
||
return ( | ||
<Modal onCloseTo={Route['/admins']}> | ||
<Modal.Header> | ||
<Modal.Title> | ||
Remove {admin.firstName} {admin.lastName} | ||
</Modal.Title> | ||
<Modal.CloseButton /> | ||
</Modal.Header> | ||
|
||
<Modal.Description> | ||
This is not an undoable action. Are you sure want to remove this admin? | ||
</Modal.Description> | ||
|
||
<RemixForm className="form" method="post"> | ||
<Form.ErrorMessage>{actionData?.error}</Form.ErrorMessage> | ||
|
||
<Button.Group> | ||
<Button.Submit color="error">Remove</Button.Submit> | ||
</Button.Group> | ||
</RemixForm> | ||
</Modal> | ||
); | ||
} | ||
|
||
export function ErrorBoundary() { | ||
return <></>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
apps/admin-dashboard/app/routes/_dashboard.bull.$queue._index.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.