Skip to content

Commit

Permalink
Extended deadline for Finnish students (#95) (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nautman authored Apr 9, 2022
1 parent 6e946e0 commit f0e32cc
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"typescript.tsdk": "node_modules/typescript/lib"
}
34 changes: 34 additions & 0 deletions src/features/application/applicationSlice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* eslint-disable camelcase */
/* eslint-disable no-param-reassign */
import { PayloadAction, createSlice } from "@reduxjs/toolkit";

import { RootState } from "store";

interface Application {
finnish: boolean;
}

interface ApplicationState {
application: Application | null;
}

export const initialState: ApplicationState = {
application: null,
};

const applicationSlice = createSlice({
name: "application",
initialState,
reducers: {
applicationSuccess(state, action: PayloadAction<Application>) {
state.application = action.payload;
},
},
});

export const selectIsFinnish = (state: RootState): boolean | undefined =>
state.application.application?.finnish;

export const { applicationSuccess } = applicationSlice.actions;

export default applicationSlice.reducer;
8 changes: 6 additions & 2 deletions src/features/auth/AuthenticatedLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Axios from "axios";
import { TokenStorage } from "utils/tokenInterceptor";
import { useDispatch } from "react-redux";
import { useSelector } from "react-redux";
import { applicationSuccess } from "features/application/applicationSlice";

interface AuthenticatedLayerProps {
children: React.ReactElement;
Expand All @@ -22,8 +23,11 @@ export default function AuthenticatedLayer(
useEffect(() => {
Axios.get("/user/@me")
.then((res) => {
dispatch(authSuccess());
dispatch(userInfoSuccess(res.data));
Axios.get("/application/@me").then(r2 => {
dispatch(authSuccess());
dispatch(userInfoSuccess(res.data));
dispatch(applicationSuccess(r2.data))
})
})
.catch(console.error);
}, [isAuthenticated]);
Expand Down
9 changes: 8 additions & 1 deletion src/features/auth/register/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const Register: React.FC<WithTranslation> = ({ t }) => {
const { push } = useHistory();
const toastId = React.useRef<React.ReactText>(null);
const applicationHasClosed =
moment.utc().month(2).endOf("month").diff(Date.now()) < 0;
moment("04-23", "MM-DD").utc().diff(Date.now()) < 0;
return (
<Center maxWidth="850px">
<Plate>
Expand Down Expand Up @@ -203,6 +203,7 @@ const Register: React.FC<WithTranslation> = ({ t }) => {
type="radio"
id="custom-inline-radio-2"
name="finnish"
disabled
/>
</FormControl>
<FormControl.Feedback type="invalid">
Expand Down Expand Up @@ -232,6 +233,12 @@ const Register: React.FC<WithTranslation> = ({ t }) => {
{t(errors.dummy)}
</Alert>
)}
<Alert
style={{ width: "100%", margin: "10px 5%" }}
variant="warning"
>
{t("Application has closed for Sweden")}
</Alert>
<Button
size="lg"
type="submit"
Expand Down
7 changes: 5 additions & 2 deletions src/features/files/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Upload from "components/portal/Upload";
import moment from "moment";
import { toast } from "react-toastify";
import { useTranslation } from "react-i18next";
import { selectIsFinnish } from "features/application/applicationSlice";

interface UploadHookProps {
accept?: string;
Expand Down Expand Up @@ -46,6 +47,7 @@ const UploadHook: React.FC<UploadHookProps> = ({
const files = useSelector(
selectFilesByFileTypeAndApplicant(fileType, applicantID)
);
const isFinnish = useSelector(selectIsFinnish);
const { t } = useTranslation();

const handleDelete = (fileID: string, applicantID: string) =>
Expand Down Expand Up @@ -94,8 +96,9 @@ const UploadHook: React.FC<UploadHookProps> = ({

const handleCancel = () => setUploadingFiles([]);

const applicationHasClosed =
moment.utc().month(2).endOf("month").diff(Date.now()) < 0;
const applicationHasClosed = isFinnish
? moment("04-23", "MM-DD").utc().diff(Date.now()) < 0
: moment.utc().month(2).endOf("month").diff(Date.now()) < 0;
const disabledUploading =
(applicationHasClosed && !alwaysAbleToUpload) || disabled;
const label = t(`${fileType}.upload.label`);
Expand Down
7 changes: 5 additions & 2 deletions src/features/portal/References/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { RootState } from "store";
import moment from "moment";
import { selectRecommendation } from "features/portal/portalSlice";
import { toast } from "react-toastify";
import { selectIsFinnish } from "features/application/applicationSlice";

const UploadLink = ({ code }: { code: string }) => (
<a
Expand Down Expand Up @@ -38,9 +39,11 @@ const Person = ({
const recommendation = useSelector((state: RootState) =>
selectRecommendation(state, recommendationIndex)
);
const isFinnish = useSelector(selectIsFinnish);
const dispatch = useDispatch();
const applicationHasClosed =
moment.utc().month(2).endOf("month").diff(Date.now()) < 0;
const applicationHasClosed = isFinnish
? moment("04-23", "MM-DD").utc().diff(Date.now()) < 0
: moment.utc().month(2).endOf("month").diff(Date.now()) < 0;
function handleSubmit(email: string) {
setLoading(true);
Axios.post<Recommendation>(
Expand Down
7 changes: 5 additions & 2 deletions src/features/portal/Survey/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Axios from "axios";
import React from "react";
import moment from "moment";
import useAxios from "axios-hooks";
import { selectIsFinnish } from "features/application/applicationSlice";

function useSurvey(): [SurveyAnswers | undefined, boolean] {
const [{ data, loading }] = useAxios("/application/@me/survey");
Expand All @@ -18,9 +19,11 @@ function useSurvey(): [SurveyAnswers | undefined, boolean] {
const PortalSurvey = () => {
const [survey, loading] = useSurvey();
const dispatch = useDispatch();
const isFinnish = useSelector(selectIsFinnish);
if (loading) return <div></div>;
const applicationHasClosed =
moment.utc().month(2).endOf("month").diff(Date.now()) < 0;
const applicationHasClosed = isFinnish
? moment("04-23", "MM-DD").utc().diff(Date.now()) < 0
: moment.utc().month(2).endOf("month").diff(Date.now()) < 0;
return (
<Survey
survey={survey}
Expand Down
3 changes: 3 additions & 0 deletions src/features/portal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ const Hook = () => {
{t("Application complete")}
</Alert>
)}
<Alert variant="warning" style={{ marginTop: 10 }}>
{t("Application has closed for Sweden")}
</Alert>
<hr style={{ color: "#b8b8b8" }} />
</div>
<div>
Expand Down
3 changes: 2 additions & 1 deletion src/resources/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,6 @@
"Application has closed": "Application period has closed",
"Couldn't upload": "Couldn't upload file",
"Request failed with status code 415": "Unsupported media file. Check that your file really is a PDF and doesn't only end in .pdf",
"average": "Average"
"average": "Average",
"Application has closed for Sweden": "Application period has closed for Swedish students."
}
2 changes: 1 addition & 1 deletion src/resources/locales/portal_en.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "Application for Rays 2022",
"introduction": "Thank you for your interest in applying to Rays! We will be reading all applications and respond to you as we can. Below you can find the information we want you to send. On the **March 31st at 23:59** you will no longer be able to edit your application and it will automatically be sent to Rays. For your application to be sent you must have uplaoded all files and filled in the survey. Until this date you can update any part by simply uploading a new file again. Your old file will be replaced by the new one. All files must be in PDF-format and the specific requirements for word count can be located in each part. The file limit is 5 MB per part.\n\nWe who arrange Rays wish you the very best of luck and look forward to reading your application! [For more information please check the website!](http://raysforexcellence.se/ansok/)",
"introduction": "Thank you for your interest in applying to Rays! We will be reading all applications and respond to you as we can. Below you can find the information we want you to send. On the **March 31st at 23:59 (April 22nd at 23:59 for Finnish students)** you will no longer be able to edit your application and it will automatically be sent to Rays. For your application to be sent you must have uplaoded all files and filled in the survey. Until this date you can update any part by simply uploading a new file again. Your old file will be replaced by the new one. All files must be in PDF-format and the specific requirements for word count can be located in each part. The file limit is 5 MB per part.\n\nWe who arrange Rays wish you the very best of luck and look forward to reading your application! [For more information please check the website!](http://raysforexcellence.se/ansok/)",
"COVER_LETTER": {
"title": "Personal letter",
"subtitle": "Maximum 600 words",
Expand Down
2 changes: 1 addition & 1 deletion src/resources/locales/portal_sv.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "Ansökan för Rays 2022",
"introduction": "Tack för att du vill ansöka till Rays! Vi kommer att läsa alla ansökningar och återkomma så snart vi kan. Du ser nedan vilka uppgifter vi vill att du sänder in. Den **31 mars klockan 23:59** stänger möjligheten att ladda uppansökningar och då kommer din ansökan automatiskt att skickas in till Rays. För att din ansökan ska skickas måste du ha laddat upp alla filer samt fyllt i formuläret. Fram till detta datum kan du uppdatera en del genom att bara ladda upp en ny fil igen. Din gamla fil kommer då ersättas med den nya. Alla filer måste vara i pdf-format och de specifika begränsningarna för filstorlek och antalet ord står bredvid varje uppladdningsdel. Filstorleken är 5 MB per del.\n\nVi som arrangerar Rays önskar dig ett stort lycka till och ser fram emot att få läsa din ansökan! [För mer information tryck här!](http://raysforexcellence.se/ansok/)",
"introduction": "Tack för att du vill ansöka till Rays! Vi kommer att läsa alla ansökningar och återkomma så snart vi kan. Du ser nedan vilka uppgifter vi vill att du sänder in. Den **31 mars klockan 23:59 (22a april klockan 23:59 för finska studenter)** stänger möjligheten att ladda uppansökningar och då kommer din ansökan automatiskt att skickas in till Rays. För att din ansökan ska skickas måste du ha laddat upp alla filer samt fyllt i formuläret. Fram till detta datum kan du uppdatera en del genom att bara ladda upp en ny fil igen. Din gamla fil kommer då ersättas med den nya. Alla filer måste vara i pdf-format och de specifika begränsningarna för filstorlek och antalet ord står bredvid varje uppladdningsdel. Filstorleken är 5 MB per del.\n\nVi som arrangerar Rays önskar dig ett stort lycka till och ser fram emot att få läsa din ansökan! [För mer information tryck här!](http://raysforexcellence.se/ansok/)",
"COVER_LETTER": {
"title": "Personligt brev",
"subtitle": "Max 600 ord",
Expand Down
3 changes: 2 additions & 1 deletion src/resources/locales/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@
"Application has closed": "Ansökningsperioden har stängt",
"Couldn't upload": "Kunde inte ladda upp fil",
"Request failed with status code 415": "Otillåtet filformat. Kolla att din fil verkligen är en PDF och inte endast slutar med .pdf",
"average": "Medelvärde"
"average": "Medelvärde",
"Application has closed for Sweden": "Ansökningsperioden har stängt för svenska elever."
}
2 changes: 2 additions & 0 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import admin from "features/admin/adminSlice";
import auth from "features/auth/authSlice";
import files from "features/files/filesSlice";
import portal from "features/portal/portalSlice";
import application from "features/application/applicationSlice";
import storage from "redux-persist/lib/storage"; // defaults to localStorage for web

const persistConfig = {
Expand All @@ -31,6 +32,7 @@ const rootReducer = combineReducers({
portal,
admin,
files,
application
});

const persistedReducer = persistReducer(persistConfig, rootReducer);
Expand Down

0 comments on commit f0e32cc

Please sign in to comment.