Skip to content

Commit

Permalink
feat: CAD timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 committed Sep 10, 2023
1 parent a2e8f2f commit 8f851b5
Show file tree
Hide file tree
Showing 11 changed files with 481 additions and 9 deletions.
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
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

0 comments on commit 8f851b5

Please sign in to comment.