feat: change timezone and date format
This commit is contained in:
parent
5550c89782
commit
e5af638219
|
|
@ -18,6 +18,13 @@ import { FacebookComponent } from '@gitroom/frontend/components/layout/facebook.
|
|||
import { headers } from 'next/headers';
|
||||
import { headerName } from '@gitroom/react/translation/i18n.config';
|
||||
import { HtmlComponent } from '@gitroom/frontend/components/layout/html.component';
|
||||
import dynamicLoad from 'next/dynamic';
|
||||
const SetTimezone = dynamicLoad(
|
||||
() => import('@gitroom/frontend/components/layout/set.timezone'),
|
||||
{
|
||||
ssr: false,
|
||||
}
|
||||
);
|
||||
|
||||
const jakartaSans = Plus_Jakarta_Sans({
|
||||
weight: ['600', '500'],
|
||||
|
|
@ -72,6 +79,7 @@ export default async function AppLayout({ children }: { children: ReactNode }) {
|
|||
}
|
||||
>
|
||||
<SentryComponent>
|
||||
<SetTimezone />
|
||||
<HtmlComponent />
|
||||
<ToltScript />
|
||||
<FacebookComponent />
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import {
|
|||
StarsList,
|
||||
} from '@gitroom/frontend/components/analytics/stars.and.forks.interface';
|
||||
import dayjs from 'dayjs';
|
||||
import { newDayjs } from '@gitroom/frontend/components/layout/set.timezone';
|
||||
export const Chart: FC<{
|
||||
list: StarsList[] | ForksList[];
|
||||
}> = (props) => {
|
||||
|
|
@ -48,7 +49,7 @@ export const Chart: FC<{
|
|||
},
|
||||
},
|
||||
data: {
|
||||
labels: list.map((row) => dayjs(row.date).format('DD/MM/YYYY')),
|
||||
labels: list.map((row) => newDayjs(row.date).format('DD/MM/YYYY')),
|
||||
datasets: [
|
||||
{
|
||||
borderColor: '#fff',
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import { TrackEnum } from '@gitroom/nestjs-libraries/user/track.enum';
|
|||
import { PurchaseCrypto } from '@gitroom/frontend/components/billing/purchase.crypto';
|
||||
import { useT } from '@gitroom/react/translation/get.transation.service.client';
|
||||
import { FinishTrial } from '@gitroom/frontend/components/billing/finish.trial';
|
||||
import { newDayjs } from '@gitroom/frontend/components/layout/set.timezone';
|
||||
|
||||
export const Prorate: FC<{
|
||||
period: 'MONTHLY' | 'YEARLY';
|
||||
|
|
@ -505,7 +506,7 @@ export const MainBillingComponent: FC<{
|
|||
'your_subscription_will_be_canceled_at',
|
||||
'Your subscription will be canceled at'
|
||||
)}
|
||||
{dayjs(subscription.cancelAt).local().format('D MMM, YYYY')}
|
||||
{newDayjs(subscription.cancelAt).local().format('D MMM, YYYY')}
|
||||
<br />
|
||||
{t(
|
||||
'you_will_never_be_charged_again',
|
||||
|
|
|
|||
|
|
@ -20,12 +20,13 @@ import isoWeek from 'dayjs/plugin/isoWeek';
|
|||
import weekOfYear from 'dayjs/plugin/weekOfYear';
|
||||
import { extend } from 'dayjs';
|
||||
import useCookie from 'react-use-cookie';
|
||||
import { newDayjs } from '@gitroom/frontend/components/layout/set.timezone';
|
||||
extend(isoWeek);
|
||||
extend(weekOfYear);
|
||||
|
||||
export const CalendarContext = createContext({
|
||||
startDate: dayjs().startOf('isoWeek').format('YYYY-MM-DD'),
|
||||
endDate: dayjs().endOf('isoWeek').format('YYYY-MM-DD'),
|
||||
startDate: newDayjs().startOf('isoWeek').format('YYYY-MM-DD'),
|
||||
endDate: newDayjs().endOf('isoWeek').format('YYYY-MM-DD'),
|
||||
customer: null as string | null,
|
||||
sets: [] as { name: string; id: string; content: string[] }[],
|
||||
signature: undefined as any,
|
||||
|
|
@ -86,7 +87,7 @@ export interface Integrations {
|
|||
|
||||
// Helper function to get start and end dates based on display type
|
||||
function getDateRange(display: string, referenceDate?: string) {
|
||||
const date = referenceDate ? dayjs(referenceDate) : dayjs();
|
||||
const date = referenceDate ? newDayjs(referenceDate) : newDayjs();
|
||||
|
||||
switch (display) {
|
||||
case 'day':
|
||||
|
|
@ -153,8 +154,8 @@ export const CalendarWeekProvider: FC<{
|
|||
const modifiedParams = new URLSearchParams({
|
||||
display: filters.display,
|
||||
customer: filters?.customer?.toString() || '',
|
||||
startDate: dayjs(filters.startDate).startOf('day').utc().format(),
|
||||
endDate: dayjs(filters.endDate).endOf('day').utc().format(),
|
||||
startDate: newDayjs(filters.startDate).startOf('day').utc().format(),
|
||||
endDate: newDayjs(filters.endDate).endOf('day').utc().format(),
|
||||
}).toString();
|
||||
|
||||
const data = (await fetch(`/posts?${modifiedParams}`)).json();
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ import { deleteDialog } from '@gitroom/react/helpers/delete.dialog';
|
|||
import { useVariables } from '@gitroom/react/helpers/variable.context';
|
||||
import { stripHtmlValidation } from '@gitroom/helpers/utils/strip.html.validation';
|
||||
import { ModalWrapperComponent } from '../new-launch/modal.wrapper.component';
|
||||
import { newDayjs } from '@gitroom/frontend/components/layout/set.timezone';
|
||||
|
||||
// Extend dayjs with necessary plugins
|
||||
extend(isSameOrAfter);
|
||||
|
|
@ -146,7 +147,7 @@ export const DayView = () => {
|
|||
{options.map((option) => (
|
||||
<Fragment key={option[0].time}>
|
||||
<div className="text-center text-[14px]">
|
||||
{dayjs()
|
||||
{newDayjs()
|
||||
.utc()
|
||||
.startOf('day')
|
||||
.add(option[0].time, 'minute')
|
||||
|
|
@ -186,7 +187,7 @@ export const WeekView = () => {
|
|||
dayjs.locale(currentLanguage);
|
||||
|
||||
const days = [];
|
||||
const weekStart = dayjs(startDate);
|
||||
const weekStart = newDayjs(startDate);
|
||||
for (let i = 0; i < 7; i++) {
|
||||
const day = weekStart.add(i, 'day');
|
||||
days.push({
|
||||
|
|
@ -214,10 +215,10 @@ export const WeekView = () => {
|
|||
<div
|
||||
className={clsx(
|
||||
'text-[14px] font-[600] flex items-center justify-center gap-[6px]',
|
||||
day.day === dayjs().format('L') && 'text-newTableTextFocused'
|
||||
day.day === newDayjs().format('L') && 'text-newTableTextFocused'
|
||||
)}
|
||||
>
|
||||
{day.day === dayjs().format('L') && (
|
||||
{day.day === newDayjs().format('L') && (
|
||||
<div className="w-[6px] h-[6px] bg-newTableTextFocused rounded-full" />
|
||||
)}
|
||||
{day.day}
|
||||
|
|
@ -259,17 +260,17 @@ export const MonthView = () => {
|
|||
const days = [];
|
||||
// Starting from Monday (1) to Sunday (7)
|
||||
for (let i = 1; i <= 7; i++) {
|
||||
days.push(dayjs().day(i).format('dddd'));
|
||||
days.push(newDayjs().day(i).format('dddd'));
|
||||
}
|
||||
return days;
|
||||
}, [i18next.resolvedLanguage]);
|
||||
|
||||
const calendarDays = useMemo(() => {
|
||||
const monthStart = dayjs(startDate);
|
||||
const monthStart = newDayjs(startDate);
|
||||
const currentMonth = monthStart.month();
|
||||
const currentYear = monthStart.year();
|
||||
|
||||
const startOfMonth = dayjs(new Date(currentYear, currentMonth, 1));
|
||||
const startOfMonth = newDayjs(new Date(currentYear, currentMonth, 1));
|
||||
|
||||
// Calculate the day offset for Monday (isoWeekday() returns 1 for Monday)
|
||||
const startDayOfWeek = startOfMonth.isoWeekday(); // 1 for Monday, 7 for Sunday
|
||||
|
|
@ -314,7 +315,7 @@ export const MonthView = () => {
|
|||
className="text-center items-center justify-center flex min-h-[100px]"
|
||||
>
|
||||
<CalendarColumn
|
||||
getDate={dayjs(date.day).endOf('day')}
|
||||
getDate={newDayjs(date.day).endOf('day')}
|
||||
randomHour={true}
|
||||
/>
|
||||
</div>
|
||||
|
|
@ -390,7 +391,7 @@ export const CalendarColumn: FC<{
|
|||
|
||||
const isBeforeNow = useMemo(() => {
|
||||
const originalUtc = getDate.startOf('hour');
|
||||
return originalUtc.startOf('hour').isBefore(dayjs().startOf('hour').utc());
|
||||
return originalUtc.startOf('hour').isBefore(newDayjs().startOf('hour').utc());
|
||||
}, [getDate, num]);
|
||||
|
||||
const { start, stop } = useInterval(
|
||||
|
|
@ -571,8 +572,8 @@ export const CalendarColumn: FC<{
|
|||
randomHour
|
||||
? getDate.hour(Math.floor(Math.random() * 24))
|
||||
: getDate.format('YYYY-MM-DDTHH:mm:ss') ===
|
||||
dayjs().startOf('hour').format('YYYY-MM-DDTHH:mm:ss')
|
||||
? dayjs().add(10, 'minute')
|
||||
newDayjs().startOf('hour').format('YYYY-MM-DDTHH:mm:ss')
|
||||
? newDayjs().add(10, 'minute')
|
||||
: getDate
|
||||
}
|
||||
{...(set?.content ? { set: JSON.parse(set.content) } : {})}
|
||||
|
|
|
|||
|
|
@ -7,13 +7,14 @@ import { useCallback } from 'react';
|
|||
import { SelectCustomer } from '@gitroom/frontend/components/launches/select.customer';
|
||||
import { useT } from '@gitroom/react/translation/get.transation.service.client';
|
||||
import i18next from 'i18next';
|
||||
import { newDayjs } from '@gitroom/frontend/components/layout/set.timezone';
|
||||
|
||||
// Helper function to get start and end dates based on display type
|
||||
function getDateRange(
|
||||
display: 'day' | 'week' | 'month',
|
||||
referenceDate?: string
|
||||
) {
|
||||
const date = referenceDate ? dayjs(referenceDate) : dayjs();
|
||||
const date = referenceDate ? newDayjs(referenceDate) : newDayjs();
|
||||
|
||||
switch (display) {
|
||||
case 'day':
|
||||
|
|
@ -44,8 +45,8 @@ export const Filters = () => {
|
|||
|
||||
// Calculate display date range text
|
||||
const getDisplayText = () => {
|
||||
const startDate = dayjs(calendar.startDate);
|
||||
const endDate = dayjs(calendar.endDate);
|
||||
const startDate = newDayjs(calendar.startDate);
|
||||
const endDate = newDayjs(calendar.endDate);
|
||||
|
||||
switch (calendar.display) {
|
||||
case 'day':
|
||||
|
|
@ -60,7 +61,7 @@ export const Filters = () => {
|
|||
};
|
||||
|
||||
const setToday = useCallback(() => {
|
||||
const today = dayjs();
|
||||
const today = newDayjs();
|
||||
const currentRange = getDateRange(
|
||||
calendar.display as 'day' | 'week' | 'month'
|
||||
);
|
||||
|
|
@ -151,7 +152,7 @@ export const Filters = () => {
|
|||
);
|
||||
|
||||
const next = useCallback(() => {
|
||||
const currentStart = dayjs(calendar.startDate);
|
||||
const currentStart = newDayjs(calendar.startDate);
|
||||
let nextStart: dayjs.Dayjs;
|
||||
|
||||
switch (calendar.display) {
|
||||
|
|
@ -181,7 +182,7 @@ export const Filters = () => {
|
|||
}, [calendar]);
|
||||
|
||||
const previous = useCallback(() => {
|
||||
const currentStart = dayjs(calendar.startDate);
|
||||
const currentStart = newDayjs(calendar.startDate);
|
||||
let prevStart: dayjs.Dayjs;
|
||||
|
||||
switch (calendar.display) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { useClickOutside } from '@mantine/hooks';
|
|||
import { Button } from '@gitroom/react/form/button';
|
||||
import { isUSCitizen } from './isuscitizen.utils';
|
||||
import { useT } from '@gitroom/react/translation/get.transation.service.client';
|
||||
import { newDayjs } from '@gitroom/frontend/components/layout/set.timezone';
|
||||
export const DatePicker: FC<{
|
||||
date: dayjs.Dayjs;
|
||||
onChange: (day: dayjs.Dayjs) => void;
|
||||
|
|
@ -22,10 +23,10 @@ export const DatePicker: FC<{
|
|||
const changeDate = useCallback(
|
||||
(type: 'date' | 'time') => (day: Date) => {
|
||||
onChange(
|
||||
dayjs(
|
||||
newDayjs(
|
||||
type === 'time'
|
||||
? date.format('YYYY-MM-DD') + ' ' + dayjs(day).format('HH:mm:ss')
|
||||
: dayjs(day).format('YYYY-MM-DD') + ' ' + date.format('HH:mm:ss')
|
||||
? date.format('YYYY-MM-DD') + ' ' + newDayjs(day).format('HH:mm:ss')
|
||||
: newDayjs(day).format('YYYY-MM-DD') + ' ' + date.format('HH:mm:ss')
|
||||
)
|
||||
);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export const isUSCitizen = () => {
|
||||
const userLanguage = navigator.language || navigator.languages[0];
|
||||
return userLanguage.startsWith('en-US');
|
||||
const userLanguage = localStorage.getItem('isUS') || ((navigator.language || navigator.languages[0]).startsWith('en-US') ? 'US' : 'GLOBAL');
|
||||
return userLanguage === 'US';
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
import { createContext, useContext } from 'react';
|
||||
import { Integrations } from '@gitroom/frontend/components/launches/calendar.context';
|
||||
import dayjs from 'dayjs';
|
||||
import { newDayjs } from '@gitroom/frontend/components/layout/set.timezone';
|
||||
export const IntegrationContext = createContext<{
|
||||
date: dayjs.Dayjs;
|
||||
integration: Integrations | undefined;
|
||||
|
|
@ -18,7 +19,7 @@ export const IntegrationContext = createContext<{
|
|||
}>({
|
||||
integration: undefined,
|
||||
value: [],
|
||||
date: dayjs(),
|
||||
date: newDayjs(),
|
||||
allIntegrations: [],
|
||||
});
|
||||
export const useIntegration = () => useContext(IntegrationContext);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import { useModals } from '@mantine/modals';
|
|||
import { sortBy } from 'lodash';
|
||||
import { usePreventWindowUnload } from '@gitroom/react/helpers/use.prevent.window.unload';
|
||||
import { useT } from '@gitroom/react/translation/get.transation.service.client';
|
||||
import { newDayjs } from '@gitroom/frontend/components/layout/set.timezone';
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
const hours = [...Array(24).keys()].map((i, index) => ({
|
||||
|
|
@ -70,12 +71,12 @@ export const TimeTable: FC<{
|
|||
);
|
||||
const addHour = useCallback(() => {
|
||||
const calculateMinutes =
|
||||
dayjs()
|
||||
newDayjs()
|
||||
.utc()
|
||||
.startOf('day')
|
||||
.add(hour, 'hours')
|
||||
.add(minute, 'minutes')
|
||||
.diff(dayjs().utc().startOf('day'), 'minutes') - dayjs.tz().utcOffset();
|
||||
.diff(newDayjs().utc().startOf('day'), 'minutes') - dayjs.tz().utcOffset();
|
||||
setCurrentTimes((prev) => [
|
||||
...prev,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import dayjs from 'dayjs';
|
|||
import useSWR, { useSWRConfig } from 'swr';
|
||||
import { useFetch } from '@gitroom/helpers/utils/custom.fetch';
|
||||
import { continueProviderList } from '@gitroom/frontend/components/new-launch/providers/continue-provider/list';
|
||||
import { newDayjs } from '@gitroom/frontend/components/layout/set.timezone';
|
||||
export const Null: FC<{
|
||||
closeModal: () => void;
|
||||
existingId: string[];
|
||||
|
|
@ -82,7 +83,7 @@ export const ContinueProvider: FC = () => {
|
|||
<div className="pt-[16px] max-h-[600px] overflow-hidden overflow-y-auto">
|
||||
<IntegrationContext.Provider
|
||||
value={{
|
||||
date: dayjs(),
|
||||
date: newDayjs(),
|
||||
value: [],
|
||||
allIntegrations: [],
|
||||
integration: {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
'use client';
|
||||
import dayjs, { ConfigType } from 'dayjs';
|
||||
import { FC, useEffect } from 'react';
|
||||
import timezone from 'dayjs/plugin/timezone';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
dayjs.extend(timezone);
|
||||
dayjs.extend(utc);
|
||||
|
||||
const {utc: originalUtc} = dayjs;
|
||||
|
||||
dayjs.utc = new Proxy(originalUtc, {
|
||||
apply(target, thisArg, args) {
|
||||
const result = target.apply(thisArg, args);
|
||||
|
||||
// Attach `.local()` method to the returned Dayjs object
|
||||
result.local = function () {
|
||||
return result.tz(getTimezone());
|
||||
};
|
||||
|
||||
return result;
|
||||
},
|
||||
});
|
||||
|
||||
export const getTimezone = () => {
|
||||
return localStorage.getItem('timezone') || dayjs.tz.guess();
|
||||
};
|
||||
|
||||
export const newDayjs = (config?: ConfigType) => {
|
||||
return dayjs.tz(config, getTimezone());
|
||||
};
|
||||
|
||||
const SetTimezone: FC = () => {
|
||||
useEffect(() => {
|
||||
if (localStorage.getItem('timezone')) {
|
||||
dayjs.tz.setDefault(getTimezone());
|
||||
}
|
||||
}, []);
|
||||
return null;
|
||||
};
|
||||
|
||||
export default SetTimezone;
|
||||
|
|
@ -30,6 +30,7 @@ import { SignaturesComponent } from '@gitroom/frontend/components/settings/signa
|
|||
import { Autopost } from '@gitroom/frontend/components/autopost/autopost';
|
||||
import { useT } from '@gitroom/react/translation/get.transation.service.client';
|
||||
import { SVGLine } from '@gitroom/frontend/components/launches/launches.component';
|
||||
import { GlobalSettings } from '@gitroom/frontend/components/settings/global.settings';
|
||||
export const SettingsPopup: FC<{
|
||||
getRef?: Ref<any>;
|
||||
}> = (props) => {
|
||||
|
|
@ -80,22 +81,12 @@ export const SettingsPopup: FC<{
|
|||
close();
|
||||
}, []);
|
||||
|
||||
const [tab, setTab] = useState(() => {
|
||||
if (user?.tier?.team_members && isGeneral) {
|
||||
return 'teams';
|
||||
}
|
||||
if (user?.tier?.webhooks) {
|
||||
return 'webhooks';
|
||||
}
|
||||
if (user?.tier?.autoPost) {
|
||||
return 'autopost';
|
||||
}
|
||||
return 'sets';
|
||||
});
|
||||
const [tab, setTab] = useState('global_settings');
|
||||
|
||||
const t = useT();
|
||||
const list = useMemo(() => {
|
||||
const arr = [];
|
||||
arr.push({ tab: 'global_settings', label: t('global_settings', 'Global Settings') });
|
||||
// Populate tabs based on user permissions
|
||||
if (user?.tier?.team_members && isGeneral) {
|
||||
arr.push({ tab: 'teams', label: t('teams', 'Teams') });
|
||||
|
|
@ -168,6 +159,11 @@ export const SettingsPopup: FC<{
|
|||
!getRef && 'rounded-[4px]'
|
||||
)}
|
||||
>
|
||||
{tab === 'global_settings' && (
|
||||
<div>
|
||||
<GlobalSettings />
|
||||
</div>
|
||||
)}
|
||||
{tab === 'teams' && !!user?.tier?.team_members && isGeneral && (
|
||||
<div>
|
||||
<TeamsComponent />
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import dynamic from 'next/dynamic';
|
|||
import { IntegrationContext } from '@gitroom/frontend/components/launches/helpers/use.integration';
|
||||
import dayjs from 'dayjs';
|
||||
import { useT } from '@gitroom/react/translation/get.transation.service.client';
|
||||
import { newDayjs } from '@gitroom/frontend/components/layout/set.timezone';
|
||||
const PreviewPopupDynamic = dynamic(() =>
|
||||
import('@gitroom/frontend/components/marketplace/preview.popup.dynamic').then(
|
||||
(mod) => mod.PreviewPopupDynamic
|
||||
|
|
@ -279,7 +280,7 @@ export const Post: FC<{
|
|||
<IntegrationContext.Provider
|
||||
value={{
|
||||
allIntegrations: [],
|
||||
date: dayjs(),
|
||||
date: newDayjs(),
|
||||
integration,
|
||||
value: [],
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ import { MarketplaceProvider } from '@gitroom/frontend/components/marketplace/ma
|
|||
import { SpecialMessage } from '@gitroom/frontend/components/marketplace/special.message';
|
||||
import { usePageVisibility } from '@gitroom/react/helpers/use.is.visible';
|
||||
import { useT } from '@gitroom/react/translation/get.transation.service.client';
|
||||
import { newDayjs } from '@gitroom/frontend/components/layout/set.timezone';
|
||||
export const Message: FC<{
|
||||
message: Message;
|
||||
seller: SellerBuyer;
|
||||
|
|
@ -89,7 +90,7 @@ export const Message: FC<{
|
|||
);
|
||||
}, [amITheBuyerOrSeller, message]);
|
||||
const time = useMemo(() => {
|
||||
return dayjs(message.createdAt).format('h:mm A');
|
||||
return newDayjs(message.createdAt).format('h:mm A');
|
||||
}, [message]);
|
||||
return (
|
||||
<div className="flex gap-[10px]">
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { ManageModal } from '@gitroom/frontend/components/new-launch/manage.moda
|
|||
import { Integrations } from '@gitroom/frontend/components/launches/calendar.context';
|
||||
import { useShallow } from 'zustand/react/shallow';
|
||||
import { useExistingData } from '@gitroom/frontend/components/launches/helpers/use.existing.data';
|
||||
import { newDayjs } from '@gitroom/frontend/components/layout/set.timezone';
|
||||
|
||||
export interface AddEditModalProps {
|
||||
dummy?: boolean;
|
||||
|
|
@ -46,7 +47,7 @@ export const AddEditModal: FC<AddEditModalProps> = (props) => {
|
|||
const integrations = useLaunchStore((state) => state.integrations);
|
||||
useEffect(() => {
|
||||
setDummy(!!props.dummy);
|
||||
setDate(props.date || dayjs());
|
||||
setDate(props.date || newDayjs());
|
||||
setAllIntegrations(props.allIntegrations || []);
|
||||
setIsCreateSet(!!props.addEditSets);
|
||||
}, []);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import { Integrations } from '@gitroom/frontend/components/launches/calendar.con
|
|||
import { createRef, RefObject } from 'react';
|
||||
import { arrayMoveImmutable } from 'array-move';
|
||||
import { PostComment } from '@gitroom/frontend/components/new-launch/providers/high.order.provider';
|
||||
import { newDayjs } from '@gitroom/frontend/components/layout/set.timezone';
|
||||
|
||||
interface Values {
|
||||
id: string;
|
||||
|
|
@ -129,7 +130,7 @@ const initialState = {
|
|||
loaded: true,
|
||||
dummy: false,
|
||||
activateExitButton: true,
|
||||
date: dayjs(),
|
||||
date: newDayjs(),
|
||||
postComment: PostComment.ALL,
|
||||
tags: [] as { label: string; value: string }[],
|
||||
totalChars: 0,
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import { useFetch } from '@gitroom/helpers/utils/custom.fetch';
|
|||
import removeMd from 'remove-markdown';
|
||||
import clsx from 'clsx';
|
||||
import { useT } from '@gitroom/react/translation/get.transation.service.client';
|
||||
import { newDayjs } from '@gitroom/frontend/components/layout/set.timezone';
|
||||
const postUrlEmitter = new EventEmitter();
|
||||
export const ShowPostSelector = () => {
|
||||
const [showPostSelector, setShowPostSelector] = useState(false);
|
||||
|
|
@ -19,7 +20,7 @@ export const ShowPostSelector = () => {
|
|||
return tag;
|
||||
},
|
||||
} as any);
|
||||
const [date, setDate] = useState(dayjs());
|
||||
const [date, setDate] = useState(newDayjs());
|
||||
useEffect(() => {
|
||||
postUrlEmitter.on(
|
||||
'show',
|
||||
|
|
@ -35,14 +36,14 @@ export const ShowPostSelector = () => {
|
|||
return () => {
|
||||
setShowPostSelector(false);
|
||||
setCallback(null);
|
||||
setDate(dayjs());
|
||||
setDate(newDayjs());
|
||||
postUrlEmitter.removeAllListeners();
|
||||
};
|
||||
}, []);
|
||||
const close = useCallback(() => {
|
||||
setShowPostSelector(false);
|
||||
setCallback(null);
|
||||
setDate(dayjs());
|
||||
setDate(newDayjs());
|
||||
}, []);
|
||||
if (!showPostSelector) {
|
||||
return <></>;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import { deleteDialog } from '@gitroom/react/helpers/delete.dialog';
|
|||
import { useT } from '@gitroom/react/translation/get.transation.service.client';
|
||||
import dayjs from 'dayjs';
|
||||
import { AddEditModal } from '@gitroom/frontend/components/new-launch/add.edit.modal';
|
||||
import { newDayjs } from '@gitroom/frontend/components/layout/set.timezone';
|
||||
|
||||
const SaveSetModal: FC<{
|
||||
postData: any;
|
||||
|
|
@ -142,7 +143,7 @@ export const Sets: FC = () => {
|
|||
reopenModal={() => {}}
|
||||
mutate={() => {}}
|
||||
integrations={integrations}
|
||||
date={dayjs()}
|
||||
date={newDayjs()}
|
||||
/>
|
||||
),
|
||||
size: '80%',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
'use client';
|
||||
|
||||
import React from 'react';
|
||||
import { useT } from '@gitroom/react/translation/get.transation.service.client';
|
||||
import dynamic from 'next/dynamic';
|
||||
|
||||
const MetricComponent = dynamic(
|
||||
() => import('@gitroom/frontend/components/settings/metric.component'),
|
||||
{
|
||||
ssr: false,
|
||||
}
|
||||
);
|
||||
export const GlobalSettings = () => {
|
||||
const t = useT();
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
<h3 className="text-[20px]">{t('global_settings', 'Global Settings')}</h3>
|
||||
<MetricComponent />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
'use client';
|
||||
|
||||
import { Select } from '@gitroom/react/form/select';
|
||||
import React, { useState } from 'react';
|
||||
import { isUSCitizen } from '@gitroom/frontend/components/launches/helpers/isuscitizen.utils';
|
||||
import timezones from 'timezones-list';
|
||||
const dateMetrics = [
|
||||
{ label: 'AM:PM', value: 'US' },
|
||||
{ label: '24 hours', value: 'GLOBAL' },
|
||||
];
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import timezone from 'dayjs/plugin/timezone';
|
||||
dayjs.extend(timezone);
|
||||
|
||||
const MetricComponent = () => {
|
||||
const [currentMetric, setCurrentMetric] = useState(isUSCitizen());
|
||||
const [timezone, setTimezone] = useState(
|
||||
localStorage.getItem('timezone') || dayjs.tz.guess()
|
||||
);
|
||||
const changeMetric = (event: React.ChangeEvent<HTMLSelectElement>) => {
|
||||
const value = event.target.value;
|
||||
setCurrentMetric(value === 'US');
|
||||
localStorage.setItem('isUS', value);
|
||||
};
|
||||
|
||||
const changeTimezone = (event: React.ChangeEvent<HTMLSelectElement>) => {
|
||||
const value = event.target.value;
|
||||
console.log(value);
|
||||
setTimezone(value);
|
||||
localStorage.setItem('timezone', value);
|
||||
dayjs.tz.setDefault(value);
|
||||
};
|
||||
return (
|
||||
<div className="my-[16px] mt-[16px] bg-sixth border-fifth border rounded-[4px] p-[24px] flex flex-col gap-[24px]">
|
||||
<div className="mt-[4px]">Date Metrics</div>
|
||||
<Select name="metric" disableForm={true} label="" onChange={changeMetric}>
|
||||
{dateMetrics.map((metric) => (
|
||||
<option
|
||||
key={metric.value}
|
||||
value={metric.value}
|
||||
selected={currentMetric === (metric.value === 'US')}
|
||||
>
|
||||
{metric.label}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
|
||||
<div className="mt-[4px]">Current Timezone</div>
|
||||
<Select
|
||||
name="timezone"
|
||||
disableForm={true}
|
||||
label=""
|
||||
onChange={changeTimezone}
|
||||
>
|
||||
{timezones.map((metric) => (
|
||||
<option
|
||||
key={metric.name}
|
||||
value={metric.tzCode}
|
||||
selected={metric.tzCode === timezone}
|
||||
>
|
||||
{metric.label}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default MetricComponent;
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import { GithubComponent } from '@gitroom/frontend/components/settings/github.component';
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import { useUser } from '@gitroom/frontend/components/layout/user.context';
|
||||
import { TeamsComponent } from '@gitroom/frontend/components/settings/teams.component';
|
||||
import { useFetch } from '@gitroom/helpers/utils/custom.fetch';
|
||||
import useSWR from 'swr';
|
||||
import { LoadingComponent } from '@gitroom/frontend/components/layout/loading';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useVariables } from '@gitroom/react/helpers/variable.context';
|
||||
import { useT } from '@gitroom/react/translation/get.transation.service.client';
|
||||
export const SettingsComponent = () => {
|
||||
const { isGeneral } = useVariables();
|
||||
const user = useUser();
|
||||
const router = useRouter();
|
||||
const fetch = useFetch();
|
||||
const load = useCallback(async (path: string) => {
|
||||
const { github } = await (await fetch('/settings/github')).json();
|
||||
if (!github) {
|
||||
return false;
|
||||
}
|
||||
const emptyOnes = github.find((p: { login: string }) => !p.login);
|
||||
const { organizations } = emptyOnes
|
||||
? await (await fetch(`/settings/organizations/${emptyOnes.id}`)).json()
|
||||
: {
|
||||
organizations: [],
|
||||
};
|
||||
return {
|
||||
github,
|
||||
organizations,
|
||||
};
|
||||
}, []);
|
||||
const { isLoading: isLoadingSettings, data: loadAll } = useSWR(
|
||||
'load-all',
|
||||
load
|
||||
);
|
||||
useEffect(() => {
|
||||
if (!isLoadingSettings && !loadAll) {
|
||||
router.push('/');
|
||||
}
|
||||
}, [loadAll, isLoadingSettings]);
|
||||
|
||||
const t = useT();
|
||||
|
||||
if (isLoadingSettings) {
|
||||
return <LoadingComponent />;
|
||||
}
|
||||
if (!loadAll) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<div className="flex flex-col gap-[68px]">
|
||||
{!isGeneral && (
|
||||
<div className="flex flex-col">
|
||||
<h3 className="text-[20px]">
|
||||
{t('your_git_repository', 'Your Git Repository')}
|
||||
</h3>
|
||||
<div className="text-customColor18 mt-[4px]">
|
||||
{t(
|
||||
'connect_your_github_repository_to_receive_updates_and_analytics',
|
||||
'Connect your GitHub repository to receive updates and analytics'
|
||||
)}
|
||||
</div>
|
||||
<GithubComponent
|
||||
github={loadAll.github}
|
||||
organizations={loadAll.organizations}
|
||||
/>
|
||||
{/*<div className="flex gap-[5px]">*/}
|
||||
{/* <div>*/}
|
||||
{/* <Checkbox disableForm={true} checked={true} name="Send Email" />*/}
|
||||
{/* </div>*/}
|
||||
{/* <div>Show news with everybody in Gitroom</div>*/}
|
||||
{/*</div>*/}
|
||||
</div>
|
||||
)}
|
||||
{!!user?.tier?.team_members && <TeamsComponent />}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
@ -7,6 +7,7 @@ import { useFetch } from '@gitroom/helpers/utils/custom.fetch';
|
|||
import dayjs from 'dayjs';
|
||||
import { useParams } from 'next/navigation';
|
||||
import { AddEditModal } from '@gitroom/frontend/components/new-launch/add.edit.modal';
|
||||
import { newDayjs } from '@gitroom/frontend/components/layout/set.timezone';
|
||||
export const StandaloneModal: FC = () => {
|
||||
const fetch = useFetch();
|
||||
const params = useParams<{ platform: string }>();
|
||||
|
|
@ -17,7 +18,7 @@ export const StandaloneModal: FC = () => {
|
|||
|
||||
const loadDate = useCallback(async () => {
|
||||
if (params.platform === 'all') {
|
||||
return dayjs().utc().format('YYYY-MM-DDTHH:mm:ss');
|
||||
return newDayjs().utc().format('YYYY-MM-DDTHH:mm:ss');
|
||||
}
|
||||
return (await (await fetch('/posts/find-slot')).json()).date;
|
||||
}, []);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
"video_made_with_ai": "Video made with AI",
|
||||
"please_add_at_least": "Please add at least 20 chars",
|
||||
"send_invitation_via_email": "Send invitation via email?",
|
||||
"global_settings": "Global Settings",
|
||||
"copy_id": "Copy Channel ID",
|
||||
"team_members": "Team Members",
|
||||
"invite_your_assistant_or_team_member_to_manage_your_account": "Invite your assistant or team member to manage your account",
|
||||
|
|
|
|||
|
|
@ -212,6 +212,7 @@
|
|||
"tailwind-scrollbar": "^3.1.0",
|
||||
"tailwindcss": "3.4.17",
|
||||
"tailwindcss-rtl": "^0.9.0",
|
||||
"timezones-list": "^3.1.0",
|
||||
"tippy.js": "^6.3.7",
|
||||
"tldts": "^6.1.47",
|
||||
"transloadit": "^3.0.2",
|
||||
|
|
|
|||
|
|
@ -516,6 +516,9 @@ importers:
|
|||
tailwindcss-rtl:
|
||||
specifier: ^0.9.0
|
||||
version: 0.9.0
|
||||
timezones-list:
|
||||
specifier: ^3.1.0
|
||||
version: 3.1.0
|
||||
tippy.js:
|
||||
specifier: ^6.3.7
|
||||
version: 6.3.7
|
||||
|
|
@ -14263,6 +14266,9 @@ packages:
|
|||
thunky@1.1.0:
|
||||
resolution: {integrity: sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==}
|
||||
|
||||
timezones-list@3.1.0:
|
||||
resolution: {integrity: sha512-PcDBt9tae330KTOIufK/wArTlJp+unuuRcG0EEu+4oLHZACHefKQyP2D51gMZID+urye92mHND60KRVuDDAmbA==}
|
||||
|
||||
tiny-case@1.0.3:
|
||||
resolution: {integrity: sha512-Eet/eeMhkO6TX8mnUteS9zgPbUMQa4I6Kkp5ORiBD5476/m+PIRiumP5tmh5ioJpH7k51Kehawy2UDfsnxxY8Q==}
|
||||
|
||||
|
|
@ -33423,6 +33429,8 @@ snapshots:
|
|||
thunky@1.1.0:
|
||||
optional: true
|
||||
|
||||
timezones-list@3.1.0: {}
|
||||
|
||||
tiny-case@1.0.3: {}
|
||||
|
||||
tiny-inflate@1.0.3: {}
|
||||
|
|
|
|||
Loading…
Reference in New Issue