Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: open tenders screen #16

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
8 changes: 4 additions & 4 deletions packages/Upphandling/api/companies.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import axios from 'axios'
import {get} from 'axios'
export const getCompanies = async () => {
const { data } = await axios.get('https://api.upphandling.app/companies')
const { data } = await get('https://api.upphandling.app/companies')
return data
}

export const getCompanyFromId = async (id) => {
const { data } = await axios.get(`https://api.upphandling.app/companies/${id}`)
const { data } = await get(`https://api.upphandling.app/companies/${id}`)
return data
}

export const createCompany = async (company) => {
const { data } = await axios.post('https://api.upphandling.app/companies', company)
const { data } = await post('https://api.upphandling.app/companies', company)
return data
}
8 changes: 4 additions & 4 deletions packages/Upphandling/api/dis.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import axios from 'axios'
import {get, post} from 'axios'
export const getDis = async () => {
const { data } = await axios.get('https://api.upphandling.app/dis')
const { data } = await get('https://api.upphandling.app/dis')
return data
}

export const getDisById = async (id) => {
const { data } = await axios.get(`https://api.upphandling.app/dis/${id}`)
const { data } = await get(`https://api.upphandling.app/dis/${id}`)
return data
}

export const createDis = (dis) => {
console.log('Creating dis...', dis)
return axios.post('https://api.upphandling.app/dis', dis)
return post('https://api.upphandling.app/dis', dis)
}
4 changes: 2 additions & 2 deletions packages/Upphandling/api/github.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import axios from 'axios'
import {get} from 'axios'
// return issues for a repo
export const getIssues = async (owner, repo) => {
console.log('owner', owner, 'repo', repo)
const { data } = await axios.get(`https://api.github.com/repos/${owner}/${repo}/issues`, {
const { data } = await get(`https://api.github.com/repos/${owner}/${repo}/issues`, {
headers: {
//Authorization: `token ${process.env.REACT_APP_GITHUB_TOKEN}`,
Accept: 'application/vnd.github.v3+json'
Expand Down
6 changes: 6 additions & 0 deletions packages/Upphandling/api/offer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import axios from 'axios'

export const createOffer = async ({offer}) => {
const { data } = await axios.post(`https://api.upphandling.app/offers`, offer)
return data
}
6 changes: 3 additions & 3 deletions packages/Upphandling/api/offers.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import axios from 'axios'
import {get, post} from 'axios'
export const getOffers = async () => {
const { data } = await axios.get('https://api.upphandling.app/offers')
const { data } = await get('https://api.upphandling.app/offers')
return data
}

export const createOffer = (offer) => {
return axios.post('https://api.upphandling.app/offers', offer)
return post('https://api.upphandling.app/offers', offer)
}
6 changes: 3 additions & 3 deletions packages/Upphandling/api/participation.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import axios from 'axios'
import {get, post} from 'axios'
export const getParticipations = async (disId) => {
const { data } = await axios.get(`https://api.upphandling.app/dis/${disId}/companies`)
const { data } = await get(`https://api.upphandling.app/dis/${disId}/companies`)
return data
}

export const createParticipation = async ({disId, companyId}) => {
const { data } = await axios.post(`https://api.upphandling.app/participations`, {disId, companyId})
const { data } = await post(`https://api.upphandling.app/participations`, {disId, companyId})
return data
}
14 changes: 10 additions & 4 deletions packages/Upphandling/api/tenders.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import axios from 'axios'
import {get, post} from 'axios'

export const getTenders = async () => {
const { data } = await axios.get('https://api.upphandling.app/tenders')
export const getTenders = async (disId) => {
const { data } = await get(`https://api.upphandling.app/dis/${disId}/tenders`)
return data
}

export const getTender = async (tenderId) => {
const { data } = await get(`https://api.upphandling.app/tenders/${tenderId}`)
return data
}


export const createTender = async (tender) => {
console.log('creating tender', JSON.stringify(tender, null, 2))
const { data } = await axios.post('https://api.upphandling.app/tenders', tender).catch((error) => {
const { data } = await post('https://api.upphandling.app/tenders', tender).catch((error) => {
console.log('error', JSON.stringify(error))
throw error
})
Expand Down
Binary file added packages/Upphandling/assets/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 4 additions & 22 deletions packages/Upphandling/components/CompanyDetails.js
Original file line number Diff line number Diff line change
@@ -1,88 +1,70 @@
import React from 'react'
import {StyleSheet, View} from 'react-native'
import {Text} from '@ui-kitten/components'
import {Card, Text} from '@ui-kitten/components'
import { Field } from './Field'

export const CompanyDetails = ({company}) => (
<View style={styles.container}>
<Card style={styles.container} appearance="outline" status={"danger"}>
<Text style={styles.field} category="h6">
Företagsinformation
{company?.name}
</Text>
<Field
style={styles.field}
label="Företagsnamn"
disabled
placeholder="Ert företagsnamn"
value={company?.name} />

<Field
value={company?.phoneNumber}
disabled
style={styles.field}
label="Telefonnummer"
placeholder="Telefonnummer" />
<Field
value={company?.email}
disabled
style={styles.field}
label="E-post"
placeholder="E-post" />
<Field
value={company?.address}
disabled
style={styles.field}
label="Adress"
placeholder="Adress" />
<Field
value={company?.zipCode + ' ' + company?.town}
disabled
style={styles.field}
label="Postnummer"
placeholder="Postnummer" />
{company.country ? (
<Field
value={company?.country}
disabled
style={styles.field}
label="Land"
placeholder="Land" />
) : null}
<Field
value={company?.industryText}
disabled
style={styles.field}
label="Verksamhet"
placeholder="Programvaruleverantör etc" />
<Field
value={company?.legalGroupText}
disabled
style={styles.field}
label="Typ av organisation"
placeholder="Aktiebolag/Handelsbolag etc" />
<Field
value={company?.website}
style={styles.field}
label="Hemsida"
placeholder="Hemsida" />
<Field
value={company?.numberEmployeesInterval}
disabled
style={styles.field}
label="Antal anställda"
placeholder="Antal anställda" />
<Field
style={styles.field}
disabled
status="success"
label="Moms registrerad"
value={company?.vatReg ? `Ja (${company?.vatRegDate})` : 'Nej'} />
<Field
style={styles.field}
disabled
label="VD"
placeholder="VD / firmatecknare"
value={company?.topDirectorName} />
</View>
</Card>
)


Expand Down
5 changes: 3 additions & 2 deletions packages/Upphandling/components/Field.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import React from 'react'
import { StyleSheet } from 'react-native'
import { Divider, Layout, Text } from '@ui-kitten/components'

export const Field = ({style, label, value, ...layoutProps}) => {
export const Field = ({style, label, children, value, ...layoutProps}) => {

return (
<React.Fragment>
<Layout level="1" {...layoutProps} style={[styles.container, style]}>
<Text appearance="hint" category="s2">
{label}
</Text>
<Text category="s2">{value}</Text>
<Text category="s2">{value}{children}</Text>
</Layout>
<Divider />
</React.Fragment>
Expand All @@ -19,6 +19,7 @@ export const Field = ({style, label, value, ...layoutProps}) => {

const styles = StyleSheet.create({
container: {
padding: 16,
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
Expand Down
132 changes: 132 additions & 0 deletions packages/Upphandling/components/Hero.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import { ImageOverlay } from '../components/ImageOverlay'
import React from 'react'
import serviceIcons from '../data/services.json'
import { ScrollView, View } from 'react-native'
import moment from 'moment'
import 'moment/locale/sv'
moment.locale('sv')

import {
Button,
Card,
StyleService,
Text,
useStyleSheet,
} from '@ui-kitten/components'

const tagIcon = (style, icon) => <Icon {...style} name={icon} />

const tag = (service, index) => (
<Button
key={index}
style={styles.optionItem}
appearance="ghost"
size="small"
accessoryLeft={(style) => tagIcon(style, serviceIcons[service] ?? 'hash')}
>
{service}
</Button>
)

const footer = (services, technologies) => (
<View style={styles.footer}>
<View style={styles.optionList}>{services?.map(tag)}</View>
<ScrollView style={styles.detailsList} horizontal={true}>
{technologies?.map(renderDetailItem)}
</ScrollView>
</View>
)

export const Hero = ({
image,
title,
organisation,
status,
startDate,
services,
technologies,
onPress,
}) => {
return (
<>
<ImageOverlay
style={styles.image}
source={image || require('../assets/notebook-dynamic-gradient.png')}
/>
<Card
style={styles.bookingCard}
appearance="filled"
disabled={true}
footer={() => footer(services, technologies)}
>
<Text style={styles.title} category="h2">
{title}
</Text>
<Text style={styles.dateLabel} category="h6">
{organisation}
</Text>
<Text style={styles.label} category="p2">
{status}
</Text>
{startDate && (
<Text style={styles.dateLabel} category="p2">
{moment(startDate).format('YYYY-MM-DD')} (
{moment().to(moment(startDate))})
</Text>
)}
{onPress && (
<Button style={styles.ctaButton} onPress={onPress}>
Ansök
</Button>
)}
</Card>
</>
)
}

const styles = StyleService.create({
image: {
marginTop: -130,
height: 260,
},
bookingCard: {
marginTop: -80,
margin: 16,
borderRadius: 20,
},
title: {
width: '80%',
},
dateLabel: {
marginTop: 8,
},
footerLabel: {
marginBottom: 16,
color: '#333',
},
label: {
marginTop: 8,
},
ctaButton: {
position: 'absolute',
bottom: 24,
right: 24,
},
detailsList: {
flexDirection: 'row',
marginHorizontal: -4,
marginVertical: 8,
},
detailItem: {
marginHorizontal: 4,
borderRadius: 16,
},
optionList: {
flexDirection: 'row',
marginVertical: 8,
},
optionItem: {
marginHorizontal: 4,
paddingHorizontal: 0,
},
})
Loading