Skip to content

Commit

Permalink
Merge pull request #4211 from webkom/change-default-survey-activation…
Browse files Browse the repository at this point in the history
…-time
  • Loading branch information
eikhr committed Oct 19, 2023
2 parents a33a654 + 728f777 commit 186f0a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/routes/surveys/AddSurveyRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import withPreparedDispatch from 'app/utils/withPreparedDispatch';
import SurveyEditor, {
initialQuestion,
} from './components/SurveyEditor/SurveyEditor';
import { defaultActiveFrom } from './utils';
import { getActiveFrom } from './utils';
import type { DeepPartial } from 'utility-types';

const loadData = (props, dispatch) => {
Expand Down Expand Up @@ -54,7 +54,7 @@ const mapStateToProps = (state, props) => {
label: fullEvent.title,
}
: undefined;
const activeFrom = fullEvent ? fullEvent.endTime : defaultActiveFrom(12, 0);
const activeFrom = getActiveFrom(fullEvent?.endTime, 14, 30);
const title = fullEvent ? `Spørreundersøkelse for ${fullEvent.title}` : '';
let initialValues: DeepPartial<FormSurvey> | null = null;

Expand Down
13 changes: 10 additions & 3 deletions app/routes/surveys/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Icon from 'app/components/Icon';
import NavigationTab from 'app/components/NavigationTab';
import NavigationLink from 'app/components/NavigationTab/NavigationLink';
import config from 'app/config';
import type { ActionGrant } from 'app/models';
import type { ActionGrant, Dateish } from 'app/models';
import type { ID } from 'app/store/models';
import styles from './components/surveys.css';
import type { ReactNode } from 'react';
Expand Down Expand Up @@ -76,8 +76,15 @@ export const TokenNavigation = ({
)}
</NavigationTab>
);
export const defaultActiveFrom = (hours: number, minutes: number) =>
moment().startOf('day').add({ day: 1, hours, minutes }).toISOString();
export const getActiveFrom = (
eventEndTime: Dateish,
hours: number,
minutes: number
) =>
moment(eventEndTime)
.startOf('day')
.add({ days: 1, hours, minutes })
.toISOString();

export const getCsvUrl = (surveyId: ID) =>
`${config.serverUrl}/surveys/${surveyId}/csv/`;
Expand Down

0 comments on commit 186f0a6

Please sign in to comment.