Karpetak ordenatzen ditu (#15)
* refactor: extract hooks * refactor: naming * refactor: naming * refactor: domain karpeta atontzen du * fix: og image konpontzen du * refactor: move component * refactor: move component * refactor: move component * refactor: move component
This commit is contained in:
78
front/src/domain/kafetegia/hooks/useKafetegiaContent.ts
Normal file
78
front/src/domain/kafetegia/hooks/useKafetegiaContent.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
import { graphql, useStaticQuery } from 'gatsby';
|
||||
|
||||
import { ProduktuaDTO } from '../dtos/ProduktuaDTO';
|
||||
import { KafetegiaContent } from '../KafetegiaContent';
|
||||
|
||||
export type MenuKonponentea =
|
||||
| {
|
||||
konponentea: 'StrapiComponentKafetegiaIzenburua';
|
||||
id: string;
|
||||
izenburuBalioa: string;
|
||||
}
|
||||
| {
|
||||
konponentea: 'StrapiComponentKafetegiaProduktuTaldea';
|
||||
id: string;
|
||||
izenburua: string;
|
||||
produktuak: ProduktuaDTO[];
|
||||
};
|
||||
|
||||
interface DataProps {
|
||||
strapiKafetegia: {
|
||||
deskribapena: string;
|
||||
izenburua: string;
|
||||
menua: MenuKonponentea[];
|
||||
};
|
||||
}
|
||||
|
||||
export function useKafetegiaContent(): KafetegiaContent {
|
||||
const {
|
||||
strapiKafetegia: { izenburua, deskribapena, menua },
|
||||
} = useStaticQuery<DataProps>(graphql`
|
||||
{
|
||||
strapiKafetegia {
|
||||
izenburua
|
||||
deskribapena
|
||||
menua {
|
||||
konponentea: __typename
|
||||
... on StrapiComponentKafetegiaIzenburua {
|
||||
izenburuBalioa
|
||||
id
|
||||
}
|
||||
... on StrapiComponentKafetegiaProduktuTaldea {
|
||||
id
|
||||
izenburua
|
||||
produktuak {
|
||||
id
|
||||
izena
|
||||
prezioa
|
||||
beganoa
|
||||
ekologikoa
|
||||
alergenoak {
|
||||
apioa
|
||||
arraina
|
||||
arrautzak
|
||||
esnekiak
|
||||
fruituLehorrak
|
||||
glutena
|
||||
kakahueteak
|
||||
krustazeoak
|
||||
lupinuak
|
||||
moluskuak
|
||||
sesamoa
|
||||
soja
|
||||
sulfitoak
|
||||
ziapea
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`);
|
||||
|
||||
return {
|
||||
izenburua,
|
||||
deskribapena,
|
||||
menua,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user