Fakultas Ilmu Komputer UI

DetailDonasiBarang.jsx 7.99 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
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
import React from "react";
import useFetchSingleData from "../../utils/useFetchSingleData";
import { css } from "@emotion/core";
import ArrowBackIcon from "@material-ui/icons/ArrowBack";
import PhoneIcon from "@material-ui/icons/Phone";
import { Link, navigate } from "@reach/router";
import PersonIcon from "@material-ui/icons/Person";
import { ErrorDiv } from "../../component/html/html";
import FormDonasiBarang from "./FormDonasiBarang";

const DetailDonasiBarang = ({ idDonasi }) => {
  const url = `${process.env.REACT_APP_BASE_URL}/program-donations/${idDonasi}/`;
  const [donation, error] = useFetchSingleData(url);

  if (Object.keys(donation).length === 0)
    return (
      <div
        data-testid="waiting-detail-donasi"
        css={css`
          display: flex;
          margin: 2rem 3rem 3rem 3rem;
          flex-direction: column;
          font-size: 25px;
        `}
      >
        {error && <ErrorDiv>Something error</ErrorDiv>}
        Fetching data..
      </div>
    );
  return (
    <div
      data-testid="page-detail-donasi"
      css={css`
        display: flex;
        margin: 2rem 3rem 3rem 3rem;
        flex-direction: column;
        justify-content: space-around;
38
        height: 60vh;
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
      `}
    >
      {error && <ErrorDiv>Something error</ErrorDiv>}
      <div>
        <button
          css={css`
            align-self: start;
            background-color: Transparent;
            background-repeat: no-repeat;
            border: none;
            cursor: pointer;
            overflow: hidden;
            outline: none;
            display: inline-block;
            vertical-align: middle;
          `}
          onClick={() => navigate(-1)}
        >
          <ArrowBackIcon fontSize="large" />
        </button>
        <div
          css={css`
            display: inline-block;
            font-size: 2rem;
            vertical-align: middle;
          `}
        >
          DETAIL DONASI
        </div>
      </div>
      <div
        css={css`
          display: flex;
          font-size: 1.2rem;
          align-items: baseline;
        `}
      >
        <PersonIcon style={{ color: "FFC80A" }} />
        <Link to={`/pengguna/${donation.user}`}>
          {donation.user_full_name} / {donation.user_username}
        </Link>
      </div>
      <div
        css={css`
          display: flex;
          font-size: 1.2rem;
          align-items: baseline;
        `}
      >
        <PhoneIcon style={{ color: "FFC80A" }} />
        <div>{donation.user_phone_number}</div>
      </div>
      <div
        css={css`
          display: flex;
          font-size: 1.2rem;
          align-items: baseline;
        `}
      >
        <div
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
          css={css`display: flex; justify-content: center; min-width:100%;`}><div className="detail-donasi-barang"
            css={css`
              background-color: #F2F2F2;
              border-radius: 15px;
              width: 650px;
              padding: 0.5rem 1rem 0.5rem 1rem;
              margin: 1rem 0 1rem 0;
          `}>
            <div
              css={css`
              font-style: normal;
              font-weight: bold;
              font-size: 25px;
              text-align: center;
              color: #4E7890;
            `}>
              DONASI BARANG</div>
            <div
              css={css`
              font-style: normal;
              font-weight: 500;
              font-size: 20px;
              text-align: center;
              color: #7D7D7D;
            `}>
              Kode: {donation.donation_number}
            </div>
            <div
              css={css`
              font-style: normal;
              font-weight: bold;
              font-size: 20px;
              line-height: 28px;
              border-bottom: 1px solid #C4C4C4;
              text-align: center;
              display: flex; justify-content: center;font-size: 1.3rem;
            `}>
              <div css={css`color: #4E7890; padding-right:6px;`}>
                Status:
              </div>
              {donation.donation_status !== "002" ? (
                <div css={css`
                color: #E7C340;
                `}>
                  Dalam Proses
                </div>
              ) : 
                <div css={css`
                  color: #4E7890;
                  `}>
                Donasi diterima
                </div>}
            </div>

            <div
              data-testid="detail-donasi-barang-test"
              className="donasi-barang"
              css={css`
            font-style: normal;
            font-weight: 300;
            font-size: 18px;
            padding: 1rem;
          `}>

              <div className="row" >

                <div className="col-3" css={css`display: flex; align-items: center;`}>
                  <div
                    css={css`
                    display: inline;
                    margin-left: 1rem;
                    font-style: normal;
                    font-weight: normal;
                    padding-bottom: 10px;
                    font-size: 18px;
                  `}
                  >
                    Program:
                </div>
                </div>

                <div className="col-9"
                  css={css` 
                font-style: normal;
                font-weight: normal;
                text-align: right;
                padding-right: 3rem;
                `}>
                  {donation.program_name}
                </div>
              </div>

              <div className="row" >

                <div className="col-3" css={css`display: flex; `}>
                  <div
                    css={css`
                  display: inline;
                  margin-left: 1rem;
                  font-style: normal;
                  font-weight: normal;
                  font-size: 18px;
                  padding-bottom: 10px;
                `}
                  >
                    Jenis Barang:
              </div></div>
                <div className="col-9"
                  css={css`
                font-style: normal;
                font-weight: normal;
                text-align: right;
                padding-right: 3rem;`}>
                  {donation.goods_description}
                </div>
              </div>

              <div className="row" >

                <div className="col-3" css={css`display: flex; `}>
                  <div
                    css={css`
                    display: inline;
                    margin-left: 1rem;
                    min-width:100%;
                    font-style: normal;
                    font-weight: normal;
                    font-size: 18px;
                    padding-bottom: 10px;
                  `}
                  >
                    Jumlah Barang:
                </div>
                </div>
                <div className="col-9"
                  css={css`
                font-style: normal;
                font-weight: normal;
                text-align: right;
                padding-right: 3rem;`}>
                  {donation.goods_quantity}
                </div>
              </div>

              <div
                css={css`
245
            font-size: 1.3rem;
246
247
            text-align: center;
            padding-bottom: 10px;
248
          `}
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
              >
                <div>
                  {donation.delivery_address === null ? (
                    <div>Diantar ke Masjid Al-Jabar</div>
                  ) : (
                    <div>Dijemput di {donation.delivery_address}</div>
                  )}
                </div>
              </div>
              <div css={css`display: flex; justify-content: center; min-width:100%;`}>{donation.donation_status !== "002" ? (
                <FormDonasiBarang
                  {...{
                    idDonasi,
                    defaultStatus: donation.donation_status,
                  }}
                />
              ) : <div css={css`
                  font-size: 1.3rem;
                  `}></div>}
              </div>
            </div>
270
271
272
273
274
275
276
277
          </div>
        </div>
      </div>
    </div>
  );
};

export default DetailDonasiBarang;