Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions frontend/apply/src/app/account/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,8 @@ export default function Account() {
onSubmit={handlePasswordSubmit}
title={t("accountPage.changePassword")}
primaryButtonDisabled={passwordLoading}
primaryButtonText={passwordLoading ? t("common.saving") : t("accountPage.changePassword")}
primaryButtonText={t("accountPage.changePassword")}
primaryButtonLoading={passwordLoading}
secondaryButtonDisabled={passwordLoading}
>
{passwordSuccess ? (
Expand Down Expand Up @@ -768,7 +769,8 @@ export default function Account() {
onSubmit={handleDeleteAccount}
title={t("accountPage.deleteAccount")}
primaryButtonDisabled={deleteLoading}
primaryButtonText={deleteLoading ? t("accountPage.deleting") : t("common.delete")}
primaryButtonText={t("common.delete")}
primaryButtonLoading={deleteLoading}
secondaryButtonDisabled={deleteLoading}
>
<p>{t("accountPage.deleteAccountConfirmation")}</p>
Expand Down
5 changes: 3 additions & 2 deletions frontend/apply/src/app/components/ApplicationCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { formatDateRange } from "@/utils/dateFormat";
import { Application } from "@/utils/types";
import { getImageUrl } from "@/utils/imageUrl";
import Image from "next/image";
import Link from "next/link";

type Props = {
application: Application;
Expand Down Expand Up @@ -58,12 +59,12 @@ const ApplicationCard = ({ application }: Props) => {
</div>

<div className={styles.cardButton}>
<a
<Link
className={"smallButton"}
href={`/apply/${application.position_details.id}`}
>
{t("common.viewApplication")}
</a>
</Link>
</div>
</div>
);
Expand Down
17 changes: 10 additions & 7 deletions frontend/apply/src/app/components/ApplicationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import "@/i18n/config";
import FormInput from "./FormInput";
import FormTextarea from "./FormTextarea";
import Modal from "./Modal";
import Button from "./Button";
import PositionInfoCard from "./PositionInfoCard";

type ApplicationFormProps = {
Expand Down Expand Up @@ -165,7 +166,6 @@ export default function ApplicationForm({

const handleDeleteDraft = async (event: React.FormEvent) => {
event.preventDefault();
console.log("Deleting draft with ID:", draftId);
if (!isDraft || draftId === null) return;
setDeletingDraft(true);
setError(null);
Expand Down Expand Up @@ -360,7 +360,7 @@ export default function ApplicationForm({
{editable ? (
<>
<div className={styles.draftSaveGroup}>
<button
<Button
type="button"
onClick={() => handleSubmit("draft")}
disabled={
Expand All @@ -372,9 +372,10 @@ export default function ApplicationForm({
!gdpr
}
className={`button ${styles.draftButton}`}
loading={savingDraft}
>
{savingDraft ? t("common.saving") : t("applicationForm.saveDraft")}
</button>
{t("applicationForm.saveDraft")}
</Button>

{showDraftSavedMessage && (
<p className={styles.draftSavedMessage}>
Expand All @@ -390,7 +391,7 @@ export default function ApplicationForm({
)}
</div>

<button
<Button
type="button"
onClick={() => {
setSubmitSuccess(false);
Expand All @@ -405,9 +406,10 @@ export default function ApplicationForm({
!gdpr
}
className={`button ${styles.submitButton}`}
loading={submittingApplication}
>
{submittingApplication ? t("applicationForm.submitting") : t("common.apply")}
</button>
{t("common.apply")}
</Button>

{isDraft && (
<button
Expand Down Expand Up @@ -437,6 +439,7 @@ export default function ApplicationForm({
onClose={() => setShowDeleteModal(false)}
title={t("applicationForm.deleteDraft")}
primaryButtonText={t("common.delete")}
primaryButtonLoading={deletingDraft}
onSubmit={handleDeleteDraft}
>
<p>{t("applicationForm.deleteDraftConfirmation")}</p>
Expand Down
9 changes: 6 additions & 3 deletions frontend/apply/src/app/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ interface ButtonProps {
children: React.ReactNode;
disabled?: boolean;
loading?: boolean;
type?: "button" | "submit" | "reset";
secondaryButton?: boolean;
}

export default function Button({
Expand All @@ -20,24 +22,25 @@ export default function Button({
disabled = false,
loading = false,
children,
type = "button",
secondaryButton = false,
}: ButtonProps) {
const button = React.useRef<HTMLButtonElement>(null);
if (loading) {
}
const buttonWidth = button.current?.offsetWidth || 0;
const buttonHeight = button.current?.offsetHeight || 0;
const cornerRadius = 10;
const borderWidth = 5;

return (
<button
className={`button activeButton ${className} ${disabled ? "disabled" : ""} ${
className={`button ${secondaryButton ? "" : "activeButton"} ${className} ${disabled ? "disabled" : ""} ${
loading ? "loading" : ""
}`}
onClick={onClick}
style={style}
ref={button}
disabled={disabled}
type={type}
>
{buttonWidth !== 0 && (
<svg
Expand Down
16 changes: 9 additions & 7 deletions frontend/apply/src/app/components/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { useTranslation } from "react-i18next";
import styles from "@/styles/modal.module.css";
import Button from "./Button";

interface ModalProps {
isOpen: boolean;
Expand All @@ -11,6 +12,7 @@ interface ModalProps {
children: React.ReactNode;
primaryButtonDisabled?: boolean;
primaryButtonText: string;
primaryButtonLoading?: boolean;
secondaryButtonDisabled?: boolean;
secondaryButtonText?: string;
showSecondaryButton?: boolean;
Expand All @@ -24,6 +26,7 @@ export default function Modal({
children,
primaryButtonDisabled,
primaryButtonText,
primaryButtonLoading = false,
secondaryButtonDisabled,
secondaryButtonText = "",
showSecondaryButton = true,
Expand Down Expand Up @@ -56,22 +59,21 @@ export default function Modal({
{children}
<div className={styles.modalActions}>
{showSecondaryButton && (
<button
type="button"
className="button"
<Button
onClick={onClose}
disabled={secondaryButtonDisabled}
secondaryButton
>
{secondaryButtonText}
</button>
</Button>
)}
<button
<Button
type="submit"
className="button activeButton"
disabled={primaryButtonDisabled}
loading={primaryButtonLoading}
>
{primaryButtonText}
</button>
</Button>
</div>
</form>
</div>
Expand Down
5 changes: 3 additions & 2 deletions frontend/apply/src/app/components/OpenPositionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "@/i18n/config";
import { formatDate } from "@/utils/dateFormat";
import Image from "next/image";
import { getImageUrl } from "@/utils/imageUrl";
import Link from "next/link";

type Props = {
position: Position;
Expand Down Expand Up @@ -42,7 +43,7 @@ const OpenPositionCard = ({ position }: Props) => {
<h4>
{t("openPositionCard.deadline")}: {formatDate(position.recruitment_end)}
</h4>
<a
<Link
className="smallButton"
onClick={(e) => e.stopPropagation()}
href={`/apply/${position.id}`}
Expand All @@ -52,7 +53,7 @@ const OpenPositionCard = ({ position }: Props) => {
: position.user_app_status === "In draft"
? t("openPositionCard.openDraft")
: t("common.apply")}
</a>
</Link>
</div>
</div>

Expand Down
4 changes: 1 addition & 3 deletions frontend/apply/src/app/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
"password": "Password",
"emailRequired": "Email is required",
"passwordRequired": "Password is required",
"signingIn": "Signing in...",
"signIn": "Sign in",
"noAccount": "Don't have an account? Register here",
"forgotPassword": "Forgot password?",
Expand Down Expand Up @@ -136,8 +135,7 @@
"deleteAccount": "Delete Account",
"deleteAccountConfirmation": "Are you sure you want to delete your account? This action cannot be undone.",
"accountDeletePasswordError": "Failed to delete account. Current password is incorrect.",
"accountDeleteError": "Failed to delete account. Please try again.",
"deleting": "Deleting..."
"accountDeleteError": "Failed to delete account. Please try again."
},
"openPositionCard": {
"deadline": "Deadline",
Expand Down
4 changes: 1 addition & 3 deletions frontend/apply/src/app/i18n/locales/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
"password": "Lösenord",
"emailRequired": "E-post krävs",
"passwordRequired": "Lösenord krävs",
"signingIn": "Loggar in...",
"signIn": "Logga in",
"noAccount": "Har du inget konto? Registrera dig här",
"forgotPassword": "Glömt lösenord?",
Expand Down Expand Up @@ -136,8 +135,7 @@
"deleteAccount": "Radera konto",
"deleteAccountConfirmation": "Är du säker på att du vill radera ditt konto? Denna åtgärd kan inte ångras.",
"accountDeletePasswordError": "Det gick inte att radera kontot. Nuvarande lösenord är felaktigt.",
"accountDeleteError": "Det gick inte att radera kontot. Försök igen.",
"deleting": "Raderar..."
"accountDeleteError": "Det gick inte att radera kontot. Försök igen."
},
"openPositionCard": {
"deadline": "Sista ansökningsdag",
Expand Down
16 changes: 10 additions & 6 deletions frontend/apply/src/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { useState } from "react";
import { useRouter } from "next/navigation";
import TextInput from "@/components/TextInput";
import Button from "@/components/Button";
import styles from "./login.module.css";
import { logIn } from "@/utils/auth";
import { useTranslation } from "react-i18next";
Expand Down Expand Up @@ -73,18 +74,21 @@ export default function Login() {
name="password"
type="password"
placeholder={t("loginPage.passwordPlaceholder")}
error={error && password === "" ? t("loginPage.passwordRequired") : ""}
error={
error && password === "" ? t("loginPage.passwordRequired") : ""
}
/>

{error && <div className={styles.errorMessage}>{error}</div>}

<button
className="button activeButton"
style={{ margin: "12px auto 0" }}
<Button
style={{ margin: "16px auto 0" }}
disabled={loading}
loading={loading}
type={"submit"}
>
{loading ? t("loginPage.signingIn") : t("loginPage.signIn")}
</button>
{t("loginPage.signIn")}
</Button>
</form>

<div className={styles.links}>
Expand Down
Loading