From 4e3f6be8e322929b83a35c7789078260dca9eb58 Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Sun, 16 Oct 2022 20:21:35 +0200 Subject: [PATCH] feat: automatically detect hour format --- frontend/.env.example | 1 - frontend/next.config.js | 1 - .../components/share/CreateUploadModalBody.tsx | 16 +++------------- .../upload/showCompletedUploadModal.tsx | 8 +++----- frontend/src/pages/account/shares.tsx | 6 ++---- 5 files changed, 8 insertions(+), 24 deletions(-) diff --git a/frontend/.env.example b/frontend/.env.example index 7e65299c..dbda9022 100644 --- a/frontend/.env.example +++ b/frontend/.env.example @@ -1,4 +1,3 @@ SHOW_HOME_PAGE=true ALLOW_REGISTRATION=true MAX_FILE_SIZE=1000000000 -TWELVE_HOUR_TIME=false diff --git a/frontend/next.config.js b/frontend/next.config.js index dea14c00..f78b7433 100644 --- a/frontend/next.config.js +++ b/frontend/next.config.js @@ -6,7 +6,6 @@ const nextConfig = { SHOW_HOME_PAGE: process.env.SHOW_HOME_PAGE, MAX_FILE_SIZE: process.env.MAX_FILE_SIZE, BACKEND_URL: process.env.BACKEND_URL, - TWELVE_HOUR_TIME: process.env.TWELVE_HOUR_TIME } } diff --git a/frontend/src/components/share/CreateUploadModalBody.tsx b/frontend/src/components/share/CreateUploadModalBody.tsx index 04507633..f4dd7d4d 100644 --- a/frontend/src/components/share/CreateUploadModalBody.tsx +++ b/frontend/src/components/share/CreateUploadModalBody.tsx @@ -1,8 +1,8 @@ import { Accordion, Button, - Col, Checkbox, + Col, Grid, NumberInput, PasswordInput, @@ -13,13 +13,10 @@ import { } from "@mantine/core"; import { useForm, yupResolver } from "@mantine/form"; import { useModals } from "@mantine/modals"; +import moment from "moment"; import * as yup from "yup"; import shareService from "../../services/share.service"; import { ShareSecurity } from "../../types/share.type"; -import moment from "moment"; -import getConfig from "next/config"; - -const { publicRuntimeConfig } = getConfig(); const PreviewExpiration = ({ form }: { form: any }) => { const value = form.values.never_expires @@ -34,14 +31,7 @@ const PreviewExpiration = ({ form }: { form: any }) => { ) .toDate(); - if (publicRuntimeConfig.TWELVE_HOUR_TIME === "true") - return `This share will expire on ${moment(expirationDate).format( - "MMMM Do YYYY, h:mm a" - )}`; - else - return `This share will expire on ${moment(expirationDate).format( - "MMMM DD YYYY, HH:mm" - )}`; + return `This share will expire on ${moment(expirationDate).format("LLL")}`; }; const CreateUploadModalBody = ({ diff --git a/frontend/src/components/upload/showCompletedUploadModal.tsx b/frontend/src/components/upload/showCompletedUploadModal.tsx index 68c32ae5..ac7de640 100644 --- a/frontend/src/components/upload/showCompletedUploadModal.tsx +++ b/frontend/src/components/upload/showCompletedUploadModal.tsx @@ -62,11 +62,9 @@ const Body = ({ share }: { share: Share }) => { {/* If our share.expiration is timestamp 0, show a different message */} {moment(share.expiration).unix() === 0 ? "This share will never expire." - : `This share will expire on ${ - publicRuntimeConfig.TWELVE_HOUR_TIME === "true" - ? moment(share.expiration).format("MMMM Do YYYY, h:mm a") - : moment(share.expiration).format("MMMM DD YYYY, HH:mm") - }`} + : `This share will expire on ${moment(share.expiration).format( + "LLL" + )}`}