summaryrefslogtreecommitdiff
path: root/src/lib/checkout/email/FinishCheckoutEmail.jsx
blob: 2c31b8155a12bb173f5345da69e4eb76f1ad1fc9 (plain)
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
38
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
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
import currencyFormat from '@/core/utils/currencyFormat'
import toTitleCase from '@/core/utils/toTitleCase'
import {
  Body,
  Column,
  Container,
  Head,
  Heading,
  Hr,
  Html,
  Img,
  Row,
  Section,
  Text
} from '@react-email/components'

const FinishCheckoutEmail = ({ transaction, payment, statusPayment }) => {
  return (
    <Html>
      <Head />
      <Body style={style.main}>
        <Container style={style.container}>
          <Section style={{ marginTop: '32px' }}>
            <Img
              src={`${process.env.SELF_HOST}/images/indoteknik-logo.png`}
              width='150'
              height='50'
              alt='Indoteknik.com'
              style={{ margin: '0 auto' }}
            />
          </Section>
          <Heading style={style.h1}>
            {statusPayment == 'success' && 'Terimakasih untuk pembelian anda!'}
            {statusPayment == 'pending' && 'Menunggu Pembayaran'}
            {statusPayment == 'failed' && 'Pembayaran Tidak Berhasil'}
            {statusPayment == 'manual' && 'Pembelian di Indoteknik.com'}
          </Heading>

          <Text style={style.text}>Hai {transaction.address.customer.name},</Text>
          <Text style={style.text}>
            {statusPayment == 'success' && (
              <>
                Terima kasih atas kepercayaan anda berbelanja di Indoteknik. Dengan ini kami
                informasikan transaksi yang anda lakukan sebesar{' '}
                <span style={{ color: '#E20613' }}>{currencyFormat(payment.grossAmount)}</span>{' '}
                sudah berhasil dilakukan. Pembelian anda akan segera kami proses dan kirim sesuai
                dengan antrian pesanan yang masuk.
              </>
            )}
            {statusPayment == 'pending' && (
              <>
                Terima kasih atas kepercayaan anda berbelanja di Indoteknik. Dengan ini kami
                informasikan transaksi yang anda lakukan sebesar{' '}
                <span style={{ color: '#E20613' }}>{currencyFormat(payment.grossAmount)}</span>{' '}
                belum dilakukan. Silahkan lakukan pembayaran pada hari ini sebelum stoknya
                kehabisan.
              </>
            )}
            {statusPayment == 'failed' && (
              <>
                Terima kasih atas kepercayaan anda berbelanja di Indoteknik. Dengan ini kami
                informasikan transaksi yang anda lakukan Tidak Berhasil. Mohon untuk tidak melakukan
                pembayaran dikarenakan transaksi ini gagal kami terima. Segera lakukan pembelian
                kembali dengan produk yang anda inginkan di website Indoteknik.com.
              </>
            )}
            {statusPayment == 'manual' && (
              <>
                Terima kasih telah mempercayai Indoteknik.com sebagai Platform B2B industrial Supply
                & Solution
              </>
            )}
          </Text>
          <Text style={style.text}>
            {['pending', 'failed'].includes(statusPayment) && (
              <>
                Jika anda mengalami kesulitan, dapat menghubungi Customer Service kami untuk
                menanyakan transaksi anda lakukan melalui Whatsapp kami.
              </>
            )}
            {statusPayment == 'success' && (
              <>
                Anda dapat menghubungi Customer Service kami untuk menanyakan status pesanan yang
                sudah berhasil anda lakukan melalui Whatsapp kami.
              </>
            )}
            {statusPayment == 'manual' && (
              <>
                Kami mohon kepada {transaction.address.customer.name} untuk dapat segera
                menyelesaikan transaksi dengan detail dibawah ini:
                <ul>
                  <li>Nomor Pembelian: {transaction.name}</li>
                  <li>Nominal: {currencyFormat(transaction.amountTotal)}</li>
                  <li>Tanggal: {transaction.dateOrder}</li>
                </ul>
              </>
            )}
          </Text>

          {['pending', 'failed', 'success'].includes(statusPayment) && (
            <>
              <Text style={{ ...style.text, lineHeight: '100%', marginTop: '24px' }}>
                <strong>Detail Transaksi</strong>
              </Text>

              <Hr style={style.hr} />

              <Section style={style.alert}>
                {statusPayment == 'success' &&
                  'Struk ini dapat anda simpan sebagai bukti tambahan dalam transaksi yang telah dilakukan.'}
                {statusPayment == 'pending' &&
                  'Kami akan menginformasikan melalui email setelah anda berhasil melakukan pembayaran.'}
                {statusPayment == 'failed' &&
                  'Dimohon untuk tidak  melakukan pembayaran. Karena transaksi anda tidak berhasil dibuat.'}
              </Section>

              <Row style={style.descriptionRow}>
                <Column style={style.descriptionLCol}>No Transaksi (SO)</Column>
                <Column style={style.descriptionRCol}>{transaction.name}</Column>
              </Row>
              <Row style={style.descriptionRow}>
                <Column style={style.descriptionLCol}>Tanggal Transaksi</Column>
                <Column style={style.descriptionRCol}>{payment.transactionTime}</Column>
              </Row>
              <Row style={style.descriptionRow}>
                <Column style={style.descriptionLCol}>Status Pembayaran</Column>
                <Column style={{ ...style.descriptionRCol }}>
                  {statusPayment == 'success' && (
                    <div style={{ ...style.badge, ...style.badgeGreen }}>Berhasil</div>
                  )}
                  {statusPayment == 'pending' && (
                    <div style={{ ...style.badge, ...style.badgeRed }}>Pending</div>
                  )}
                  {statusPayment == 'failed' && (
                    <div style={{ ...style.badge, ...style.badgeRed }}>Tidak Berhasil</div>
                  )}
                </Column>
              </Row>
              <Row style={style.descriptionRow}>
                <Column style={style.descriptionLCol}>Metode Pembayaran</Column>
                <Column style={style.descriptionRCol}>
                  {toTitleCase(payment.paymentType.replaceAll('_', ' '))}
                </Column>
              </Row>
              <Row style={style.descriptionRow}>
                <Column style={style.descriptionLCol}>Batas Akhir Pembayaran</Column>
                <Column style={style.descriptionRCol}>{payment.expiryTime}</Column>
              </Row>
              <Row style={style.descriptionRow}>
                <Column style={style.descriptionLCol}>Nominal Transfer</Column>
                <Column style={style.descriptionRCol}>
                  <span style={{ fontWeight: '600' }}>{currencyFormat(payment.grossAmount)}</span>
                </Column>
              </Row>

              <Text style={{ ...style.text, lineHeight: '100%', marginTop: '24px' }}>
                <strong>Detail Produk</strong>
              </Text>

              <Hr style={style.hr} />

              {transaction.products.map((product) => (
                <Row
                  style={style.productRow}
                  key={product.id}
                >
                  <Column style={style.productLCol}>
                    <Img
                      src={product.parent.image}
                      width='100%'
                    />
                  </Column>
                  <Column style={style.productRCol}>
                    <Text style={style.productName}>{product.name}</Text>
                    <Text style={style.productCode}>{product.code}</Text>
                    <div style={{ dislay: 'flex' }}>
                      <span style={style.productPriceA}>
                        {currencyFormat(product.price.priceDiscount)}
                      </span>
                      {product.price.discountPercentage > 0 && (
                        <>
                          &nbsp;
                          <span style={style.productPriceB}>
                            {currencyFormat(product.price.price)}
                          </span>
                        </>
                      )}
                      &nbsp; x {product.quantity} barang
                    </div>
                  </Column>
                </Row>
              ))}

              <Hr style={style.hr} />

              <Row style={style.descriptionRow}>
                <Column style={style.descriptionLCol}>Subtotal</Column>
                <Column style={style.descriptionRCol}>
                  {currencyFormat(transaction.subtotal)}
                </Column>
              </Row>
              <Row style={style.descriptionRow}>
                <Column style={style.descriptionLCol}>Total Diskon</Column>
                <Column style={{ ...style.descriptionRCol, color: '#E20613' }}>
                  {currencyFormat(transaction.discountTotal)}
                </Column>
              </Row>
              <Row style={style.descriptionRow}>
                <Column style={style.descriptionLCol}>PPN 11% (Incl.)</Column>
                <Column style={style.descriptionRCol}>
                  {currencyFormat(transaction.subtotal * 0.11)}
                </Column>
              </Row>

              <Hr style={style.hr} />

              <Row style={style.descriptionRow}>
                <Column style={style.descriptionLCol}>Grand Total</Column>
                <Column style={style.descriptionRCol}>
                  <span style={{ fontWeight: '600' }}>
                    {currencyFormat(transaction.amountTotal)}
                  </span>
                </Column>
              </Row>

              <Hr style={style.hr} />
            </>
          )}

          {statusPayment == 'manual' && (
            <>
              <Text style={style.text}>
                Dengan cara dibawah ini:
                <ul>
                  <li>
                    Lakukan pembayaran manual via mobile app perbankan{' '}
                    {transaction.address.customer.name}
                    <br />
                    Nama Bank: Bank Central Asia (BCA)
                    <br />
                    No. Rek: 8870400081
                    <br />
                    A/N: INDOTEKNIK DOTCOM GEMILANG PT
                  </li>
                  <li>
                    Setelah berhasil melakukan pembayaran, mohon agar melakukan Screen Capture bukti
                    bayar sebagai bukti untuk kami bahwa {transaction.address.customer.name} telah
                    melakukan transaksi pembayaran
                  </li>
                  <li>
                    Kirimkan bukti transaksi pembayaran anda dengan melakukan reply / balas email
                    ini dengan melampirkan bukti di attachment / lampiran
                  </li>
                  <li>
                    Transaksi {transaction.address.customer.name} akan segera diproses oleh salah
                    satu Account Representative Indoteknik
                  </li>
                </ul>
              </Text>
              <Text style={style.text}>
                Jika ada pertanyaan seputar teknis pembayaran {transaction.address.customer.name}{' '}
                dapat hubungi kami melalui Email{' '}
                <a href='mailto:sales@indoteknik.com'>(sales@indoteknik.com)</a> atau Whatsapp{' '}
                <a href='https://wa.me/628128080622'>(+62 812-8080-622)</a>.
              </Text>
              <Text style={style.text}>
                Terima kasih atas perhatiannya, selamat kembali beraktifitas
              </Text>
            </>
          )}

          <Text style={{ ...style.text, margin: '12px 0 3px' }}>Best regards,</Text>

          <Text style={{ ...style.text, margin: '3px 0 0' }}>
            <strong>PT. Indoteknik Dotcom Gemilang</strong>
            <br />
            Jl. Bandengan Utara 85A No. 8-9 Penjaringan.
            <br />
            Kec. Penjaringan, Jakarta Utara - DKI Jakarta
          </Text>
        </Container>
      </Body>
    </Html>
  )
}

const style = {
  main: {
    backgroundColor: '#ffffff',
    margin: '0 auto',
    fontFamily:
      "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif"
  },
  container: {
    border: '1px solid #eaeaea',
    borderRadius: '5px',
    margin: '40px auto',
    padding: '20px',
    width: '465px'
  },
  h1: {
    color: '#000',
    fontSize: '24px',
    fontWeight: 'normal',
    textAlign: 'center',
    margin: '30px 0',
    padding: '0'
  },
  text: {
    color: '#000',
    fontSize: '14px',
    lineHeight: '24px'
  },
  alert: {
    backgroundColor: '#FDF1C7',
    border: '1px solid #F8C20A',
    padding: '8px',
    borderRadius: '6px',
    fontSize: '14px',
    margin: '16px 0'
  },
  hr: {
    border: 'none',
    borderTop: '1px solid #eaeaea',
    margin: '8px 0',
    width: '100%'
  },
  descriptionRow: {
    width: '100%',
    margin: '10px 0',
    fontSize: '14px'
  },
  descriptionLCol: {
    width: '50%',
    color: '#6B7280'
  },
  descriptionRCol: {
    width: '50%',
    textAlign: 'right'
  },
  productRow: {
    width: '100%',
    margin: '10px 0',
    fontSize: '14px'
  },
  productLCol: {
    width: '25%',
    border: '1px solid #eaeaea',
    borderRadius: '4px',
    padding: '1px'
  },
  productRCol: {
    width: '75%',
    padding: '0 8px',
    verticalAlign: 'top'
  },
  productName: {
    lineHeight: '121%',
    margin: '0 0 8px'
  },
  productCode: {
    color: '#6B7280',
    lineHeight: '100%',
    margin: '0 0 8px',
    fontSize: '14px'
  },
  productPriceA: {
    lineHeight: '100%',
    fontSize: '14px'
  },
  productPriceB: {
    color: '#6B7280',
    lineHeight: '100%',
    fontSize: '14px',
    textDecoration: 'line-through'
  },
  badge: {
    padding: '3px 6px',
    borderRadius: '6px',
    fontSize: '14px',
    width: 'fit-content',
    marginLeft: 'auto'
  },
  badgeRed: {
    color: '#E20613',
    backgroundColor: '#FCE2E4',
    border: '1px solid #E20613'
  },
  badgeGreen: {
    color: '#16A34A',
    backgroundColor: '#E7F4E9',
    border: '1px solid #16A34A'
  }
}

export default FinishCheckoutEmail