Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: CAD Timezone #1789

Merged
merged 2 commits into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "cad" ADD COLUMN "timeZone" TEXT;
1 change: 1 addition & 0 deletions apps/api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ model cad {
autoSetUserPropertiesId String?
discordRoles DiscordRoles? @relation(fields: [discordRolesId], references: [id])
discordRolesId String?
timeZone String?
}

model CadFeature {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export class CADSettingsController {
businessWhitelisted: data.businessWhitelisted,
registrationCode: data.registrationCode,
logoId: data.image,
timeZone: data.timeZone || null,
miscCadSettings: { update: { roleplayEnabled: data.roleplayEnabled } },
},
include: { features: true, miscCadSettings: true, apiToken: true },
Expand Down
1 change: 1 addition & 0 deletions apps/api/src/middlewares/auth/is-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export function CAD_SELECT(options: CadSelectOptions) {
businessWhitelisted: true,
features: true,
autoSetUserProperties: true,
timeZone: true,
registrationCode: options.selectCADsettings,
steamApiKey: options.selectCADsettings,
apiTokenId: options.selectCADsettings,
Expand Down
4 changes: 3 additions & 1 deletion apps/client/locales/en/cad-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
"taxiWhitelist": "Taxi Whitelist",
"taxiWhitelistDescription": "The taxi system will be whitelisted. The Taxi permission must be given to the user before they can use the taxi system.",
"businessWhitelist": "Business Whitelist",
"businessWhitelistDescription": "The business system will be whitelisted. Any new business must first be reviewed, then they can be approved or denied before it can be used."
"businessWhitelistDescription": "The business system will be whitelisted. Any new business must first be reviewed, then they can be approved or denied before it can be used.",
"timeZone": "Time Zone",
"timeZoneDescription": "The time zone that will be used in the SnailyCAD instance. This will apply to all users."
},
"DiscordRolesTab": {
"discordRoles": "Discord Roles",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ import * as React from "react";
import { useAuth } from "context/AuthContext";
import { useTranslations } from "use-intl";
import useFetch from "lib/useFetch";
import { Button, Input, Loader, SwitchField, TextField, Textarea } from "@snailycad/ui";
import {
Button,
Input,
Loader,
SelectField,
SwitchField,
TextField,
Textarea,
} from "@snailycad/ui";
import { handleValidate } from "lib/handleValidate";
import { CAD_SETTINGS_SCHEMA } from "@snailycad/schemas";
import { ImageSelectInput, validateFile } from "components/form/inputs/ImageSelectInput";
Expand All @@ -14,6 +22,8 @@ import type { PutCADSettingsData } from "@snailycad/types/api";
import { TabsContent } from "@radix-ui/react-tabs";
import { SettingsTabs } from "components/admin/cad-settings/layout";

import timeZones from "./timezones.json";

export function GeneralSettingsTab() {
const [logo, setLogo] = React.useState<(File | string) | null>(null);
const [headerId, setHeaderId] = React.useState<(File | string) | null>(null);
Expand Down Expand Up @@ -111,6 +121,7 @@ export function GeneralSettingsTab() {
registrationCode: cad.registrationCode ?? "",
roleplayEnabled: cad.miscCadSettings?.roleplayEnabled ?? true,
cadOGDescription: cad.miscCadSettings?.cadOGDescription ?? "",
timeZone: cad?.timeZone ?? null,
};

return (
Expand Down Expand Up @@ -146,6 +157,24 @@ export function GeneralSettingsTab() {
/>
</SettingsFormField>

<SettingsFormField
label={t("timeZone")}
description={t("timeZoneDescription")}
errorMessage={errors.timeZone}
optional
>
<SelectField
name="timeZone"
label={t("timeZone")}
options={timeZones.map((tz) => ({
label: tz,
value: tz,
}))}
selectedKey={values.timeZone}
onSelectionChange={(value) => setFieldValue("timeZone", value)}
/>
</SettingsFormField>

{AOP ? (
<SettingsFormField
optional
Expand Down
Loading
Loading