ScholarshipCore.jsx 1.31 KB
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
2
3
4
5
6
7
8
9
import PropTypes from "prop-types";
import React from "react";
import Scholarship from "./Scholarship";
import nullIfNaN from "../../../../utils/nullIfNaN";

export function getScholarshipDefaultModelData() {
  return {
    comment: "",
    frequency: null,
10
11
    amount_min: null,
    amount_max: null,
Florent Chehab's avatar
Florent Chehab committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
    other_advantages: "",
    title: "",
    short_description: "",
    importance_level: "-",
    currency: "EUR",
    obj_moderation_level: 0,
    useful_links: []
  };
}

function ScholarshipCore({ rawModelData }) {
  const {
    comment,
    frequency,
    currency,
    short_description,
    amount_min,
    amount_max,
    other_advantages
  } = rawModelData;

  return (
    <Scholarship
      currency={currency}
      frequency={frequency}
      shortDescription={short_description}
      amountMin={nullIfNaN(parseFloat(amount_min))}
      amountMax={nullIfNaN(parseFloat(amount_max))}
      otherAdvantages={other_advantages}
      comment={comment}
    />
  );
}

ScholarshipCore.propTypes = {
  rawModelData: PropTypes.shape({
    comment: PropTypes.string,
    frequency: PropTypes.string,
    currency: PropTypes.string,
    short_description: PropTypes.string,
    amount_min: PropTypes.string,
    amount_max: PropTypes.string,
    other_advantages: PropTypes.string
  }).isRequired
};

export default ScholarshipCore;