Adding registration mode to details modal. Fixes #153

This commit is contained in:
Dessalines 2023-10-23 13:37:16 -04:00
parent 6da2dbb005
commit 5478a493da
2 changed files with 25 additions and 1 deletions

@ -1 +1 @@
Subproject commit 74b5b5023bc27f6f0fc1bc2dc3fc81f49110b501
Subproject commit 5abee6854397d898bed9219b22166be718c2b8e7

View file

@ -115,6 +115,8 @@ const InstanceCard = ({ instance }: InstanceCardProps) => {
const users = instance.site_info.site_view.counts.users;
const comments = instance.site_info.site_view.counts.comments;
const monthlyUsers = instance.site_info.site_view.counts.users_active_month;
const registrationMode =
instance.site_info.site_view.local_site.registration_mode;
const modalId = `modal_${domain}`;
@ -131,6 +133,7 @@ const InstanceCard = ({ instance }: InstanceCardProps) => {
monthlyUsers={monthlyUsers}
icon={icon}
sidebar={sidebar}
registrationMode={registrationMode}
/>
<InstanceIcon domain={domain} icon={icon} />
<InstanceStats
@ -229,6 +232,18 @@ export const StatsBadges = ({ users, comments, monthlyUsers }) => (
</>
);
function registrationModeToString(registrationMode: string): string {
if (registrationMode == "Open") {
return i18n.t("registrations_open");
} else if (registrationMode == "Closed") {
return i18n.t("registrations_closed");
} else if (registrationMode == "RequireApplication") {
return i18n.t("requires_application");
} else {
return i18n.t("registrations_open");
}
}
export const DetailsModal = ({
id,
domain,
@ -238,6 +253,7 @@ export const DetailsModal = ({
comments,
monthlyUsers,
sidebar,
registrationMode,
}) => (
<dialog id={id} className="modal">
<form method="dialog" className="modal-backdrop">
@ -262,6 +278,14 @@ export const DetailsModal = ({
comments={comments}
monthlyUsers={monthlyUsers}
/>
<Badge
content={
<div className="text-sm text-gray-500">
<Icon icon="user-check" classes="mr-2" />
<span>{registrationModeToString(registrationMode)}</span>
</div>
}
/>
<div className="btn btn-primary btn-outline btn-sm normal-case">
<a href={buildUrl(domain)}>{i18n.t("browse_instance")}</a>
</div>